Re: [PATCH netdev-2.6.git] bonding: support carrier state for master

2006-03-29 Thread Jeff Garzik

Jay Vosburgh wrote:

Add support for the bonding master to specify its carrier state
based upon the state of the slaves.  For 802.3ad, the bond is up if
there is an active, parterned aggregator.  For other modes, the bond is
up if any slaves are up.  Updates driver version to 3.0.3.

Based on a patch by jamal [EMAIL PROTECTED].

Signed-off-by: Jay Vosburgh [EMAIL PROTECTED]


applied


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH netdev-2.6.git] bonding: support carrier state for master

2006-03-27 Thread Jay Vosburgh

Add support for the bonding master to specify its carrier state
based upon the state of the slaves.  For 802.3ad, the bond is up if
there is an active, parterned aggregator.  For other modes, the bond is
up if any slaves are up.  Updates driver version to 3.0.3.

Based on a patch by jamal [EMAIL PROTECTED].

Signed-off-by: Jay Vosburgh [EMAIL PROTECTED]


--- n26u-carrier/drivers/net/bonding/bond_3ad.c 2006/03/27 19:43:21 1.1
+++ n26u-carrier/drivers/net/bonding/bond_3ad.c 2006/03/27 20:21:19
@@ -2294,6 +2294,34 @@ void bond_3ad_handle_link_change(struct 
port-sm_vars |= AD_PORT_BEGIN;
 }
 
+/*
+ * set link state for bonding master: if we have an active partnered
+ * aggregator, we're up, if not, we're down.  Presumes that we cannot
+ * have an active aggregator if there are no slaves with link up.
+ *
+ * Called by bond_set_carrier(). Return zero if carrier state does not
+ * change, nonzero if it does.
+ */
+int bond_3ad_set_carrier(struct bonding *bond)
+{
+   struct aggregator *agg;
+
+   agg = __get_active_agg((SLAVE_AD_INFO(bond-first_slave).aggregator));
+   if (agg  MAC_ADDRESS_COMPARE(agg-partner_system, null_mac_addr)) {
+   if (!netif_carrier_ok(bond-dev)) {
+   netif_carrier_on(bond-dev);
+   return 1;
+   }
+   return 0;
+   }
+
+   if (netif_carrier_ok(bond-dev)) {
+   netif_carrier_off(bond-dev);
+   return 1;
+   }
+   return 0;
+}
+
 /**
  * bond_3ad_get_active_agg_info - get information of the active aggregator
  * @bond: bonding struct to work on
--- n26u-carrier/drivers/net/bonding/bond_3ad.h 2006/03/27 19:43:21 1.1
+++ n26u-carrier/drivers/net/bonding/bond_3ad.h 2006/03/27 19:43:41
@@ -283,5 +283,6 @@ void bond_3ad_handle_link_change(struct 
 int  bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info 
*ad_info);
 int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
 int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct 
packet_type* ptype, struct net_device *orig_dev);
+int bond_3ad_set_carrier(struct bonding *bond);
 #endif //__BOND_3AD_H__
 
--- n26u-carrier/drivers/net/bonding/bond_main.c2006/03/27 19:43:21 
1.1
+++ n26u-carrier/drivers/net/bonding/bond_main.c2006/03/27 21:03:37
@@ -559,6 +559,42 @@ out:
 /*--- Link status ---*/
 
 /*
+ * Set the carrier state for the master according to the state of its
+ * slaves.  If any slaves are up, the master is up.  In 802.3ad mode,
+ * do special 802.3ad magic.
+ *
+ * Returns zero if carrier state does not change, nonzero if it does.
+ */
+static int bond_set_carrier(struct bonding *bond)
+{
+   struct slave *slave;
+   int i;
+
+   if (bond-slave_cnt == 0)
+   goto down;
+
+   if (bond-params.mode == BOND_MODE_8023AD)
+   return bond_3ad_set_carrier(bond);
+
+   bond_for_each_slave(bond, slave, i) {
+   if (slave-link == BOND_LINK_UP) {
+   if (!netif_carrier_ok(bond-dev)) {
+   netif_carrier_on(bond-dev);
+   return 1;
+   }
+   return 0;
+   }
+   }
+
+down:
+   if (netif_carrier_ok(bond-dev)) {
+   netif_carrier_off(bond-dev);
+   return 1;
+   }
+   return 0;
+}
+
+/*
  * Get link speed and duplex from the slave's base driver
  * using ethtool. If for some reason the call fails or the
  * values are invalid, fake speed and duplex to 100/Full
@@ -1074,10 +1110,24 @@ void bond_change_active_slave(struct bon
 void bond_select_active_slave(struct bonding *bond)
 {
struct slave *best_slave;
+   int rv;
 
best_slave = bond_find_best_slave(bond);
if (best_slave != bond-curr_active_slave) {
bond_change_active_slave(bond, best_slave);
+   rv = bond_set_carrier(bond);
+   if (!rv)
+   return;
+
+   if (netif_carrier_ok(bond-dev)) {
+   printk(KERN_INFO DRV_NAME
+  : %s: first active interface up!\n,
+  bond-dev-name);
+   } else {
+   printk(KERN_INFO DRV_NAME : %s: 
+  now running without any active interface !\n,
+  bond-dev-name);
+   }
}
 }
 
@@ -1458,10 +1508,14 @@ int bond_enslave(struct net_device *bond
if (((!bond-curr_active_slave) ||
 (bond-curr_active_slave-dev-priv_flags  
IFF_SLAVE_INACTIVE)) 
(new_slave-link != BOND_LINK_DOWN)) {
-   dprintk(This is the first active slave\n);
/* first slave or no active slave yet, and this link