diff options
author | Luiz Otavio O Souza <loos@FreeBSD.org> | 2021-08-25 09:07:44 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2021-08-26 09:23:44 +0000 |
commit | eb680a63de1dbf5c974f483975dcb2c60ec6fa08 (patch) | |
tree | 85f2cddba3c6cd564e8e43cc19a360e5d33bf282 /sys/net/if_bridge.c | |
parent | cd46399b9ccf04f6ec00a532e52c8b1edb007af7 (diff) | |
download | src-eb680a63de1dbf5c974f483975dcb2c60ec6fa08.tar.gz src-eb680a63de1dbf5c974f483975dcb2c60ec6fa08.zip |
if_bridge: add ALTQ support
Similar to the recent addition of ALTQ support to if_vlan.
Reviewed by: donner
Obtained from: pfsense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31675
Diffstat (limited to 'sys/net/if_bridge.c')
-rw-r--r-- | sys/net/if_bridge.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index adf1c9155ee1..703a76086c55 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -298,6 +298,10 @@ static void bridge_init(void *); static void bridge_dummynet(struct mbuf *, struct ifnet *); static void bridge_stop(struct ifnet *, int); static int bridge_transmit(struct ifnet *, struct mbuf *); +#ifdef ALTQ +static void bridge_altq_start(if_t); +static int bridge_altq_transmit(if_t, struct mbuf *); +#endif static void bridge_qflush(struct ifnet *); static struct mbuf *bridge_input(struct ifnet *, struct mbuf *); static int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, @@ -726,7 +730,15 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params) if_initname(ifp, bridge_name, unit); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bridge_ioctl; +#ifdef ALTQ + ifp->if_start = bridge_altq_start; + ifp->if_transmit = bridge_altq_transmit; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); +#else ifp->if_transmit = bridge_transmit; +#endif ifp->if_qflush = bridge_qflush; ifp->if_init = bridge_init; ifp->if_type = IFT_BRIDGE; @@ -798,6 +810,9 @@ bridge_clone_destroy(struct ifnet *ifp) BRIDGE_LIST_UNLOCK(); bstp_detach(&sc->sc_stp); +#ifdef ALTQ + IFQ_PURGE(&ifp->if_snd); +#endif NET_EPOCH_EXIT(et); ether_ifdetach(ifp); @@ -2219,6 +2234,38 @@ bridge_transmit(struct ifnet *ifp, struct mbuf *m) return (error); } +#ifdef ALTQ +static void +bridge_altq_start(if_t ifp) +{ + struct ifaltq *ifq = &ifp->if_snd; + struct mbuf *m; + + IFQ_LOCK(ifq); + IFQ_DEQUEUE_NOLOCK(ifq, m); + while (m != NULL) { + bridge_transmit(ifp, m); + IFQ_DEQUEUE_NOLOCK(ifq, m); + } + IFQ_UNLOCK(ifq); +} + +static int +bridge_altq_transmit(if_t ifp, struct mbuf *m) +{ + int err; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, err); + if (err == 0) + bridge_altq_start(ifp); + } else + err = bridge_transmit(ifp, m); + + return (err); +} +#endif /* ALTQ */ + /* * The ifp->if_qflush entry point for if_bridge(4) is no-op. */ |