diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2015-04-07 06:22:22 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2015-04-07 06:22:22 +0000 |
commit | b7703ad4323263efc9ae404a5441f33f92356428 (patch) | |
tree | 220c80a3454f80e4e7104121b429c9d1bd2b8750 /sys/contrib | |
parent | 6fe17960157674f5b9c0bcf126f707230bc0f4a4 (diff) | |
download | src-b7703ad4323263efc9ae404a5441f33f92356428.tar.gz src-b7703ad4323263efc9ae404a5441f33f92356428.zip |
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.
Notes
Notes:
svn path=/head/; revision=281192
Diffstat (limited to 'sys/contrib')
-rw-r--r-- | sys/contrib/ipfilter/netinet/ip_compat.h | 34 |
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 6d744683d467..8aece74b53cc 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; |