svn commit: r281192 - head/sys/contrib/ipfilter/netinet
Gleb Smirnoff
glebius at FreeBSD.org
Tue Apr 7 06:22:23 UTC 2015
Author: glebius
Date: Tue Apr 7 06:22:22 2015
New Revision: 281192
URL: https://svnweb.freebsd.org/changeset/base/281192
Log:
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.
Modified:
head/sys/contrib/ipfilter/netinet/ip_compat.h
Modified: head/sys/contrib/ipfilter/netinet/ip_compat.h
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_compat.h Tue Apr 7 06:17:34 2015 (r281191)
+++ head/sys/contrib/ipfilter/netinet/ip_compat.h Tue Apr 7 06:22:22 2015 (r281192)
@@ -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;
More information about the svn-src-all
mailing list