diff options
-rw-r--r-- | sys/net/bridgestp.c | 1 | ||||
-rw-r--r-- | sys/net/if_bridge.c | 14 | ||||
-rw-r--r-- | sys/net/if_bridgevar.h | 30 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 19 | ||||
-rw-r--r-- | sys/netgraph/ng_ether.c | 21 |
5 files changed, 37 insertions, 48 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 76250f1..1c48842 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/condvar.h> #include <net/if.h> #include <net/if_dl.h> diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 81925d4..641380e 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -102,7 +102,6 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/condvar.h> #include <net/bpf.h> #include <net/if.h> @@ -173,12 +172,6 @@ __FBSDID("$FreeBSD$"); static struct mtx bridge_list_mtx; -extern struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *); -extern int (*bridge_output_p)(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); -extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *); -extern void (*bridge_detach_p)(struct ifnet *); - int bridge_rtable_prune_period = BRIDGE_RTABLE_PRUNE_PERIOD; uma_zone_t bridge_rtnode_zone; @@ -187,9 +180,14 @@ int bridge_clone_create(struct if_clone *, int); void bridge_clone_destroy(struct ifnet *); int bridge_ioctl(struct ifnet *, u_long, caddr_t); +void bridge_ifdetach(struct ifnet *); static void bridge_init(void *); +void bridge_dummynet(struct mbuf *, struct ifnet *); void bridge_stop(struct ifnet *, int); void bridge_start(struct ifnet *); +struct mbuf *bridge_input(struct ifnet *, struct mbuf *); +int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); void bridge_forward(struct bridge_softc *, struct mbuf *m); @@ -1887,7 +1885,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, if (m == NULL) return; } - + bridge_enqueue(sc, dst_if, mc); } if (used == 0) diff --git a/sys/net/if_bridgevar.h b/sys/net/if_bridgevar.h index 2cd7704..7c6b9c2 100644 --- a/sys/net/if_bridgevar.h +++ b/sys/net/if_bridgevar.h @@ -76,6 +76,7 @@ #include <sys/callout.h> #include <sys/queue.h> +#include <sys/condvar.h> /* * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the @@ -335,23 +336,36 @@ struct bridge_softc { (_sc)->sc_iflist_xcnt--; \ } while (0) +#define BRIDGE_INPUT(_ifp, _m) do { \ + KASSERT(bridge_input_p != NULL, \ + ("%s: if_bridge not loaded!", __func__)); \ + _m = (*bridge_input_p)(_ifp, _m); \ + if (_m != NULL) \ + _ifp = _m->m_pkthdr.rcvif; \ +} while (0) + +#define BRIDGE_OUTPUT(_ifp, _m, _err) do { \ + KASSERT(bridge_output_p != NULL, \ + ("%s: if_bridge not loaded!", __func__)); \ + _err = (*bridge_output_p)(_ifp, _m, NULL, NULL); \ +} while (0) + extern const uint8_t bstp_etheraddr[]; -void bridge_ifdetach(struct ifnet *); +void bridge_enqueue(struct bridge_softc *, struct ifnet *, struct mbuf *); void bridge_rtdelete(struct bridge_softc *, struct ifnet *ifp, int); -int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); -void bridge_dummynet(struct mbuf *, struct ifnet *); -struct mbuf *bridge_input(struct ifnet *, struct mbuf *); - -extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state); +extern struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *); +extern int (*bridge_output_p)(struct ifnet *, struct mbuf *, + struct sockaddr *, struct rtentry *); +extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *); +extern void (*bridge_detach_p)(struct ifnet *); +extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state); void bstp_initialization(struct bridge_softc *); void bstp_linkstate(struct ifnet *, int); void bstp_stop(struct bridge_softc *); struct mbuf *bstp_input(struct ifnet *, struct mbuf *); -void bridge_enqueue(struct bridge_softc *, struct ifnet *, struct mbuf *); #endif /* _KERNEL */ diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 8bce103..9a8c416 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -59,6 +59,7 @@ #include <net/if_types.h> #include <net/bpf.h> #include <net/ethernet.h> +#include <net/if_bridgevar.h> #include <net/if_vlan_var.h> #if defined(INET) || defined(INET6) @@ -105,7 +106,7 @@ void (*ng_ether_detach_p)(struct ifnet *ifp); void (*vlan_input_p)(struct ifnet *, struct mbuf *); -/* if_bridge(4) support. XXX: should go into some include. */ +/* if_bridge(4) support */ struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *); int (*bridge_output_p)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); @@ -288,9 +289,8 @@ ether_output(struct ifnet *ifp, struct mbuf *m, * Bridges require special output handling. */ if (ifp->if_bridge) { - KASSERT(bridge_output_p != NULL, - ("%s: if_bridge not loaded!", __func__)); - return ((*bridge_output_p)(ifp, m, NULL, NULL)); + BRIDGE_OUTPUT(ifp, m, error); + return (error); } /* @@ -585,18 +585,9 @@ ether_input(struct ifnet *ifp, struct mbuf *m) * at the src/sys/netgraph/ng_ether.c:ng_ether_rcv_upper() */ if (ifp->if_bridge) { - KASSERT(bridge_input_p != NULL, - ("%s: if_bridge not loaded!", __func__)); - - m = (*bridge_input_p)(ifp, m); + BRIDGE_INPUT(ifp, m); if (m == NULL) return; - /* - * Bridge has determined that the packet is for us. - * Update our interface pointer -- we may have had - * to "bridge" the packet locally. - */ - ifp = m->m_pkthdr.rcvif; } /* First chunk of an mbuf contains good entropy */ diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index c493092..8937fc8 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -61,6 +61,7 @@ #include <net/if_arp.h> #include <net/if_var.h> #include <net/ethernet.h> +#include <net/if_bridgevar.h> #include <netgraph/ng_message.h> #include <netgraph/netgraph.h> @@ -103,9 +104,6 @@ static void ng_ether_link_state(struct ifnet *ifp, int state); static int ng_ether_rcv_lower(node_p node, struct mbuf *m); static int ng_ether_rcv_upper(node_p node, struct mbuf *m); -/* if_bridge(4) support. XXX: should go into some include. */ -extern struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *); - /* Netgraph node methods */ static ng_constructor_t ng_ether_constructor; static ng_rcvmsg_t ng_ether_rcvmsg; @@ -647,26 +645,15 @@ ng_ether_rcv_upper(node_p node, struct mbuf *m) m->m_pkthdr.rcvif = ifp; - /* - * XXX: This is a copy'and'paste from if_ethersubr.c:ether_input() - */ + /* Pass the packet to the bridge, it may come back to us */ if (ifp->if_bridge) { - KASSERT(bridge_input_p != NULL, - ("%s: if_bridge not loaded!", __func__)); - - m = (*bridge_input_p)(ifp, m); + BRIDGE_INPUT(ifp, m); if (m == NULL) return (0); - /* - * Bridge has determined that the packet is for us. - * Update our interface pointer -- we may have had - * to "bridge" the packet locally. - */ - ifp = m->m_pkthdr.rcvif; } /* Route packet back in */ - ether_demux(priv->ifp, m); + ether_demux(ifp, m); return (0); } |