git: 984c87891bf5 - stable/13 - if_vlan: add the ALTQ support to if_vlan.

Kristof Provost kp at FreeBSD.org
Wed Sep 1 13:28:30 UTC 2021


The branch stable/13 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=984c87891bf5e04fd2400be04e1957f1472b7d3c

commit 984c87891bf5e04fd2400be04e1957f1472b7d3c
Author:     Luiz Otavio O Souza <loos at FreeBSD.org>
AuthorDate: 2021-08-21 09:41:03 +0000
Commit:     Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-09-01 13:27:00 +0000

    if_vlan: add the ALTQ support to if_vlan.
    
    Inspired by the iflib implementation, allow ALTQ to be used with if_vlan
    interfaces.
    
    Reviewed by:    donner
    Obtained from:  pfsense
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31647
    
    (cherry picked from commit 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d)
---
 sys/net/if_vlan.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 2ff584a059e9..3114a3f8b76c 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -305,6 +305,10 @@ static	int vlan_setflag(struct ifnet *ifp, int flag, int status,
 static	int vlan_setflags(struct ifnet *ifp, int status);
 static	int vlan_setmulti(struct ifnet *ifp);
 static	int vlan_transmit(struct ifnet *ifp, struct mbuf *m);
+#ifdef ALTQ
+static void vlan_altq_start(struct ifnet *ifp);
+static	int vlan_altq_transmit(struct ifnet *ifp, struct mbuf *m);
+#endif
 static	int vlan_output(struct ifnet *ifp, struct mbuf *m,
     const struct sockaddr *dst, struct route *ro);
 static	void vlan_unconfig(struct ifnet *ifp);
@@ -1094,7 +1098,15 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
 	ifp->if_dunit = unit;
 
 	ifp->if_init = vlan_init;
+#ifdef ALTQ
+	ifp->if_start = vlan_altq_start;
+	ifp->if_transmit = vlan_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 = vlan_transmit;
+#endif
 	ifp->if_qflush = vlan_qflush;
 	ifp->if_ioctl = vlan_ioctl;
 #if defined(KERN_TLS) || defined(RATELIMIT)
@@ -1147,6 +1159,9 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
 	if (ifp->if_vlantrunk)
 		return (EBUSY);
 
+#ifdef ALTQ
+	IFQ_PURGE(&ifp->if_snd);
+#endif
 	ether_ifdetach(ifp);	/* first, remove it from system-wide lists */
 	vlan_unconfig(ifp);	/* now it can be unconfigured and freed */
 	/*
@@ -1268,6 +1283,38 @@ vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
 	return p->if_output(ifp, m, dst, ro);
 }
 
+#ifdef ALTQ
+static void
+vlan_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) {
+		vlan_transmit(ifp, m);
+		IFQ_DEQUEUE_NOLOCK(ifq, m);
+	}
+	IFQ_UNLOCK(ifq);
+}
+
+static int
+vlan_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)
+			vlan_altq_start(ifp);
+	} else
+		err = vlan_transmit(ifp, m);
+
+	return (err);
+}
+#endif	/* ALTQ */
+
 /*
  * The ifp->if_qflush entry point for vlan(4) is a no-op.
  */


More information about the dev-commits-src-all mailing list