aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2013-10-31 17:33:29 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2013-10-31 17:33:29 +0000
commitf9b2a21c9eb4d2715be82dc9049eae29fdb40d17 (patch)
tree01dc64113d7529525013792f8b66cb32fa9df750 /sys/net
parent0bfd163f522701b486e066fa2e56624c02f5081a (diff)
parent5b74cfe42faa839e906c6444abf3509e193be160 (diff)
downloadsrc-f9b2a21c9eb4d2715be82dc9049eae29fdb40d17.tar.gz
src-f9b2a21c9eb4d2715be82dc9049eae29fdb40d17.zip
Merge head r232040 through r257457.
M usr.sbin/portsnap/portsnap/portsnap.8 M usr.sbin/portsnap/portsnap/portsnap.sh M usr.sbin/tcpdump/tcpdump/Makefile
Notes
Notes: svn path=/projects/pf/head/; revision=257458
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c1
-rw-r--r--sys/net/bpf.h8
-rw-r--r--sys/net/bridgestp.c1
-rw-r--r--sys/net/ieee8023ad_lacp.c3
-rw-r--r--sys/net/if.h12
-rw-r--r--sys/net/if_arcsubr.c1
-rw-r--r--sys/net/if_atmsubr.c1
-rw-r--r--sys/net/if_bridge.c1
-rw-r--r--sys/net/if_clone.c3
-rw-r--r--sys/net/if_clone.h2
-rw-r--r--sys/net/if_disc.c1
-rw-r--r--sys/net/if_edsc.c3
-rw-r--r--sys/net/if_ef.c1
-rw-r--r--sys/net/if_enc.c1
-rw-r--r--sys/net/if_epair.c1
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/if_faith.c1
-rw-r--r--sys/net/if_fddisubr.c1
-rw-r--r--sys/net/if_fwsubr.c1
-rw-r--r--sys/net/if_gif.c1
-rw-r--r--sys/net/if_gre.c1
-rw-r--r--sys/net/if_iso88025subr.c1
-rw-r--r--sys/net/if_loop.c1
-rw-r--r--sys/net/if_media.h7
-rw-r--r--sys/net/if_mib.c1
-rw-r--r--sys/net/if_spppfr.c1
-rw-r--r--sys/net/if_spppsubr.c1
-rw-r--r--sys/net/if_stf.c1
-rw-r--r--sys/net/if_tap.c3
-rw-r--r--sys/net/if_tun.c1
-rw-r--r--sys/net/if_var.h571
-rw-r--r--sys/net/if_vlan.c2
-rw-r--r--sys/net/if_vlan_var.h8
-rw-r--r--sys/net/ifq.h490
-rw-r--r--sys/net/pf_mtag.h62
-rw-r--r--sys/net/pfil.c1
-rw-r--r--sys/net/pfvar.h183
-rw-r--r--sys/net/raw_cb.c2
-rw-r--r--sys/net/raw_usrreq.c2
-rw-r--r--sys/net/route.c1
-rw-r--r--sys/net/rtsock.c1
41 files changed, 620 insertions, 769 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index cb3ed2716a5e..add10bf3469c 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <net/if.h>
+#include <net/if_var.h>
#define BPF_INTERNAL
#include <net/bpf.h>
#include <net/bpf_buffer.h>
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index e362f1612d61..b42b64b0ceae 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1310,4 +1310,12 @@ bpf_peers_present(struct bpf_if *bpf)
*/
#define BPF_MEMWORDS 16
+#ifdef _SYS_EVENTHANDLER_H_
+/* BPF attach/detach events */
+struct ifnet;
+typedef void (*bpf_track_fn)(void *, struct ifnet *, int /* dlt */,
+ int /* 1 =>'s attach */);
+EVENTHANDLER_DECLARE(bpf_track, bpf_track_fn);
+#endif /* _SYS_EVENTHANDLER_H_ */
+
#endif /* _NET_BPF_H_ */
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index 07cf2199f7d7..bd5ef9f906e6 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/taskqueue.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_llc.h>
diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c
index 8dbadd447711..423d3c485fed 100644
--- a/sys/net/ieee8023ad_lacp.c
+++ b/sys/net/ieee8023ad_lacp.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/callout.h>
+#include <sys/eventhandler.h>
#include <sys/mbuf.h>
#include <sys/systm.h>
#include <sys/malloc.h>
@@ -42,8 +43,10 @@ __FBSDID("$FreeBSD$");
#include <machine/stdarg.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
+#include <sys/taskqueue.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/ethernet.h>
#include <net/if_media.h>
diff --git a/sys/net/if.h b/sys/net/if.h
index 80a7112678d9..cd9adb317c82 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -35,10 +35,6 @@
#include <sys/cdefs.h>
-#ifdef _KERNEL
-#include <sys/queue.h>
-#endif
-
#if __BSD_VISIBLE
/*
* <net/if.h> does not depend on <sys/time.h> on most other systems. This
@@ -49,8 +45,6 @@
#include <sys/time.h>
#include <sys/socket.h>
#endif
-
-struct ifnet;
#endif
/*
@@ -537,10 +531,4 @@ struct if_nameindex *if_nameindex(void);
unsigned int if_nametoindex(const char *);
__END_DECLS
#endif
-
-#ifdef _KERNEL
-/* XXX - this should go away soon. */
-#include <net/if_var.h>
-#endif
-
#endif /* !_NET_IF_H_ */
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index 2f9478582d11..49c2dd3de685 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -57,6 +57,7 @@
#include <machine/cpu.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/if_dl.h>
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index d6190ec9fcd3..8bf8534bc851 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/if_dl.h>
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 572ee06d3660..a44596034979 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
#include "opt_inet6.h"
#include <sys/param.h>
+#include <sys/eventhandler.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/protosw.h>
diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c
index fcb71313047f..abbda41199d7 100644
--- a/sys/net/if_clone.c
+++ b/sys/net/if_clone.c
@@ -32,6 +32,7 @@
*/
#include <sys/param.h>
+#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/limits.h>
#include <sys/lock.h>
@@ -42,8 +43,8 @@
#include <sys/socket.h>
#include <net/if.h>
-#include <net/if_clone.h>
#include <net/if_var.h>
+#include <net/if_clone.h>
#include <net/radix.h>
#include <net/route.h>
#include <net/vnet.h>
diff --git a/sys/net/if_clone.h b/sys/net/if_clone.h
index 7159421aa8a1..90d9b7b18a15 100644
--- a/sys/net/if_clone.h
+++ b/sys/net/if_clone.h
@@ -58,9 +58,11 @@ int ifc_name2unit(const char *name, int *unit);
int ifc_alloc_unit(struct if_clone *, int *);
void ifc_free_unit(struct if_clone *, int);
+#ifdef _SYS_EVENTHANDLER_H_
/* Interface clone event. */
typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
+#endif
/* The below interfaces used only by net/if.c. */
void if_clone_init(void);
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 16a1e7b02f44..2afecfe644ee 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -45,6 +45,7 @@
#include <sys/sockio.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/route.h>
diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c
index b54cfaecc50d..3ee1c6d864af 100644
--- a/sys/net/if_edsc.c
+++ b/sys/net/if_edsc.c
@@ -46,7 +46,8 @@
#include <net/bpf.h> /* bpf(9) */
#include <net/ethernet.h> /* Ethernet related constants and types */
-#include <net/if.h> /* basic part of ifnet(9) */
+#include <net/if.h>
+#include <net/if_var.h> /* basic part of ifnet(9) */
#include <net/if_clone.h> /* network interface cloning */
#include <net/if_types.h> /* IFT_ETHER and friends */
#include <net/if_var.h> /* kernel-only part of ifnet(9) */
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index fc6402c137d7..887c9120e30a 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -43,6 +43,7 @@
#include <net/ethernet.h>
#include <net/if_llc.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_types.h>
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index dcb82f5d8f1b..fc78769ba54e 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -44,6 +44,7 @@
#include <sys/sysctl.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/pfil.h>
diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index 42a8a7a77255..03e379bd012c 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
@@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_media.h>
#include <net/if_var.h>
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 26e6edb58937..c4a9125c9f45 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -51,6 +51,7 @@
#include <sys/uuid.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/netisr.h>
#include <net/route.h>
@@ -62,10 +63,11 @@
#include <net/if_bridgevar.h>
#include <net/if_vlan_var.h>
#include <net/if_llatbl.h>
-#include <net/pf_mtag.h>
#include <net/pfil.h>
#include <net/vnet.h>
+#include <netpfil/pf/pf_mtag.h>
+
#if defined(INET) || defined(INET6)
#include <netinet/in.h>
#include <netinet/in_var.h>
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index 37a53bbeb8f3..277e54e2dcbf 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -56,6 +56,7 @@
#include <sys/malloc.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/netisr.h>
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 4f54dcb6780d..2f03bb7e5feb 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -51,6 +51,7 @@
#include <sys/sockio.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_llc.h>
#include <net/if_types.h>
diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c
index 31fc2a949bf3..5f0f9238794c 100644
--- a/sys/net/if_fwsubr.c
+++ b/sys/net/if_fwsubr.c
@@ -43,6 +43,7 @@
#include <sys/sockio.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/if_llc.h>
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index dfc2697e9af1..e39c1df5d3c5 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -53,6 +53,7 @@
#include <machine/cpu.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/netisr.h>
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 98090e548596..3176348d265d 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -62,6 +62,7 @@
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/route.h>
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 5975b282302b..825b220a1311 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -54,6 +54,7 @@
#include <sys/sockio.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_llc.h>
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 499cd2c06f8e..64f9209d1fd7 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -51,6 +51,7 @@
#include <sys/sysctl.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/netisr.h>
diff --git a/sys/net/if_media.h b/sys/net/if_media.h
index 7d26f7a35e5d..a7a775b9a60f 100644
--- a/sys/net/if_media.h
+++ b/sys/net/if_media.h
@@ -54,6 +54,8 @@
#include <sys/queue.h>
+struct ifnet;
+
/*
* Driver callbacks for media status and change requests.
*/
@@ -153,7 +155,10 @@ uint64_t ifmedia_baudrate(int);
#define IFM_40G_CR4 27 /* 40GBase-CR4 */
#define IFM_40G_SR4 28 /* 40GBase-SR4 */
#define IFM_40G_LR4 29 /* 40GBase-LR4 */
-
+/*
+ * Please update ieee8023ad_lacp.c:lacp_compose_key()
+ * after adding new Ethernet media types.
+ */
/* note 31 is the max! */
#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */
diff --git a/sys/net/if_mib.c b/sys/net/if_mib.c
index 97a2d4028466..aa6e6e5acb74 100644
--- a/sys/net/if_mib.c
+++ b/sys/net/if_mib.c
@@ -36,6 +36,7 @@
#include <sys/sysctl.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_mib.h>
#include <net/vnet.h>
diff --git a/sys/net/if_spppfr.c b/sys/net/if_spppfr.c
index b5e24f6802d2..a1518492c269 100644
--- a/sys/net/if_spppfr.c
+++ b/sys/net/if_spppfr.c
@@ -58,6 +58,7 @@
#endif
#include <net/if.h>
+#include <net/if_var.h>
#include <net/netisr.h>
#include <net/if_types.h>
#include <net/route.h>
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 9fe713c38910..b24ea73d3317 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -40,6 +40,7 @@
#include <sys/md5.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/netisr.h>
#include <net/if_types.h>
#include <net/route.h>
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 2c347398be66..e0bec252ce1e 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -94,6 +94,7 @@
#include <sys/malloc.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/route.h>
#include <net/netisr.h>
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index fe53a6acf4fb..6b93408f58f3 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -63,6 +63,7 @@
#include <net/bpf.h>
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_dl.h>
#include <net/if_media.h>
@@ -205,7 +206,7 @@ vmnet_clone_create(struct if_clone *ifc, int unit, caddr_t params)
i = clone_create(&tapclones, &tap_cdevsw, &unit, &dev, VMNET_DEV_MASK);
if (i) {
dev = make_dev(&tap_cdevsw, unit | VMNET_DEV_MASK, UID_ROOT,
- GID_WHEEL, 0600, "%s%d", tapname, unit);
+ GID_WHEEL, 0600, "%s%d", vmnetname, unit);
}
tapcreate(dev);
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 262d6d2f9a6c..ddef6f90d207 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -45,6 +45,7 @@
#include <sys/random.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_types.h>
#include <net/netisr.h>
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 73554a93f94f..f918a39a6833 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -58,38 +58,26 @@
* interfaces. These routines live in the files if.c and route.c
*/
-#ifdef __STDC__
-/*
- * Forward structure declarations for function prototypes [sic].
- */
-struct mbuf;
-struct thread;
-struct rtentry;
-struct rt_addrinfo;
+struct rtentry; /* ifa_rtrequest */
+struct rt_addrinfo; /* ifa_rtrequest */
struct socket;
-struct ether_header;
struct carp_if;
struct carp_softc;
struct ifvlantrunk;
-struct route;
+struct route; /* if_output */
struct vnet;
-#endif
-
-#include <sys/queue.h> /* get TAILQ macros */
#ifdef _KERNEL
-#include <sys/mbuf.h>
-#include <sys/eventhandler.h>
+#include <sys/mbuf.h> /* ifqueue only? */
#include <sys/buf_ring.h>
#include <net/vnet.h>
#endif /* _KERNEL */
#include <sys/counter.h>
#include <sys/lock.h> /* XXX */
-#include <sys/mutex.h> /* XXX */
+#include <sys/mutex.h> /* struct ifqueue */
#include <sys/rwlock.h> /* XXX */
#include <sys/sx.h> /* XXX */
-#include <sys/event.h> /* XXX */
-#include <sys/_task.h>
+#include <sys/_task.h> /* if_link_task */
#define IF_DUNIT_NONE -1
@@ -106,33 +94,44 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* packet filter hooks */
#endif /* _KERNEL */
/*
- * Structure defining a queue for a network interface.
- */
-struct ifqueue {
- struct mbuf *ifq_head;
- struct mbuf *ifq_tail;
- int ifq_len;
- int ifq_maxlen;
- int ifq_drops;
- struct mtx ifq_mtx;
-};
-
-/*
* Structure defining a network interface.
*
- * (Would like to call this struct ``if'', but C isn't PL/1.)
+ * Size ILP32: 592 (approx)
+ * LP64: 1048 (approx)
*/
-
struct ifnet {
+ /* General book keeping of interface lists. */
+ TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */
+ LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */
+ TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
+ /* protected by if_addr_lock */
+ u_char if_alloctype; /* if_type at time of allocation */
+
+ /* Driver and protocol specific information that remains stable. */
void *if_softc; /* pointer to driver state */
+ void *if_llsoftc; /* link layer softc */
void *if_l2com; /* pointer to protocol bits */
- struct vnet *if_vnet; /* pointer to network stack instance */
- TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */
- char if_xname[IFNAMSIZ]; /* external name (name + unit) */
const char *if_dname; /* driver name */
int if_dunit; /* unit or IF_DUNIT_NONE */
+ u_short if_index; /* numeric abbreviation for this if */
+ short if_index_reserved; /* spare space to grow if_index */
+ char if_xname[IFNAMSIZ]; /* external name (name + unit) */
+ char *if_description; /* interface description */
+
+ /* Variable fields that are touched by the stack and drivers. */
+ int if_flags; /* up/down, broadcast, etc. */
+ int if_capabilities; /* interface features & capabilities */
+ int if_capenable; /* enabled features & capabilities */
+ void *if_linkmib; /* link-type-specific MIB data */
+ size_t if_linkmiblen; /* length of above data */
+ int if_drv_flags; /* driver-managed status flags */
u_int if_refcount; /* reference count */
- struct ifaddrhead if_addrhead; /* linked list of addresses per if */
+ struct ifaltq if_snd; /* output queue (includes altq) */
+ struct if_data if_data; /* type information and statistics */
+ struct task if_linktask; /* task for link change events */
+
+ /* Addresses of different protocol families assigned to this if. */
+ struct rwlock if_addr_lock; /* lock to protect address lists */
/*
* if_addrhead is the list of all addresses associated to
* an interface.
@@ -143,21 +142,29 @@ struct ifnet {
* However, access to the AF_LINK address through this
* field is deprecated. Use if_addr or ifaddr_byindex() instead.
*/
- int if_pcount; /* number of promiscuous listeners */
- struct carp_if *if_carp; /* carp interface structure */
- struct bpf_if *if_bpf; /* packet filter structure */
- u_short if_index; /* numeric abbreviation for this if */
- short if_index_reserved; /* spare space to grow if_index */
- struct ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */
- int if_flags; /* up/down, broadcast, etc. */
- int if_capabilities; /* interface features & capabilities */
- int if_capenable; /* enabled features & capabilities */
- void *if_linkmib; /* link-type-specific MIB data */
- size_t if_linkmiblen; /* length of above data */
- struct if_data if_data;
+ struct ifaddrhead if_addrhead; /* linked list of addresses per if */
struct ifmultihead if_multiaddrs; /* multicast addresses configured */
int if_amcount; /* number of all-multicast requests */
-/* procedure handles */
+ struct ifaddr *if_addr; /* pointer to link-level address */
+ const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
+ struct rwlock if_afdata_lock;
+ void *if_afdata[AF_MAX];
+ int if_afdata_initialized;
+
+ /* Additional features hung off the interface. */
+ u_int if_fib; /* interface FIB */
+ struct vnet *if_vnet; /* pointer to network stack instance */
+ struct vnet *if_home_vnet; /* where this ifnet originates from */
+ struct ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */
+ struct bpf_if *if_bpf; /* packet filter structure */
+ int if_pcount; /* number of promiscuous listeners */
+ void *if_bridge; /* bridge glue */
+ void *if_lagg; /* lagg glue */
+ void *if_pf_kif; /* pf glue */
+ struct carp_if *if_carp; /* carp interface structure */
+ struct label *if_label; /* interface MAC label */
+
+ /* Various procedures of the layer2 encapsulation and drivers. */
int (*if_output) /* output routine (enqueue) */
(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
@@ -177,39 +184,12 @@ struct ifnet {
(struct ifnet *, struct mbuf *);
void (*if_reassign) /* reassign to vnet routine */
(struct ifnet *, struct vnet *, char *);
- struct vnet *if_home_vnet; /* where this ifnet originates from */
- struct ifaddr *if_addr; /* pointer to link-level address */
- void *if_llsoftc; /* link layer softc */
- int if_drv_flags; /* driver-managed status flags */
- struct ifaltq if_snd; /* output queue (includes altq) */
- const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
-
- void *if_bridge; /* bridge glue */
-
- struct label *if_label; /* interface MAC label */
-
- /* these are only used by IPv6 */
- void *if_unused[2];
- void *if_afdata[AF_MAX];
- int if_afdata_initialized;
- struct rwlock if_afdata_lock;
- struct task if_linktask; /* task for link change events */
- struct rwlock if_addr_lock; /* lock to protect address lists */
-
- LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */
- TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
- /* protected by if_addr_lock */
- void *if_pf_kif;
- void *if_lagg; /* lagg glue */
- char *if_description; /* interface description */
- u_int if_fib; /* interface FIB */
- u_char if_alloctype; /* if_type at time of allocation */
+ /* Stuff that's only temporary and doesn't belong here. */
u_int if_hw_tsomax; /* tso burst length limit, the minimum
* is (IP_MAXPACKET / 8).
* XXXAO: Have to find a better place
* for it eventually. */
-
/*
* Spare fields are added so that we can modify sensitive data
* structures without changing the kernel binary interface, and must
@@ -217,10 +197,11 @@ struct ifnet {
*/
char if_cspare[3];
int if_ispare[4];
+ void *if_unused[2];
void *if_pspare[8]; /* 1 netmap, 7 TDB */
};
-typedef void if_init_f_t(void *);
+#include <net/ifq.h> /* XXXAO: temporary unconditional include */
/*
* XXX These aliases are terribly dangerous because they could apply
@@ -276,97 +257,8 @@ void if_addr_runlock(struct ifnet *ifp); /* if_addrhead */
void if_maddr_rlock(struct ifnet *ifp); /* if_multiaddrs */
void if_maddr_runlock(struct ifnet *ifp); /* if_multiaddrs */
-/*
- * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
- * are queues of messages stored on ifqueue structures
- * (defined above). Entries are added to and deleted from these structures
- * by these macros.
- */
-#define IF_LOCK(ifq) mtx_lock(&(ifq)->ifq_mtx)
-#define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx)
-#define IF_LOCK_ASSERT(ifq) mtx_assert(&(ifq)->ifq_mtx, MA_OWNED)
-#define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
-#define _IF_DROP(ifq) ((ifq)->ifq_drops++)
-#define _IF_QLEN(ifq) ((ifq)->ifq_len)
-
-#define _IF_ENQUEUE(ifq, m) do { \
- (m)->m_nextpkt = NULL; \
- if ((ifq)->ifq_tail == NULL) \
- (ifq)->ifq_head = m; \
- else \
- (ifq)->ifq_tail->m_nextpkt = m; \
- (ifq)->ifq_tail = m; \
- (ifq)->ifq_len++; \
-} while (0)
-
-#define IF_ENQUEUE(ifq, m) do { \
- IF_LOCK(ifq); \
- _IF_ENQUEUE(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define _IF_PREPEND(ifq, m) do { \
- (m)->m_nextpkt = (ifq)->ifq_head; \
- if ((ifq)->ifq_tail == NULL) \
- (ifq)->ifq_tail = (m); \
- (ifq)->ifq_head = (m); \
- (ifq)->ifq_len++; \
-} while (0)
-
-#define IF_PREPEND(ifq, m) do { \
- IF_LOCK(ifq); \
- _IF_PREPEND(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define _IF_DEQUEUE(ifq, m) do { \
- (m) = (ifq)->ifq_head; \
- if (m) { \
- if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \
- (ifq)->ifq_tail = NULL; \
- (m)->m_nextpkt = NULL; \
- (ifq)->ifq_len--; \
- } \
-} while (0)
-
-#define IF_DEQUEUE(ifq, m) do { \
- IF_LOCK(ifq); \
- _IF_DEQUEUE(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define _IF_DEQUEUE_ALL(ifq, m) do { \
- (m) = (ifq)->ifq_head; \
- (ifq)->ifq_head = (ifq)->ifq_tail = NULL; \
- (ifq)->ifq_len = 0; \
-} while (0)
-
-#define IF_DEQUEUE_ALL(ifq, m) do { \
- IF_LOCK(ifq); \
- _IF_DEQUEUE_ALL(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define _IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
-#define IF_POLL(ifq, m) _IF_POLL(ifq, m)
-
-#define _IF_DRAIN(ifq) do { \
- struct mbuf *m; \
- for (;;) { \
- _IF_DEQUEUE(ifq, m); \
- if (m == NULL) \
- break; \
- m_freem(m); \
- } \
-} while (0)
-
-#define IF_DRAIN(ifq) do { \
- IF_LOCK(ifq); \
- _IF_DRAIN(ifq); \
- IF_UNLOCK(ifq); \
-} while(0)
-
#ifdef _KERNEL
+#ifdef _SYS_EVENTHANDLER_H_
/* interface link layer address change event */
typedef void (*iflladdr_event_handler_t)(void *, struct ifnet *);
EVENTHANDLER_DECLARE(iflladdr_event, iflladdr_event_handler_t);
@@ -382,6 +274,7 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
/* Interface link state change event */
typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int);
EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t);
+#endif /* _SYS_EVENTHANDLER_H_ */
/*
* interface groups
@@ -404,6 +297,7 @@ struct ifg_list {
TAILQ_ENTRY(ifg_list) ifgl_next;
};
+#ifdef _SYS_EVENTHANDLER_H_
/* group attach event */
typedef void (*group_attach_event_handler_t)(void *, struct ifg_group *);
EVENTHANDLER_DECLARE(group_attach_event, group_attach_event_handler_t);
@@ -413,6 +307,7 @@ EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t);
/* group change event */
typedef void (*group_change_event_handler_t)(void *, const char *);
EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
+#endif /* _SYS_EVENTHANDLER_H_ */
#define IF_AFDATA_LOCK_INIT(ifp) \
rw_init(&(ifp)->if_afdata_lock, "if_afdata")
@@ -431,172 +326,6 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
#define IF_AFDATA_WLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_WLOCKED)
#define IF_AFDATA_UNLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED)
-int if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp,
- int adjust);
-#define IF_HANDOFF(ifq, m, ifp) \
- if_handoff((struct ifqueue *)ifq, m, ifp, 0)
-#define IF_HANDOFF_ADJ(ifq, m, ifp, adj) \
- if_handoff((struct ifqueue *)ifq, m, ifp, adj)
-
-void if_start(struct ifnet *);
-
-#define IFQ_ENQUEUE(ifq, m, err) \
-do { \
- IF_LOCK(ifq); \
- if (ALTQ_IS_ENABLED(ifq)) \
- ALTQ_ENQUEUE(ifq, m, NULL, err); \
- else { \
- if (_IF_QFULL(ifq)) { \
- m_freem(m); \
- (err) = ENOBUFS; \
- } else { \
- _IF_ENQUEUE(ifq, m); \
- (err) = 0; \
- } \
- } \
- if (err) \
- (ifq)->ifq_drops++; \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define IFQ_DEQUEUE_NOLOCK(ifq, m) \
-do { \
- if (TBR_IS_ENABLED(ifq)) \
- (m) = tbr_dequeue_ptr(ifq, ALTDQ_REMOVE); \
- else if (ALTQ_IS_ENABLED(ifq)) \
- ALTQ_DEQUEUE(ifq, m); \
- else \
- _IF_DEQUEUE(ifq, m); \
-} while (0)
-
-#define IFQ_DEQUEUE(ifq, m) \
-do { \
- IF_LOCK(ifq); \
- IFQ_DEQUEUE_NOLOCK(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define IFQ_POLL_NOLOCK(ifq, m) \
-do { \
- if (TBR_IS_ENABLED(ifq)) \
- (m) = tbr_dequeue_ptr(ifq, ALTDQ_POLL); \
- else if (ALTQ_IS_ENABLED(ifq)) \
- ALTQ_POLL(ifq, m); \
- else \
- _IF_POLL(ifq, m); \
-} while (0)
-
-#define IFQ_POLL(ifq, m) \
-do { \
- IF_LOCK(ifq); \
- IFQ_POLL_NOLOCK(ifq, m); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define IFQ_PURGE_NOLOCK(ifq) \
-do { \
- if (ALTQ_IS_ENABLED(ifq)) { \
- ALTQ_PURGE(ifq); \
- } else \
- _IF_DRAIN(ifq); \
-} while (0)
-
-#define IFQ_PURGE(ifq) \
-do { \
- IF_LOCK(ifq); \
- IFQ_PURGE_NOLOCK(ifq); \
- IF_UNLOCK(ifq); \
-} while (0)
-
-#define IFQ_SET_READY(ifq) \
- do { ((ifq)->altq_flags |= ALTQF_READY); } while (0)
-
-#define IFQ_LOCK(ifq) IF_LOCK(ifq)
-#define IFQ_UNLOCK(ifq) IF_UNLOCK(ifq)
-#define IFQ_LOCK_ASSERT(ifq) IF_LOCK_ASSERT(ifq)
-#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
-#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
-#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
-#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
-#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
-
-/*
- * The IFF_DRV_OACTIVE test should really occur in the device driver, not in
- * the handoff logic, as that flag is locked by the device driver.
- */
-#define IFQ_HANDOFF_ADJ(ifp, m, adj, err) \
-do { \
- int len; \
- short mflags; \
- \
- len = (m)->m_pkthdr.len; \
- mflags = (m)->m_flags; \
- IFQ_ENQUEUE(&(ifp)->if_snd, m, err); \
- if ((err) == 0) { \
- (ifp)->if_obytes += len + (adj); \
- if (mflags & M_MCAST) \
- (ifp)->if_omcasts++; \
- if (((ifp)->if_drv_flags & IFF_DRV_OACTIVE) == 0) \
- if_start(ifp); \
- } \
-} while (0)
-
-#define IFQ_HANDOFF(ifp, m, err) \
- IFQ_HANDOFF_ADJ(ifp, m, 0, err)
-
-#define IFQ_DRV_DEQUEUE(ifq, m) \
-do { \
- (m) = (ifq)->ifq_drv_head; \
- if (m) { \
- if (((ifq)->ifq_drv_head = (m)->m_nextpkt) == NULL) \
- (ifq)->ifq_drv_tail = NULL; \
- (m)->m_nextpkt = NULL; \
- (ifq)->ifq_drv_len--; \
- } else { \
- IFQ_LOCK(ifq); \
- IFQ_DEQUEUE_NOLOCK(ifq, m); \
- while ((ifq)->ifq_drv_len < (ifq)->ifq_drv_maxlen) { \
- struct mbuf *m0; \
- IFQ_DEQUEUE_NOLOCK(ifq, m0); \
- if (m0 == NULL) \
- break; \
- m0->m_nextpkt = NULL; \
- if ((ifq)->ifq_drv_tail == NULL) \
- (ifq)->ifq_drv_head = m0; \
- else \
- (ifq)->ifq_drv_tail->m_nextpkt = m0; \
- (ifq)->ifq_drv_tail = m0; \
- (ifq)->ifq_drv_len++; \
- } \
- IFQ_UNLOCK(ifq); \
- } \
-} while (0)
-
-#define IFQ_DRV_PREPEND(ifq, m) \
-do { \
- (m)->m_nextpkt = (ifq)->ifq_drv_head; \
- if ((ifq)->ifq_drv_tail == NULL) \
- (ifq)->ifq_drv_tail = (m); \
- (ifq)->ifq_drv_head = (m); \
- (ifq)->ifq_drv_len++; \
-} while (0)
-
-#define IFQ_DRV_IS_EMPTY(ifq) \
- (((ifq)->ifq_drv_len == 0) && ((ifq)->ifq_len == 0))
-
-#define IFQ_DRV_PURGE(ifq) \
-do { \
- struct mbuf *m, *n = (ifq)->ifq_drv_head; \
- while((m = n) != NULL) { \
- n = m->m_nextpkt; \
- m_freem(m); \
- } \
- (ifq)->ifq_drv_head = (ifq)->ifq_drv_tail = NULL; \
- (ifq)->ifq_drv_len = 0; \
- IFQ_PURGE(ifq); \
-} while (0)
-
-#ifdef _KERNEL
static __inline void
if_initbaudrate(struct ifnet *ifp, uintmax_t baud)
{
@@ -609,165 +338,6 @@ if_initbaudrate(struct ifnet *ifp, uintmax_t baud)
ifp->if_baudrate = baud;
}
-static __inline int
-drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
-{
- int error = 0;
-
-#ifdef ALTQ
- if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
- IFQ_ENQUEUE(&ifp->if_snd, m, error);
- return (error);
- }
-#endif
- error = buf_ring_enqueue(br, m);
- if (error)
- m_freem(m);
-
- return (error);
-}
-
-static __inline void
-drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new)
-{
- /*
- * The top of the list needs to be swapped
- * for this one.
- */
-#ifdef ALTQ
- if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
- /*
- * Peek in altq case dequeued it
- * so put it back.
- */
- IFQ_DRV_PREPEND(&ifp->if_snd, new);
- return;
- }
-#endif
- buf_ring_putback_sc(br, new);
-}
-
-static __inline struct mbuf *
-drbr_peek(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- struct mbuf *m;
- if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
- /*
- * Pull it off like a dequeue
- * since drbr_advance() does nothing
- * for altq and drbr_putback() will
- * use the old prepend function.
- */
- IFQ_DEQUEUE(&ifp->if_snd, m);
- return (m);
- }
-#endif
- return(buf_ring_peek(br));
-}
-
-static __inline void
-drbr_flush(struct ifnet *ifp, struct buf_ring *br)
-{
- struct mbuf *m;
-
-#ifdef ALTQ
- if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
- IFQ_PURGE(&ifp->if_snd);
-#endif
- while ((m = buf_ring_dequeue_sc(br)) != NULL)
- m_freem(m);
-}
-
-static __inline void
-drbr_free(struct buf_ring *br, struct malloc_type *type)
-{
-
- drbr_flush(NULL, br);
- buf_ring_free(br, type);
-}
-
-static __inline struct mbuf *
-drbr_dequeue(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- struct mbuf *m;
-
- if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
- IFQ_DEQUEUE(&ifp->if_snd, m);
- return (m);
- }
-#endif
- return (buf_ring_dequeue_sc(br));
-}
-
-static __inline void
-drbr_advance(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- /* Nothing to do here since peek dequeues in altq case */
- if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
- return;
-#endif
- return (buf_ring_advance_sc(br));
-}
-
-
-static __inline struct mbuf *
-drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring *br,
- int (*func) (struct mbuf *, void *), void *arg)
-{
- struct mbuf *m;
-#ifdef ALTQ
- if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
- IFQ_LOCK(&ifp->if_snd);
- IFQ_POLL_NOLOCK(&ifp->if_snd, m);
- if (m != NULL && func(m, arg) == 0) {
- IFQ_UNLOCK(&ifp->if_snd);
- return (NULL);
- }
- IFQ_DEQUEUE_NOLOCK(&ifp->if_snd, m);
- IFQ_UNLOCK(&ifp->if_snd);
- return (m);
- }
-#endif
- m = buf_ring_peek(br);
- if (m == NULL || func(m, arg) == 0)
- return (NULL);
-
- return (buf_ring_dequeue_sc(br));
-}
-
-static __inline int
-drbr_empty(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- if (ALTQ_IS_ENABLED(&ifp->if_snd))
- return (IFQ_IS_EMPTY(&ifp->if_snd));
-#endif
- return (buf_ring_empty(br));
-}
-
-static __inline int
-drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- if (ALTQ_IS_ENABLED(&ifp->if_snd))
- return (1);
-#endif
- return (!buf_ring_empty(br));
-}
-
-static __inline int
-drbr_inuse(struct ifnet *ifp, struct buf_ring *br)
-{
-#ifdef ALTQ
- if (ALTQ_IS_ENABLED(&ifp->if_snd))
- return (ifp->if_snd.ifq_len);
-#endif
- return (buf_ring_count(br));
-}
-#endif
/*
* 72 was chosen below because it is the size of a TCP/IP
* header (40) + the minimum mss (32).
@@ -903,8 +473,6 @@ VNET_DECLARE(int, useloopback);
#define V_loif VNET(loif)
#define V_useloopback VNET(useloopback)
-extern int ifqmaxlen;
-
int if_addgroup(struct ifnet *, const char *);
int if_delgroup(struct ifnet *, const char *);
int if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **);
@@ -925,7 +493,6 @@ void if_free(struct ifnet *);
void if_initname(struct ifnet *, const char *, int);
void if_link_state_change(struct ifnet *, int);
int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3);
-void if_qflush(struct ifnet *);
void if_ref(struct ifnet *);
void if_rele(struct ifnet *);
int if_setlladdr(struct ifnet *, const u_char *, int);
@@ -935,9 +502,6 @@ int ifpromisc(struct ifnet *, int);
struct ifnet *ifunit(const char *);
struct ifnet *ifunit_ref(const char *);
-void ifq_init(struct ifaltq *, struct ifnet *ifp);
-void ifq_delete(struct ifaltq *);
-
int ifa_add_loopback_route(struct ifaddr *, struct sockaddr *);
int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *);
@@ -961,14 +525,5 @@ void if_deregister_com_alloc(u_char type);
#define IF_LLADDR(ifp) \
LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
-#ifdef DEVICE_POLLING
-enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS };
-
-typedef int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count);
-int ether_poll_register(poll_handler_t *h, struct ifnet *ifp);
-int ether_poll_deregister(struct ifnet *ifp);
-#endif /* DEVICE_POLLING */
-
#endif /* _KERNEL */
-
#endif /* !_NET_IF_VAR_H_ */
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index b7f119715fc5..75699fb8ff25 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include "opt_vlan.h"
#include <sys/param.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -61,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_clone.h>
#include <net/if_dl.h>
#include <net/if_types.h>
diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h
index 4eb3b09feb3e..b24087435da2 100644
--- a/sys/net/if_vlan_var.h
+++ b/sys/net/if_vlan_var.h
@@ -150,6 +150,14 @@ extern int (*vlan_tag_p)(struct ifnet *, uint16_t *);
extern int (*vlan_setcookie_p)(struct ifnet *, void *);
extern void *(*vlan_cookie_p)(struct ifnet *);
+#ifdef _SYS_EVENTHANDLER_H_
+/* VLAN state change events */
+typedef void (*vlan_config_fn)(void *, struct ifnet *, uint16_t);
+typedef void (*vlan_unconfig_fn)(void *, struct ifnet *, uint16_t);
+EVENTHANDLER_DECLARE(vlan_config, vlan_config_fn);
+EVENTHANDLER_DECLARE(vlan_unconfig, vlan_unconfig_fn);
+#endif /* _SYS_EVENTHANDLER_H_ */
+
#endif /* _KERNEL */
#endif /* _NET_IF_VLAN_VAR_H_ */
diff --git a/sys/net/ifq.h b/sys/net/ifq.h
new file mode 100644
index 000000000000..18d61e22d371
--- /dev/null
+++ b/sys/net/ifq.h
@@ -0,0 +1,490 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * From: @(#)if.h 8.1 (Berkeley) 6/10/93
+ * $FreeBSD$
+ */
+
+#ifndef _NET_IFQ_H_
+#define _NET_IFQ_H_
+
+#ifdef _KERNEL
+#include <sys/mbuf.h> /* ifqueue only? */
+#include <sys/buf_ring.h>
+#include <net/vnet.h>
+#endif /* _KERNEL */
+#include <sys/lock.h> /* XXX */
+#include <sys/mutex.h> /* struct ifqueue */
+
+#define IF_DUNIT_NONE -1
+
+#include <altq/if_altq.h>
+
+/*
+ * Structure defining a queue for a network interface.
+ */
+struct ifqueue {
+ struct mbuf *ifq_head;
+ struct mbuf *ifq_tail;
+ int ifq_len;
+ int ifq_maxlen;
+ int ifq_drops;
+ struct mtx ifq_mtx;
+};
+
+#ifdef _KERNEL
+/*
+ * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
+ * are queues of messages stored on ifqueue structures
+ * (defined above). Entries are added to and deleted from these structures
+ * by these macros.
+ */
+#define IF_LOCK(ifq) mtx_lock(&(ifq)->ifq_mtx)
+#define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx)
+#define IF_LOCK_ASSERT(ifq) mtx_assert(&(ifq)->ifq_mtx, MA_OWNED)
+#define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
+#define _IF_DROP(ifq) ((ifq)->ifq_drops++)
+#define _IF_QLEN(ifq) ((ifq)->ifq_len)
+
+#define _IF_ENQUEUE(ifq, m) do { \
+ (m)->m_nextpkt = NULL; \
+ if ((ifq)->ifq_tail == NULL) \
+ (ifq)->ifq_head = m; \
+ else \
+ (ifq)->ifq_tail->m_nextpkt = m; \
+ (ifq)->ifq_tail = m; \
+ (ifq)->ifq_len++; \
+} while (0)
+
+#define IF_ENQUEUE(ifq, m) do { \
+ IF_LOCK(ifq); \
+ _IF_ENQUEUE(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define _IF_PREPEND(ifq, m) do { \
+ (m)->m_nextpkt = (ifq)->ifq_head; \
+ if ((ifq)->ifq_tail == NULL) \
+ (ifq)->ifq_tail = (m); \
+ (ifq)->ifq_head = (m); \
+ (ifq)->ifq_len++; \
+} while (0)
+
+#define IF_PREPEND(ifq, m) do { \
+ IF_LOCK(ifq); \
+ _IF_PREPEND(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define _IF_DEQUEUE(ifq, m) do { \
+ (m) = (ifq)->ifq_head; \
+ if (m) { \
+ if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \
+ (ifq)->ifq_tail = NULL; \
+ (m)->m_nextpkt = NULL; \
+ (ifq)->ifq_len--; \
+ } \
+} while (0)
+
+#define IF_DEQUEUE(ifq, m) do { \
+ IF_LOCK(ifq); \
+ _IF_DEQUEUE(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define _IF_DEQUEUE_ALL(ifq, m) do { \
+ (m) = (ifq)->ifq_head; \
+ (ifq)->ifq_head = (ifq)->ifq_tail = NULL; \
+ (ifq)->ifq_len = 0; \
+} while (0)
+
+#define IF_DEQUEUE_ALL(ifq, m) do { \
+ IF_LOCK(ifq); \
+ _IF_DEQUEUE_ALL(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define _IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
+#define IF_POLL(ifq, m) _IF_POLL(ifq, m)
+
+#define _IF_DRAIN(ifq) do { \
+ struct mbuf *m; \
+ for (;;) { \
+ _IF_DEQUEUE(ifq, m); \
+ if (m == NULL) \
+ break; \
+ m_freem(m); \
+ } \
+} while (0)
+
+#define IF_DRAIN(ifq) do { \
+ IF_LOCK(ifq); \
+ _IF_DRAIN(ifq); \
+ IF_UNLOCK(ifq); \
+} while(0)
+
+int if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp,
+ int adjust);
+#define IF_HANDOFF(ifq, m, ifp) \
+ if_handoff((struct ifqueue *)ifq, m, ifp, 0)
+#define IF_HANDOFF_ADJ(ifq, m, ifp, adj) \
+ if_handoff((struct ifqueue *)ifq, m, ifp, adj)
+
+void if_start(struct ifnet *);
+
+#define IFQ_ENQUEUE(ifq, m, err) \
+do { \
+ IF_LOCK(ifq); \
+ if (ALTQ_IS_ENABLED(ifq)) \
+ ALTQ_ENQUEUE(ifq, m, NULL, err); \
+ else { \
+ if (_IF_QFULL(ifq)) { \
+ m_freem(m); \
+ (err) = ENOBUFS; \
+ } else { \
+ _IF_ENQUEUE(ifq, m); \
+ (err) = 0; \
+ } \
+ } \
+ if (err) \
+ (ifq)->ifq_drops++; \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define IFQ_DEQUEUE_NOLOCK(ifq, m) \
+do { \
+ if (TBR_IS_ENABLED(ifq)) \
+ (m) = tbr_dequeue_ptr(ifq, ALTDQ_REMOVE); \
+ else if (ALTQ_IS_ENABLED(ifq)) \
+ ALTQ_DEQUEUE(ifq, m); \
+ else \
+ _IF_DEQUEUE(ifq, m); \
+} while (0)
+
+#define IFQ_DEQUEUE(ifq, m) \
+do { \
+ IF_LOCK(ifq); \
+ IFQ_DEQUEUE_NOLOCK(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define IFQ_POLL_NOLOCK(ifq, m) \
+do { \
+ if (TBR_IS_ENABLED(ifq)) \
+ (m) = tbr_dequeue_ptr(ifq, ALTDQ_POLL); \
+ else if (ALTQ_IS_ENABLED(ifq)) \
+ ALTQ_POLL(ifq, m); \
+ else \
+ _IF_POLL(ifq, m); \
+} while (0)
+
+#define IFQ_POLL(ifq, m) \
+do { \
+ IF_LOCK(ifq); \
+ IFQ_POLL_NOLOCK(ifq, m); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define IFQ_PURGE_NOLOCK(ifq) \
+do { \
+ if (ALTQ_IS_ENABLED(ifq)) { \
+ ALTQ_PURGE(ifq); \
+ } else \
+ _IF_DRAIN(ifq); \
+} while (0)
+
+#define IFQ_PURGE(ifq) \
+do { \
+ IF_LOCK(ifq); \
+ IFQ_PURGE_NOLOCK(ifq); \
+ IF_UNLOCK(ifq); \
+} while (0)
+
+#define IFQ_SET_READY(ifq) \
+ do { ((ifq)->altq_flags |= ALTQF_READY); } while (0)
+
+#define IFQ_LOCK(ifq) IF_LOCK(ifq)
+#define IFQ_UNLOCK(ifq) IF_UNLOCK(ifq)
+#define IFQ_LOCK_ASSERT(ifq) IF_LOCK_ASSERT(ifq)
+#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
+#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
+#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
+#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
+#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
+
+/*
+ * The IFF_DRV_OACTIVE test should really occur in the device driver, not in
+ * the handoff logic, as that flag is locked by the device driver.
+ */
+#define IFQ_HANDOFF_ADJ(ifp, m, adj, err) \
+do { \
+ int len; \
+ short mflags; \
+ \
+ len = (m)->m_pkthdr.len; \
+ mflags = (m)->m_flags; \
+ IFQ_ENQUEUE(&(ifp)->if_snd, m, err); \
+ if ((err) == 0) { \
+ (ifp)->if_obytes += len + (adj); \
+ if (mflags & M_MCAST) \
+ (ifp)->if_omcasts++; \
+ if (((ifp)->if_drv_flags & IFF_DRV_OACTIVE) == 0) \
+ if_start(ifp); \
+ } \
+} while (0)
+
+#define IFQ_HANDOFF(ifp, m, err) \
+ IFQ_HANDOFF_ADJ(ifp, m, 0, err)
+
+#define IFQ_DRV_DEQUEUE(ifq, m) \
+do { \
+ (m) = (ifq)->ifq_drv_head; \
+ if (m) { \
+ if (((ifq)->ifq_drv_head = (m)->m_nextpkt) == NULL) \
+ (ifq)->ifq_drv_tail = NULL; \
+ (m)->m_nextpkt = NULL; \
+ (ifq)->ifq_drv_len--; \
+ } else { \
+ IFQ_LOCK(ifq); \
+ IFQ_DEQUEUE_NOLOCK(ifq, m); \
+ while ((ifq)->ifq_drv_len < (ifq)->ifq_drv_maxlen) { \
+ struct mbuf *m0; \
+ IFQ_DEQUEUE_NOLOCK(ifq, m0); \
+ if (m0 == NULL) \
+ break; \
+ m0->m_nextpkt = NULL; \
+ if ((ifq)->ifq_drv_tail == NULL) \
+ (ifq)->ifq_drv_head = m0; \
+ else \
+ (ifq)->ifq_drv_tail->m_nextpkt = m0; \
+ (ifq)->ifq_drv_tail = m0; \
+ (ifq)->ifq_drv_len++; \
+ } \
+ IFQ_UNLOCK(ifq); \
+ } \
+} while (0)
+
+#define IFQ_DRV_PREPEND(ifq, m) \
+do { \
+ (m)->m_nextpkt = (ifq)->ifq_drv_head; \
+ if ((ifq)->ifq_drv_tail == NULL) \
+ (ifq)->ifq_drv_tail = (m); \
+ (ifq)->ifq_drv_head = (m); \
+ (ifq)->ifq_drv_len++; \
+} while (0)
+
+#define IFQ_DRV_IS_EMPTY(ifq) \
+ (((ifq)->ifq_drv_len == 0) && ((ifq)->ifq_len == 0))
+
+#define IFQ_DRV_PURGE(ifq) \
+do { \
+ struct mbuf *m, *n = (ifq)->ifq_drv_head; \
+ while((m = n) != NULL) { \
+ n = m->m_nextpkt; \
+ m_freem(m); \
+ } \
+ (ifq)->ifq_drv_head = (ifq)->ifq_drv_tail = NULL; \
+ (ifq)->ifq_drv_len = 0; \
+ IFQ_PURGE(ifq); \
+} while (0)
+
+static __inline int
+drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
+{
+ int error = 0;
+
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
+ IFQ_ENQUEUE(&ifp->if_snd, m, error);
+ return (error);
+ }
+#endif
+ error = buf_ring_enqueue(br, m);
+ if (error)
+ m_freem(m);
+
+ return (error);
+}
+
+static __inline void
+drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new)
+{
+ /*
+ * The top of the list needs to be swapped
+ * for this one.
+ */
+#ifdef ALTQ
+ if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
+ /*
+ * Peek in altq case dequeued it
+ * so put it back.
+ */
+ IFQ_DRV_PREPEND(&ifp->if_snd, new);
+ return;
+ }
+#endif
+ buf_ring_putback_sc(br, new);
+}
+
+static __inline struct mbuf *
+drbr_peek(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ struct mbuf *m;
+ if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
+ /*
+ * Pull it off like a dequeue
+ * since drbr_advance() does nothing
+ * for altq and drbr_putback() will
+ * use the old prepend function.
+ */
+ IFQ_DEQUEUE(&ifp->if_snd, m);
+ return (m);
+ }
+#endif
+ return(buf_ring_peek(br));
+}
+
+static __inline void
+drbr_flush(struct ifnet *ifp, struct buf_ring *br)
+{
+ struct mbuf *m;
+
+#ifdef ALTQ
+ if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
+ IFQ_PURGE(&ifp->if_snd);
+#endif
+ while ((m = buf_ring_dequeue_sc(br)) != NULL)
+ m_freem(m);
+}
+
+static __inline void
+drbr_free(struct buf_ring *br, struct malloc_type *type)
+{
+
+ drbr_flush(NULL, br);
+ buf_ring_free(br, type);
+}
+
+static __inline struct mbuf *
+drbr_dequeue(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ struct mbuf *m;
+
+ if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
+ IFQ_DEQUEUE(&ifp->if_snd, m);
+ return (m);
+ }
+#endif
+ return (buf_ring_dequeue_sc(br));
+}
+
+static __inline void
+drbr_advance(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ /* Nothing to do here since peek dequeues in altq case */
+ if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
+ return;
+#endif
+ return (buf_ring_advance_sc(br));
+}
+
+
+static __inline struct mbuf *
+drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring *br,
+ int (*func) (struct mbuf *, void *), void *arg)
+{
+ struct mbuf *m;
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
+ IFQ_LOCK(&ifp->if_snd);
+ IFQ_POLL_NOLOCK(&ifp->if_snd, m);
+ if (m != NULL && func(m, arg) == 0) {
+ IFQ_UNLOCK(&ifp->if_snd);
+ return (NULL);
+ }
+ IFQ_DEQUEUE_NOLOCK(&ifp->if_snd, m);
+ IFQ_UNLOCK(&ifp->if_snd);
+ return (m);
+ }
+#endif
+ m = buf_ring_peek(br);
+ if (m == NULL || func(m, arg) == 0)
+ return (NULL);
+
+ return (buf_ring_dequeue_sc(br));
+}
+
+static __inline int
+drbr_empty(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd))
+ return (IFQ_IS_EMPTY(&ifp->if_snd));
+#endif
+ return (buf_ring_empty(br));
+}
+
+static __inline int
+drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd))
+ return (1);
+#endif
+ return (!buf_ring_empty(br));
+}
+
+static __inline int
+drbr_inuse(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd))
+ return (ifp->if_snd.ifq_len);
+#endif
+ return (buf_ring_count(br));
+}
+
+extern int ifqmaxlen;
+
+void if_qflush(struct ifnet *);
+void ifq_init(struct ifaltq *, struct ifnet *ifp);
+void ifq_delete(struct ifaltq *);
+
+#ifdef DEVICE_POLLING
+enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS };
+
+typedef int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count);
+int ether_poll_register(poll_handler_t *h, struct ifnet *ifp);
+int ether_poll_deregister(struct ifnet *ifp);
+#endif /* DEVICE_POLLING */
+
+#endif /* _KERNEL */
+#endif /* !_NET_IFQ_H_ */
diff --git a/sys/net/pf_mtag.h b/sys/net/pf_mtag.h
deleted file mode 100644
index baff00a699b9..000000000000
--- a/sys/net/pf_mtag.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* $FreeBSD$ */
-/*
- * Copyright (c) 2001 Daniel Hartmeier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef _NET_PF_MTAG_H_
-#define _NET_PF_MTAG_H_
-
-#ifdef _KERNEL
-
-#define PF_TAG_GENERATED 0x01
-#define PF_TAG_FRAGCACHE 0x02
-#define PF_TAG_TRANSLATE_LOCALHOST 0x04
-#define PF_PACKET_LOOPED 0x08
-#define PF_FASTFWD_OURS_PRESENT 0x10
-
-struct pf_mtag {
- void *hdr; /* saved hdr pos in mbuf, for ECN */
- u_int32_t qid; /* queue id */
- u_int16_t tag; /* tag id */
- u_int8_t flags;
- u_int8_t routed;
-};
-
-static __inline struct pf_mtag *
-pf_find_mtag(struct mbuf *m)
-{
- struct m_tag *mtag;
-
- if ((mtag = m_tag_find(m, PACKET_TAG_PF, NULL)) == NULL)
- return (NULL);
-
- return ((struct pf_mtag *)(mtag + 1));
-}
-#endif /* _KERNEL */
-#endif /* _NET_PF_MTAG_H_ */
diff --git a/sys/net/pfil.c b/sys/net/pfil.c
index 44373ee14bf5..2494deae2052 100644
--- a/sys/net/pfil.c
+++ b/sys/net/pfil.c
@@ -45,6 +45,7 @@
#include <sys/queue.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/pfil.h>
static struct mtx pfil_global_lock;
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 26f569a47d24..79840ac0b920 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -41,83 +41,9 @@
#include <net/radix.h>
#include <netinet/in.h>
-#include <net/pf_mtag.h>
-
-#define PF_TCPS_PROXY_SRC ((TCP_NSTATES)+0)
-#define PF_TCPS_PROXY_DST ((TCP_NSTATES)+1)
-
-#define PF_MD5_DIGEST_LENGTH 16
-#ifdef MD5_DIGEST_LENGTH
-#if PF_MD5_DIGEST_LENGTH != MD5_DIGEST_LENGTH
-#error
-#endif
-#endif
-
-enum { PF_INOUT, PF_IN, PF_OUT };
-enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT,
- PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, PF_DEFER };
-enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT,
- PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_MAX };
-enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT,
- PF_OP_LE, PF_OP_GT, PF_OP_GE, PF_OP_XRG, PF_OP_RRG };
-enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC, PF_DEBUG_NOISY };
-enum { PF_CHANGE_NONE, PF_CHANGE_ADD_HEAD, PF_CHANGE_ADD_TAIL,
- PF_CHANGE_ADD_BEFORE, PF_CHANGE_ADD_AFTER,
- PF_CHANGE_REMOVE, PF_CHANGE_GET_TICKET };
-enum { PF_GET_NONE, PF_GET_CLR_CNTR };
-enum { PF_SK_WIRE, PF_SK_STACK, PF_SK_BOTH };
-
-/*
- * Note about PFTM_*: real indices into pf_rule.timeout[] come before
- * PFTM_MAX, special cases afterwards. See pf_state_expires().
- */
-enum { PFTM_TCP_FIRST_PACKET, PFTM_TCP_OPENING, PFTM_TCP_ESTABLISHED,
- PFTM_TCP_CLOSING, PFTM_TCP_FIN_WAIT, PFTM_TCP_CLOSED,
- PFTM_UDP_FIRST_PACKET, PFTM_UDP_SINGLE, PFTM_UDP_MULTIPLE,
- PFTM_ICMP_FIRST_PACKET, PFTM_ICMP_ERROR_REPLY,
- PFTM_OTHER_FIRST_PACKET, PFTM_OTHER_SINGLE,
- PFTM_OTHER_MULTIPLE, PFTM_FRAG, PFTM_INTERVAL,
- PFTM_ADAPTIVE_START, PFTM_ADAPTIVE_END, PFTM_SRC_NODE,
- PFTM_TS_DIFF, PFTM_MAX, PFTM_PURGE, PFTM_UNLINKED,
- PFTM_UNTIL_PACKET };
-
-/* PFTM default values */
-#define PFTM_TCP_FIRST_PACKET_VAL 120 /* First TCP packet */
-#define PFTM_TCP_OPENING_VAL 30 /* No response yet */
-#define PFTM_TCP_ESTABLISHED_VAL 24*60*60/* Established */
-#define PFTM_TCP_CLOSING_VAL 15 * 60 /* Half closed */
-#define PFTM_TCP_FIN_WAIT_VAL 45 /* Got both FINs */
-#define PFTM_TCP_CLOSED_VAL 90 /* Got a RST */
-#define PFTM_UDP_FIRST_PACKET_VAL 60 /* First UDP packet */
-#define PFTM_UDP_SINGLE_VAL 30 /* Unidirectional */
-#define PFTM_UDP_MULTIPLE_VAL 60 /* Bidirectional */
-#define PFTM_ICMP_FIRST_PACKET_VAL 20 /* First ICMP packet */
-#define PFTM_ICMP_ERROR_REPLY_VAL 10 /* Got error response */
-#define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */
-#define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */
-#define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */
-#define PFTM_FRAG_VAL 30 /* Fragment expire */
-#define PFTM_INTERVAL_VAL 10 /* Expire interval */
-#define PFTM_SRC_NODE_VAL 0 /* Source tracking */
-#define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */
-
-enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO };
-enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,
- PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX };
-#define PF_POOL_IDMASK 0x0f
-enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM,
- PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN };
-enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
- PF_ADDR_TABLE, PF_ADDR_URPFFAILED,
- PF_ADDR_RANGE };
-#define PF_POOL_TYPEMASK 0x0f
-#define PF_POOL_STICKYADDR 0x20
-#define PF_WSCALE_FLAG 0x80
-#define PF_WSCALE_MASK 0x0f
-
-#define PF_LOG 0x01
-#define PF_LOG_ALL 0x02
-#define PF_LOG_SOCKET_LOOKUP 0x04
+#include <netpfil/pf/pf.h>
+#include <netpfil/pf/pf_altq.h>
+#include <netpfil/pf/pf_mtag.h>
struct pf_addr {
union {
@@ -134,8 +60,6 @@ struct pf_addr {
#define addr32 pfa.addr32
};
-#define PF_TABLE_NAME_SIZE 32
-
#define PFI_AFLAG_NETWORK 0x01
#define PFI_AFLAG_BROADCAST 0x02
#define PFI_AFLAG_PEER 0x04
@@ -564,7 +488,6 @@ struct pf_rule {
union pf_rule_ptr skip[PF_SKIP_COUNT];
#define PF_RULE_LABEL_SIZE 64
char label[PF_RULE_LABEL_SIZE];
-#define PF_QNAME_SIZE 64
char ifname[IFNAMSIZ];
char qname[PF_QNAME_SIZE];
char pqname[PF_QNAME_SIZE];
@@ -1195,43 +1118,6 @@ struct pf_pdesc {
#define PF_DPORT_RANGE 0x01 /* Dest port uses range */
#define PF_RPORT_RANGE 0x02 /* RDR'ed port uses range */
-/* Reasons code for passing/dropping a packet */
-#define PFRES_MATCH 0 /* Explicit match of a rule */
-#define PFRES_BADOFF 1 /* Bad offset for pull_hdr */
-#define PFRES_FRAG 2 /* Dropping following fragment */
-#define PFRES_SHORT 3 /* Dropping short packet */
-#define PFRES_NORM 4 /* Dropping by normalizer */
-#define PFRES_MEMORY 5 /* Dropped due to lacking mem */
-#define PFRES_TS 6 /* Bad TCP Timestamp (RFC1323) */
-#define PFRES_CONGEST 7 /* Congestion (of ipintrq) */
-#define PFRES_IPOPTIONS 8 /* IP option */
-#define PFRES_PROTCKSUM 9 /* Protocol checksum invalid */
-#define PFRES_BADSTATE 10 /* State mismatch */
-#define PFRES_STATEINS 11 /* State insertion failure */
-#define PFRES_MAXSTATES 12 /* State limit */
-#define PFRES_SRCLIMIT 13 /* Source node/conn limit */
-#define PFRES_SYNPROXY 14 /* SYN proxy */
-#define PFRES_MAX 15 /* total+1 */
-
-#define PFRES_NAMES { \
- "match", \
- "bad-offset", \
- "fragment", \
- "short", \
- "normalize", \
- "memory", \
- "bad-timestamp", \
- "congestion", \
- "ip-option", \
- "proto-cksum", \
- "state-mismatch", \
- "state-insert", \
- "state-limit", \
- "src-limit", \
- "synproxy", \
- NULL \
-}
-
/* Counters for other things we want to keep track of */
#define LCNT_STATES 0 /* states */
#define LCNT_SRCSTATES 1 /* max-src-states */
@@ -1322,69 +1208,6 @@ struct pf_status {
u_int8_t pf_chksum[PF_MD5_DIGEST_LENGTH];
};
-struct cbq_opts {
- u_int minburst;
- u_int maxburst;
- u_int pktsize;
- u_int maxpktsize;
- u_int ns_per_byte;
- u_int maxidle;
- int minidle;
- u_int offtime;
- int flags;
-};
-
-struct priq_opts {
- int flags;
-};
-
-struct hfsc_opts {
- /* real-time service curve */
- u_int rtsc_m1; /* slope of the 1st segment in bps */
- u_int rtsc_d; /* the x-projection of m1 in msec */
- u_int rtsc_m2; /* slope of the 2nd segment in bps */
- /* link-sharing service curve */
- u_int lssc_m1;
- u_int lssc_d;
- u_int lssc_m2;
- /* upper-limit service curve */
- u_int ulsc_m1;
- u_int ulsc_d;
- u_int ulsc_m2;
- int flags;
-};
-
-struct pf_altq {
- char ifname[IFNAMSIZ];
-
- void *altq_disc; /* discipline-specific state */
- TAILQ_ENTRY(pf_altq) entries;
-
- /* scheduler spec */
- u_int8_t scheduler; /* scheduler type */
- u_int16_t tbrsize; /* tokenbucket regulator size */
- u_int32_t ifbandwidth; /* interface bandwidth */
-
- /* queue spec */
- char qname[PF_QNAME_SIZE]; /* queue name */
- char parent[PF_QNAME_SIZE]; /* parent name */
- u_int32_t parent_qid; /* parent queue id */
- u_int32_t bandwidth; /* queue bandwidth */
- u_int8_t priority; /* priority */
- u_int8_t local_flags; /* dynamic interface */
-#define PFALTQ_FLAG_IF_REMOVED 0x01
-
- u_int16_t qlimit; /* queue size limit */
- u_int16_t flags; /* misc flags */
- union {
- struct cbq_opts cbq_opts;
- struct priq_opts priq_opts;
- struct hfsc_opts hfsc_opts;
- } pq_u;
-
- u_int32_t qid; /* return value */
-};
-
struct pf_divert {
union {
struct in_addr ipv4;
diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c
index c90f537c8d6f..477a65db26e7 100644
--- a/sys/net/raw_cb.c
+++ b/sys/net/raw_cb.c
@@ -44,8 +44,8 @@
#include <sys/systm.h>
#include <net/if.h>
-#include <net/raw_cb.h>
#include <net/vnet.h>
+#include <net/raw_cb.h>
/*
* Routines to manage the raw protocol control blocks.
diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c
index df77063863fc..87bcd895a477 100644
--- a/sys/net/raw_usrreq.c
+++ b/sys/net/raw_usrreq.c
@@ -46,8 +46,8 @@
#include <sys/systm.h>
#include <net/if.h>
-#include <net/raw_cb.h>
#include <net/vnet.h>
+#include <net/raw_cb.h>
MTX_SYSINIT(rawcb_mtx, &rawcb_mtx, "rawcb", MTX_DEF);
diff --git a/sys/net/route.c b/sys/net/route.c
index 55efd944b38f..a64c669fda6f 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -54,6 +54,7 @@
#include <sys/kernel.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <net/vnet.h>
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index e92eb8937027..e7d1d99a59ca 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -53,6 +53,7 @@
#include <sys/systm.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_llatbl.h>
#include <net/if_types.h>