ALTQ patch for if_vlan.c

Jon Simola jsimola at gmail.com
Mon Jan 17 09:47:48 PST 2005


(CC's to jsimola at gmail.com, I'm not subscribed to the -net list)
I whipped up this against
5.3-STABLE #1: Wed Dec 22 17:11:02 PST 2004

I've had this patch in operation for a week on my router that serves
500 DSL customers and I've had no problems with it.

On the -stable list it was mentioned that the vlan pseudo-device
probably isn't the best place to be doing this, however I haven't been
able to figure out any other way to perform traffic shaping on vlan
interfaces.

--- sys/net/if_vlan.c.orig      Wed Jan  5 12:25:19 2005
+++ sys/net/if_vlan.c   Wed Jan  5 12:53:45 2005
@@ -379,7 +379,10 @@
        ifp->if_init = vlan_ifinit;
        ifp->if_start = vlan_start;
        ifp->if_ioctl = vlan_ioctl;
-       ifp->if_snd.ifq_maxlen = ifqmaxlen;
+       IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
+       ifp->if_snd.ifq_drv_maxlen = 0;
+       IFQ_SET_READY(&ifp->if_snd);
+
        ether_ifattach(ifp, ifv->ifv_ac.ac_enaddr);
        /* Now undo some of the damage... */
        ifp->if_baudrate = 0;
@@ -423,11 +426,15 @@
 {
        int unit;
        struct ifvlan *ifv = ifp->if_softc;
+       int s;

        unit = ifp->if_dunit;

        VLAN_LOCK();
        LIST_REMOVE(ifv, ifv_list);
+       s = splimp();
+       IFQ_PURGE(&ifp->if_snd);
+       splx(s);
        vlan_unconfig(ifp);
        VLAN_UNLOCK();

@@ -458,12 +465,22 @@
        struct mbuf *m;
        int error;

+       if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
+               IFQ_LOCK(&ifp->if_snd);
+               IFQ_POLL_NOLOCK(&ifp->if_snd, m);
+               if (m == NULL ) {
+                       IFQ_UNLOCK(&ifp->if_snd);
+                       return;
+               }
+               IFQ_UNLOCK(&ifp->if_snd);
+       }
+
        ifv = ifp->if_softc;
        p = ifv->ifv_p;

        ifp->if_flags |= IFF_OACTIVE;
        for (;;) {
-               IF_DEQUEUE(&ifp->if_snd, m);
+               IFQ_DEQUEUE(&ifp->if_snd, m);
                if (m == 0)
                        break;
                BPF_MTAP(ifp, m);


-- 
Jon Simola


More information about the freebsd-net mailing list