Skip to content

Commit

Permalink
bridge: control carrier based on ports online
Browse files Browse the repository at this point in the history
This makes the bridge device behave like a physical device.
In earlier releases the bridge always asserted carrier. This
changes the behavior so that bridge device carrier is on only
if one or more ports are in the forwarding state. This
should help IPv6 autoconfiguration, DHCP, and routing daemons.

I did brief testing with Network and Virt manager and they
seem fine, but since this changes behavior of bridge, it should
wait until net-next (2.6.39).

Signed-off-by: Stephen Hemminger <[email protected]>
Reviewed-by: Nicolas de Pesloüan <[email protected]>
Tested-By: Adam Majer <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
stephen hemminger authored and davem330 committed Mar 14, 2011
1 parent 9425276 commit 1faa435
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
4 changes: 4 additions & 0 deletions net/bridge/br_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static int br_dev_open(struct net_device *dev)
{
struct net_bridge *br = netdev_priv(dev);

netif_carrier_off(dev);

br_features_recompute(br);
netif_start_queue(dev);
br_stp_enable_bridge(br);
Expand All @@ -94,6 +96,8 @@ static int br_dev_stop(struct net_device *dev)
{
struct net_bridge *br = netdev_priv(dev);

netif_carrier_off(dev);

br_stp_disable_bridge(br);
br_multicast_stop(br);

Expand Down
35 changes: 22 additions & 13 deletions net/bridge/br_stp.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,28 +397,37 @@ static void br_make_forwarding(struct net_bridge_port *p)
void br_port_state_selection(struct net_bridge *br)
{
struct net_bridge_port *p;
unsigned int liveports = 0;

/* Don't change port states if userspace is handling STP */
if (br->stp_enabled == BR_USER_STP)
return;

list_for_each_entry(p, &br->port_list, list) {
if (p->state != BR_STATE_DISABLED) {
if (p->port_no == br->root_port) {
p->config_pending = 0;
p->topology_change_ack = 0;
br_make_forwarding(p);
} else if (br_is_designated_port(p)) {
del_timer(&p->message_age_timer);
br_make_forwarding(p);
} else {
p->config_pending = 0;
p->topology_change_ack = 0;
br_make_blocking(p);
}
if (p->state == BR_STATE_DISABLED)
continue;

if (p->port_no == br->root_port) {
p->config_pending = 0;
p->topology_change_ack = 0;
br_make_forwarding(p);
} else if (br_is_designated_port(p)) {
del_timer(&p->message_age_timer);
br_make_forwarding(p);
} else {
p->config_pending = 0;
p->topology_change_ack = 0;
br_make_blocking(p);
}

if (p->state == BR_STATE_FORWARDING)
++liveports;
}

if (liveports == 0)
netif_carrier_off(br->dev);
else
netif_carrier_on(br->dev);
}

/* called under bridge lock */
Expand Down
1 change: 1 addition & 0 deletions net/bridge/br_stp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static void br_forward_delay_timer_expired(unsigned long arg)
p->state = BR_STATE_FORWARDING;
if (br_is_designated_for_some_port(br))
br_topology_change_detection(br);
netif_carrier_on(br->dev);
}
br_log_state(p);
spin_unlock(&br->lock);
Expand Down

0 comments on commit 1faa435

Please sign in to comment.