netdev
[Top] [All Lists]

[PATCH 2.6] (2/3) vlan propogate carrier and hotplug state

To: Ben Greear <greearb@xxxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxx>
Subject: [PATCH 2.6] (2/3) vlan propogate carrier and hotplug state
From: Stephen Hemminger <shemminger@xxxxxxxx>
Date: Tue, 3 Aug 2004 13:40:14 -0700
Cc: netdev@xxxxxxxxxxx
In-reply-to: <410FD348.9040301@xxxxxxxxxxxxxxx>
Organization: Open Source Development Lab
References: <20040803105017.0774e1db@xxxxxxxxxxxxxxxxxxxxx> <410FD348.9040301@xxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
The bridge STP code now wants to handle device's getting connected/disconnected
and this includes vlan devices.  This patch makes the VLAN pseudo device state
mirror the state of the real device.  Only bothered with carrier and hotplug.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxx>

diff -Nru a/net/8021q/vlan.c b/net/8021q/vlan.c
--- a/net/8021q/vlan.c  2004-08-03 13:35:48 -07:00
+++ b/net/8021q/vlan.c  2004-08-03 13:35:48 -07:00
@@ -69,6 +69,10 @@
        .func = vlan_skb_recv, /* VLAN receive method */
 };
 
+/* Bits of netdev state that are propogated from real device to virtual */
+#define VLAN_LINK_STATE_MASK \
+       ((1<<__LINK_STATE_PRESENT)|(1<<__LINK_STATE_NOCARRIER))
+
 /* End of global variables definitions. */
 
 /*
@@ -472,6 +476,8 @@
        new_dev->flags = real_dev->flags;
        new_dev->flags &= ~IFF_UP;
 
+       new_dev->state = real_dev->state & VLAN_LINK_STATE_MASK;
+
        /* need 4 bytes for extra VLAN header info,
         * hope the underlying device can handle it.
         */
@@ -598,9 +604,20 @@
         */
 
        switch (event) {
-       case NETDEV_CHANGEADDR:
-       case NETDEV_GOING_DOWN:
-               /* Ignore for now */
+       case NETDEV_CHANGE:
+               /* Propogate real device state to vlan devices */
+               flgs = dev->state & VLAN_LINK_STATE_MASK;
+               for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+                       vlandev = grp->vlan_devices[i];
+                       if (!vlandev)
+                               continue;
+
+                       if ((vlandev->state & VLAN_LINK_STATE_MASK) != flgs) {
+                               vlandev->state = (vlandev->state &~ 
VLAN_LINK_STATE_MASK) 
+                                       | flgs;
+                               netdev_state_change(vlandev);
+                       }
+               }
                break;
 
        case NETDEV_DOWN:

<Prev in Thread] Current Thread [Next in Thread>