bridge: make user modified path cost sticky
authorstephen hemminger <stephen@networkplumber.org>
Sat, 13 Apr 2013 14:06:07 +0000 (14:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Apr 2013 18:03:44 +0000 (14:03 -0400)
Keep a STP port path cost value if it was set by a user.
Don't replace it with the link-speed based path cost
whenever the link goes down and comes back up.

Reported-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_if.c
net/bridge/br_private.h
net/bridge/br_stp_if.c

index ef1b91431c6bb1e0627119f877eca0d2339a899c..459dab22b3f6009dc027c01e29fe587270291053 100644 (file)
@@ -67,7 +67,8 @@ void br_port_carrier_check(struct net_bridge_port *p)
        struct net_device *dev = p->dev;
        struct net_bridge *br = p->br;
 
-       if (netif_running(dev) && netif_oper_up(dev))
+       if (!(p->flags & BR_ADMIN_COST) &&
+           netif_running(dev) && netif_oper_up(dev))
                p->path_cost = port_cost(dev);
 
        if (!netif_running(br->dev))
index 3cbf5beb3d4be267fbea19a2fd81b7b09d3d6a0c..d2c043a857b6a0fd3bfd208f018179b96c42dacd 100644 (file)
@@ -156,6 +156,7 @@ struct net_bridge_port
 #define BR_BPDU_GUARD           0x00000002
 #define BR_ROOT_BLOCK          0x00000004
 #define BR_MULTICAST_FAST_LEAVE        0x00000008
+#define BR_ADMIN_COST          0x00000010
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
        u32                             multicast_startup_queries_sent;
index 0bdb4ebd362b7818229bb50f13d25f7e1181dcad..d45e760141bb81a34909b98724b2d8f3fc876136 100644 (file)
@@ -288,6 +288,7 @@ int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost)
            path_cost > BR_MAX_PATH_COST)
                return -ERANGE;
 
+       p->flags |= BR_ADMIN_COST;
        p->path_cost = path_cost;
        br_configuration_update(p->br);
        br_port_state_selection(p->br);