From patchwork Mon Mar 7 18:34:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 85789 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D81AEB70EC for ; Tue, 8 Mar 2011 05:34:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755007Ab1CGSeM (ORCPT ); Mon, 7 Mar 2011 13:34:12 -0500 Received: from mail.vyatta.com ([76.74.103.46]:40176 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526Ab1CGSeL (ORCPT ); Mon, 7 Mar 2011 13:34:11 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id A0518182901B; Mon, 7 Mar 2011 10:34:10 -0800 (PST) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NlDRrRDpLqjh; Mon, 7 Mar 2011 10:34:09 -0800 (PST) Received: from nehalam (pool-74-107-135-205.ptldor.fios.verizon.net [74.107.135.205]) by mail.vyatta.com (Postfix) with ESMTPSA id EA7BB182895B; Mon, 7 Mar 2011 10:34:08 -0800 (PST) Date: Mon, 7 Mar 2011 10:34:06 -0800 From: Stephen Hemminger To: "David S. Miller" Cc: Nicolas de =?ISO-8859-1?B?UGVzbG/8YW4=?= , Adam Majer , Alexey Kuznetsov , "Pekka Savola (ipv6)" , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , bridge@lists.linux-foundation.org, netdev@vger.kernel.org, Andy Gospodarek , Jay Vosburgh Subject: [PATCH] bridge: control carrier based on ports online Message-ID: <20110307103406.27330529@nehalam> In-Reply-To: <4D748CC3.8060603@gmail.com> References: <1649722795.14144.1299480074110.JavaMail.root@tahiti.vyatta.com> <4D748CC3.8060603@gmail.com> Organization: Vyatta X-Mailer: Claws Mail 3.7.6 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: Nicolas de Pesloüan Tested-By: Adam Majer --- net/bridge/br_device.c | 4 ++++ net/bridge/br_stp.c | 35 ++++++++++++++++++++++------------- net/bridge/br_stp_timer.c | 1 + 3 files changed, 27 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/bridge/br_device.c 2011-03-07 08:40:08.913599513 -0800 +++ b/net/bridge/br_device.c 2011-03-07 08:40:48.382377389 -0800 @@ -78,6 +78,8 @@ static int br_dev_open(struct net_device { struct net_bridge *br = netdev_priv(dev); + netif_carrier_off(dev); + br_features_recompute(br); netif_start_queue(dev); br_stp_enable_bridge(br); @@ -94,6 +96,8 @@ static int br_dev_stop(struct net_device { struct net_bridge *br = netdev_priv(dev); + netif_carrier_off(dev); + br_stp_disable_bridge(br); br_multicast_stop(br); --- a/net/bridge/br_stp.c 2011-03-07 08:41:58.619783678 -0800 +++ b/net/bridge/br_stp.c 2011-03-07 08:53:58.953558810 -0800 @@ -397,28 +397,37 @@ static void br_make_forwarding(struct ne 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 */ --- a/net/bridge/br_stp_timer.c 2011-03-07 08:53:25.728770710 -0800 +++ b/net/bridge/br_stp_timer.c 2011-03-07 08:53:40.273116636 -0800 @@ -94,6 +94,7 @@ static void br_forward_delay_timer_expir 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);