summaryrefslogtreecommitdiffstats
path: root/sys/contrib
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-04-07 06:22:22 +0000
committerglebius <glebius@FreeBSD.org>2015-04-07 06:22:22 +0000
commitf39ae51d4daa485c473c0da28eced9359a4c4d8e (patch)
tree220c80a3454f80e4e7104121b429c9d1bd2b8750 /sys/contrib
parent70540f5f7b429cf049c10870a997477bed109a51 (diff)
downloadFreeBSD-src-f39ae51d4daa485c473c0da28eced9359a4c4d8e.zip
FreeBSD-src-f39ae51d4daa485c473c0da28eced9359a4c4d8e.tar.gz
In ipfilter(4) there is the ipftest(1) program, that compiles half of the
ipfilter code as userland application. To reduce kernel structure knowledge include if_var.h only if a file is compiled with _KERNEL defined. In !_KERNEL case, provide our own definition of struct ifnet, that will satisfy ipftest(1). This was already done earlier to struct ifaddr in r279029. Protect the definition with _NET_IF_VAR_H_, since kernel part of ipfilter may include if_var.h and ip_compat.h. Sponsored by: Netflix Sponsored by: Nginx, Inc.
Diffstat (limited to 'sys/contrib')
-rw-r--r--sys/contrib/ipfilter/netinet/ip_compat.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/sys/contrib/ipfilter/netinet/ip_compat.h b/sys/contrib/ipfilter/netinet/ip_compat.h
index 6d74468..8aece74 100644
--- a/sys/contrib/ipfilter/netinet/ip_compat.h
+++ b/sys/contrib/ipfilter/netinet/ip_compat.h
@@ -153,7 +153,8 @@ struct ether_addr {
# include <sys/rwlock.h>
# define KMUTEX_T struct mtx
# define KRWLOCK_T struct rwlock
-# ifdef _KERNEL
+
+#ifdef _KERNEL
# define READ_ENTER(x) rw_rlock(&(x)->ipf_lk)
# define WRITE_ENTER(x) rw_wlock(&(x)->ipf_lk)
# define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk)
@@ -165,16 +166,7 @@ struct ether_addr {
else \
rw_runlock(&(x)->ipf_lk); \
} while (0)
-# endif
-
# include <net/if_var.h>
-# define IFNAME(x) ((struct ifnet *)x)->if_xname
-# define COPYIFNAME(v, x, b) \
- (void) strncpy(b, \
- ((struct ifnet *)x)->if_xname, \
- LIFNAMSIZ)
-
-# ifdef _KERNEL
# define GETKTIME(x) microtime((struct timeval *)x)
# include <netinet/in_systm.h>
@@ -216,8 +208,28 @@ struct ether_addr {
# define M_DUP(m) m_dup(m, M_NOWAIT)
# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
typedef struct mbuf mb_t;
-# endif /* _KERNEL */
+#else /* !_KERNEL */
+#ifndef _NET_IF_VAR_H_
+/*
+ * Userland emulation of struct ifnet.
+ */
+struct route;
+struct mbuf;
+struct ifnet {
+ char if_xname[IFNAMSIZ];
+ TAILQ_HEAD(, ifaddr) if_addrlist;
+ int (*if_output)(struct ifnet *, struct mbuf *,
+ const struct sockaddr *, struct route *);
+};
+#endif /* _NET_IF_VAR_H_ */
+#endif /* _KERNEL */
+
+# define IFNAME(x) ((struct ifnet *)x)->if_xname
+# define COPYIFNAME(v, x, b) \
+ (void) strncpy(b, \
+ ((struct ifnet *)x)->if_xname, \
+ LIFNAMSIZ)
typedef u_long ioctlcmd_t;
typedef struct uio uio_t;
OpenPOWER on IntegriCloud