提交 576eb625 编写于 作者: S stephen hemminger 提交者: David S. Miller

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: NStephen Hemminger <shemminger@vyatta.com>
Reviewed-by: NFlavio Leitner <fbl@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 aa1113d9
...@@ -66,14 +66,14 @@ void br_port_carrier_check(struct net_bridge_port *p) ...@@ -66,14 +66,14 @@ void br_port_carrier_check(struct net_bridge_port *p)
struct net_device *dev = p->dev; struct net_device *dev = p->dev;
struct net_bridge *br = p->br; struct net_bridge *br = p->br;
if (netif_running(dev) && netif_carrier_ok(dev)) if (netif_running(dev) && netif_oper_up(dev))
p->path_cost = port_cost(dev); p->path_cost = port_cost(dev);
if (!netif_running(br->dev)) if (!netif_running(br->dev))
return; return;
spin_lock_bh(&br->lock); spin_lock_bh(&br->lock);
if (netif_running(dev) && netif_carrier_ok(dev)) { if (netif_running(dev) && netif_oper_up(dev)) {
if (p->state == BR_STATE_DISABLED) if (p->state == BR_STATE_DISABLED)
br_stp_enable_port(p); br_stp_enable_port(p);
} else { } else {
...@@ -383,7 +383,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) ...@@ -383,7 +383,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
spin_lock_bh(&br->lock); spin_lock_bh(&br->lock);
changed_addr = br_stp_recalculate_bridge_id(br); changed_addr = br_stp_recalculate_bridge_id(br);
if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) && if (netif_running(dev) && netif_oper_up(dev) &&
(br->dev->flags & IFF_UP)) (br->dev->flags & IFF_UP))
br_stp_enable_port(p); br_stp_enable_port(p);
spin_unlock_bh(&br->lock); spin_unlock_bh(&br->lock);
......
...@@ -181,8 +181,11 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) ...@@ -181,8 +181,11 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state)
if (p->br->stp_enabled == BR_KERNEL_STP) if (p->br->stp_enabled == BR_KERNEL_STP)
return -EBUSY; return -EBUSY;
/* if device is not up, change is not allowed
* if link is not present, only allowable state is disabled
*/
if (!netif_running(p->dev) || if (!netif_running(p->dev) ||
(!netif_carrier_ok(p->dev) && state != BR_STATE_DISABLED)) (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED))
return -ENETDOWN; return -ENETDOWN;
p->state = state; p->state = state;
......
...@@ -82,7 +82,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v ...@@ -82,7 +82,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
break; break;
case NETDEV_UP: case NETDEV_UP:
if (netif_carrier_ok(dev) && (br->dev->flags & IFF_UP)) { if (netif_running(br->dev) && netif_oper_up(dev)) {
spin_lock_bh(&br->lock); spin_lock_bh(&br->lock);
br_stp_enable_port(p); br_stp_enable_port(p);
spin_unlock_bh(&br->lock); spin_unlock_bh(&br->lock);
......
...@@ -54,7 +54,7 @@ void br_stp_enable_bridge(struct net_bridge *br) ...@@ -54,7 +54,7 @@ void br_stp_enable_bridge(struct net_bridge *br)
br_config_bpdu_generation(br); br_config_bpdu_generation(br);
list_for_each_entry(p, &br->port_list, list) { list_for_each_entry(p, &br->port_list, list) {
if ((p->dev->flags & IFF_UP) && netif_carrier_ok(p->dev)) if (netif_running(p->dev) && netif_oper_up(p->dev))
br_stp_enable_port(p); br_stp_enable_port(p);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册