Commit 576eb62598f10c8c7fd75703fe89010cdcfff596

Authored by stephen hemminger
Committed by David S. Miller
1 parent aa1113d9f8

bridge: respect RFC2863 operational state

The bridge link detection should follow the operational state
of the lower device, rather than the carrier bit. This allows devices
like tunnels that are controlled by userspace control plane to work
with bridge STP link management.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Reviewed-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 9 additions and 6 deletions Side-by-side Diff

... ... @@ -66,14 +66,14 @@
66 66 struct net_device *dev = p->dev;
67 67 struct net_bridge *br = p->br;
68 68  
69   - if (netif_running(dev) && netif_carrier_ok(dev))
  69 + if (netif_running(dev) && netif_oper_up(dev))
70 70 p->path_cost = port_cost(dev);
71 71  
72 72 if (!netif_running(br->dev))
73 73 return;
74 74  
75 75 spin_lock_bh(&br->lock);
76   - if (netif_running(dev) && netif_carrier_ok(dev)) {
  76 + if (netif_running(dev) && netif_oper_up(dev)) {
77 77 if (p->state == BR_STATE_DISABLED)
78 78 br_stp_enable_port(p);
79 79 } else {
... ... @@ -383,7 +383,7 @@
383 383 spin_lock_bh(&br->lock);
384 384 changed_addr = br_stp_recalculate_bridge_id(br);
385 385  
386   - if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
  386 + if (netif_running(dev) && netif_oper_up(dev) &&
387 387 (br->dev->flags & IFF_UP))
388 388 br_stp_enable_port(p);
389 389 spin_unlock_bh(&br->lock);
net/bridge/br_netlink.c
... ... @@ -181,8 +181,11 @@
181 181 if (p->br->stp_enabled == BR_KERNEL_STP)
182 182 return -EBUSY;
183 183  
  184 + /* if device is not up, change is not allowed
  185 + * if link is not present, only allowable state is disabled
  186 + */
184 187 if (!netif_running(p->dev) ||
185   - (!netif_carrier_ok(p->dev) && state != BR_STATE_DISABLED))
  188 + (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED))
186 189 return -ENETDOWN;
187 190  
188 191 p->state = state;
net/bridge/br_notify.c
... ... @@ -82,7 +82,7 @@
82 82 break;
83 83  
84 84 case NETDEV_UP:
85   - if (netif_carrier_ok(dev) && (br->dev->flags & IFF_UP)) {
  85 + if (netif_running(br->dev) && netif_oper_up(dev)) {
86 86 spin_lock_bh(&br->lock);
87 87 br_stp_enable_port(p);
88 88 spin_unlock_bh(&br->lock);
net/bridge/br_stp_if.c
... ... @@ -54,7 +54,7 @@
54 54 br_config_bpdu_generation(br);
55 55  
56 56 list_for_each_entry(p, &br->port_list, list) {
57   - if ((p->dev->flags & IFF_UP) && netif_carrier_ok(p->dev))
  57 + if (netif_running(p->dev) && netif_oper_up(p->dev))
58 58 br_stp_enable_port(p);
59 59  
60 60 }