From patchwork Fri May 15 18:44:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 27278 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id EB13DB6F44 for ; Sat, 16 May 2009 04:44:45 +1000 (EST) Received: by ozlabs.org (Postfix) id D881DDE115; Sat, 16 May 2009 04:44:45 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 7960BDE114 for ; Sat, 16 May 2009 04:44:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753423AbZEOSoi (ORCPT ); Fri, 15 May 2009 14:44:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753234AbZEOSoi (ORCPT ); Fri, 15 May 2009 14:44:38 -0400 Received: from mail.vyatta.com ([76.74.103.46]:36658 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753122AbZEOSoh (ORCPT ); Fri, 15 May 2009 14:44:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id D563D4F4033; Fri, 15 May 2009 11:44:38 -0700 (PDT) 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 6e-FPuuowG4W; Fri, 15 May 2009 11:44:34 -0700 (PDT) Received: from nehalam (pool-71-117-243-159.ptldor.fios.verizon.net [71.117.243.159]) by mail.vyatta.com (Postfix) with ESMTP id D34954F4030; Fri, 15 May 2009 11:44:33 -0700 (PDT) Date: Fri, 15 May 2009 11:44:32 -0700 From: Stephen Hemminger To: Jay Vosburgh Cc: bonding-devel@lists.sf.net, netdev@vger.kernel.org Subject: [PATCH] bonding: fix link down handling in 802.3ad mode Message-ID: <20090515114432.4025a2d6@nehalam> Organization: Vyatta X-Mailer: Claws Mail 3.6.1 (GTK+ 2.16.1; 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 One of the purposes of bonding is to allow for redundant links, and failover correctly if the cable is pulled. If all the members of a bonded device have no carrier present, the bonded device itself needs to report no carrier present to user space so management tools (like routing daemons) can respond. Bonding in 802.3ad mode does not work correctly for this because it incorrectly chooses a link that is down as a possible aggregator. Signed-off-by: Stephen Hemminger --- This patch is a bug fix and should go into 2.6.30 Signed-off-by: Jay Vosburgh --- 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/drivers/net/bonding/bond_3ad.c 2009-05-14 15:38:15.090363836 -0700 +++ b/drivers/net/bonding/bond_3ad.c 2009-05-15 11:41:44.313559146 -0700 @@ -1465,6 +1465,12 @@ static struct aggregator *ad_agg_selecti return best; } +static int agg_device_up(const struct aggregator *agg) +{ + return (netif_running(agg->slave->dev) && + netif_carrier_ok(agg->slave->dev)); +} + /** * ad_agg_selection_logic - select an aggregation group for a team * @aggregator: the aggregator we're looking at @@ -1496,14 +1502,13 @@ static void ad_agg_selection_logic(struc struct port *port; origin = agg; - active = __get_active_agg(agg); - best = active; + best = (active && agg_device_up(active)) ? active : NULL; do { agg->is_active = 0; - if (agg->num_of_ports) + if (agg->num_of_ports && agg_device_up(agg)) best = ad_agg_selection_test(best, agg); } while ((agg = __get_next_agg(agg)));