rocker: install/remove router MAC for untagged VLAN when joining/leaving bridge
authorScott Feldman <sfeldma@gmail.com>
Mon, 1 Jun 2015 18:39:05 +0000 (11:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jun 2015 00:00:09 +0000 (17:00 -0700)
When the port joins a bridge, the port's internal VLAN ID needs to change
to the bridge's internal VLAN ID.  Likewise, when leaving the bridge, the
internal VLAN ID reverts back the port's original internal VLAN ID.  (The
internal VLAN ID is used by device to internally mark untagged pkts with
some VLAN, which will eventually be removed on egress...think PVID).  When
the internal VLAN ID changes, we need to update the VLAN table entries and
the router MAC entries for IP/IPv6 to reflect the new internal VLAN ID.

This patch makes use of the common rocker_port_vlan_add/del functions to
make sure the tables are updated for the current internal VLAN ID.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/rocker/rocker.c

index 076f3f2..357f55d 100644 (file)
@@ -5153,41 +5153,49 @@ static bool rocker_port_dev_check(const struct net_device *dev)
 static int rocker_port_bridge_join(struct rocker_port *rocker_port,
                                   struct net_device *bridge)
 {
+       u16 untagged_vid = 0;
        int err;
 
-       rocker_port_internal_vlan_id_put(rocker_port,
-                                        rocker_port->dev->ifindex);
-
-       rocker_port->bridge_dev = bridge;
+       /* Port is joining bridge, so the internal VLAN for the
+        * port is going to change to the bridge internal VLAN.
+        * Let's remove untagged VLAN (vid=0) from port and
+        * re-add once internal VLAN has changed.
+        */
 
-       /* Use bridge internal VLAN ID for untagged pkts */
-       err = rocker_port_vlan(rocker_port, SWITCHDEV_TRANS_NONE,
-                              ROCKER_OP_FLAG_REMOVE, 0);
+       err = rocker_port_vlan_del(rocker_port, untagged_vid, 0);
        if (err)
                return err;
+
+       rocker_port_internal_vlan_id_put(rocker_port,
+                                        rocker_port->dev->ifindex);
        rocker_port->internal_vlan_id =
                rocker_port_internal_vlan_id_get(rocker_port, bridge->ifindex);
-       return rocker_port_vlan(rocker_port, SWITCHDEV_TRANS_NONE, 0, 0);
+
+       rocker_port->bridge_dev = bridge;
+
+       return rocker_port_vlan_add(rocker_port, SWITCHDEV_TRANS_NONE,
+                                   untagged_vid, 0);
 }
 
 static int rocker_port_bridge_leave(struct rocker_port *rocker_port)
 {
+       u16 untagged_vid = 0;
        int err;
 
-       rocker_port_internal_vlan_id_put(rocker_port,
-                                        rocker_port->bridge_dev->ifindex);
-
-       rocker_port->bridge_dev = NULL;
-
-       /* Use port internal VLAN ID for untagged pkts */
-       err = rocker_port_vlan(rocker_port, SWITCHDEV_TRANS_NONE,
-                              ROCKER_OP_FLAG_REMOVE, 0);
+       err = rocker_port_vlan_del(rocker_port, untagged_vid, 0);
        if (err)
                return err;
+
+       rocker_port_internal_vlan_id_put(rocker_port,
+                                        rocker_port->bridge_dev->ifindex);
        rocker_port->internal_vlan_id =
                rocker_port_internal_vlan_id_get(rocker_port,
                                                 rocker_port->dev->ifindex);
-       err = rocker_port_vlan(rocker_port, SWITCHDEV_TRANS_NONE, 0, 0);
+
+       rocker_port->bridge_dev = NULL;
+
+       err = rocker_port_vlan_add(rocker_port, SWITCHDEV_TRANS_NONE,
+                                  untagged_vid, 0);
        if (err)
                return err;