net/bonding: ADD IPoIB support for the bonding driver
Subsystems (5)
v6 cover net/bonding: ADD IPoIB support for the bonding driver
This patch series is the sixth version (see below link to V5) of the suggested changes to the bonding driver so it would be able to support non ARPHRD_ETHER netdevices for its High-Availability (active-backup) mode.
Patches 1-8 were originally submitted in V5 and patch 9 is an addition by Jay.
Major changes from the previous version:
----------------------------------------
1. Remove the patches to net/core. Bonding will use the NETDEV_GOING_DOWN notification instead of NETDEV_CHANGE+IFF_SLAVE_DETACH. This reduces the amount of patches from 11 to 9.
Links to earlier discussion:
----------------------------
1. A discussion in netdev about bonding support for IPoIB.
http://lists.openwall.net/netdev/2006/11/30/46
2. V5 series
http://lists.openfabrics.org/pipermail/general/2007-September/040996.html
PATCH v6 1/9 IB/ipoib: Bound the net device to the ipoib_neigh structue
IPoIB uses a two layer neighboring scheme, such that for each struct neighbour whose device is an ipoib one, there is a struct ipoib_neigh buddy which is created on demand at the tx flow by an ipoib_neigh_alloc(skb->dst->neighbour) call.
When using the bonding driver, neighbours are created by the net stack on behalf of the bonding (master) device. On the tx flow the bonding code gets an skb such that skb->dev points to the master device, it changes this skb to point on the slave device and calls the slave hard_start_xmit function.
Under this scheme, ipoib_neigh_destructor assumption that for each struct neighbour it gets, n->dev is an ipoib device and hence netdev_priv(n->dev) can be casted to struct ipoib_dev_priv is buggy.
To fix it, this patch adds a dev field to struct ipoib_neigh which is used instead of the struct neighbour dev one, when n->dev->flags has the IFF_MASTER bit set.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 4 +++- drivers/infiniband/ulp/ipoib/ipoib_main.c | 24 +++++++++++++++--------- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib.h +3 -1
@@ -328,6 +328,7 @@ struct ipoib_neigh {struct sk_buff_head queue;struct neighbour *neighbour; +struct net_device *dev;struct list_head list; };
@@ -344,7 +345,8 @@ static inline struct ipoib_neigh **to_ip INFINIBAND_ALEN, sizeof(void *)); } -struct ipoib_neigh *ipoib_neigh_alloc (struct neighbour *neigh); +struct ipoib_neigh *ipoib_neigh_alloc (struct neighbour *neigh, +struct net_device *dev);void ipoib_neigh_free (struct net_device *dev,struct ipoib_neigh *neigh);extern struct workqueue_struct *ipoib_workqueue;
drivers/infiniband/ulp/ipoib/ipoib_main.c +15 -9
@@ -511,7 +511,7 @@ static void neigh_add_path(struct sk_bufstruct ipoib_path *path;struct ipoib_neigh *neigh; - neigh =ipoib_neigh_alloc (skb->dst->neighbour); + neigh =ipoib_neigh_alloc (skb->dst->neighbour, skb->dev);if (!neigh) { ++priv->stats.tx_dropped;dev_kfree_skb_any (skb);
@@ -830,6 +830,13 @@ static void ipoib_neigh_cleanup(struct nunsigned long flags;struct ipoib_ah *ah =NULL ; + neigh = *to_ipoib_neigh (n); +if (neigh) { + priv =netdev_priv (neigh->dev); +ipoib_dbg (priv,"neigh_destructor for bonding device: %s\n" , + n->dev->name); + }else +return ; ipoib_dbg(priv, "neigh_cleanup for %06x " IPOIB_GID_FMT "\n", IPOIB_QPN(n->ha),
@@ -837,13 +844,10 @@ static void ipoib_neigh_cleanup(struct nspin_lock_irqsave (&priv->lock, flags); - neigh = *to_ipoib_neigh (n); -if (neigh) { -if (neigh->ah) - ah = neigh->ah; -list_del (&neigh->list); -ipoib_neigh_free (n->dev, neigh); - } +if (neigh->ah) + ah = neigh->ah; +list_del (&neigh->list); +ipoib_neigh_free (n->dev, neigh);spin_unlock_irqrestore (&priv->lock, flags);
@@ -851,7 +855,8 @@ static void ipoib_neigh_cleanup(struct nipoib_put_ah (ah); } -struct ipoib_neigh *ipoib_neigh_alloc (struct neighbour *neighbour) +struct ipoib_neigh *ipoib_neigh_alloc (struct neighbour *neighbour, +struct net_device *dev) {struct ipoib_neigh *neigh;
@@ -860,6 +865,7 @@ struct ipoib_neigh *ipoib_neigh_alloc(streturn NULL ; neigh->neighbour = neighbour; + neigh->dev = dev; *to_ipoib_neigh (neighbour) = neigh;skb_queue_head_init (&neigh->queue);ipoib_cm_set (neigh,NULL );
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +2 -1
@@ -727,7 +727,8 @@ out:if (skb->dst && skb->dst->neighbour && !*to_ipoib_neigh (skb->dst->neighbour)) { -struct ipoib_neigh *neigh =ipoib_neigh_alloc (skb->dst->neighbour); +struct ipoib_neigh *neigh =ipoib_neigh_alloc (skb->dst->neighbour, + skb->dev);if (neigh) {kref_get (&mcast->ah->ref);
PATCH v6 2/9 IB/ipoib: Verify address handle validity on send
In reply to Moni ShouaWhen the bonding device senses a carrier loss of its active slave it replaces that slave with a new one. In between the times when the carrier of an IPoIB device goes down and ipoib_neigh is destroyed, it is possible that the bonding driver will send a packet on a new slave that uses an old ipoib_neigh. This patch detects and prevents this from happenning.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +3 -2
@@ -686,9 +686,10 @@ static int ipoib_start_xmit(struct sk_bu goto out; } }else if (neigh->ah) { -if (unlikely (memcmp (&neigh->dgid.raw, +if (unlikely ((memcmp (&neigh->dgid.raw, skb->dst->neighbour->ha +4 , -sizeof (union ib_gid )))) { +sizeof (union ib_gid ))) || + (neigh->dev != dev))) {spin_lock (&priv->lock);/* * It's safe to call ipoib_put_ah() inside
PATCH v6 3/9 net/bonding: Enable bonding to enslave non ARPHRD_ETHER
In reply to Moni ShouaThis patch changes some of the bond netdevice attributes and functions to be that of the active slave for the case of the enslaved device not being of ARPHRD_ETHER type. Basically it overrides those setting done by ether_setup(), which are netdevice **type** dependent and hence might be not appropriate for devices of other types. It also enforces mutual exclusion on bonding slaves from dissimilar ether types, as was concluded over the v1 discussion.
IPoIB (see Documentation/infiniband/ipoib.txt) MAC address is made of a 3 bytes IB QP (Queue Pair) number and 16 bytes IB port GID (Global ID) of the port this IPoIB device is bounded to. The QP is a resource created by the IB HW and the GID is an identifier burned into the HCA (i have omitted here some details which are not important for the bonding RFC).
--- drivers/net/bonding/bond_main.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+)
drivers/net/bonding/bond_main.c +39 -0
@@ -1237,6 +1237,26 @@ static int bond_compute_features(structreturn 0 ; } + +static void bond_setup_by_slave (struct net_device *bond_dev, +struct net_device *slave_dev) +{ + bond_dev->hard_header = slave_dev->hard_header; + bond_dev->rebuild_header = slave_dev->rebuild_header; + bond_dev->hard_header_cache = slave_dev->hard_header_cache; + bond_dev->header_cache_update = slave_dev->header_cache_update; + bond_dev->hard_header_parse = slave_dev->hard_header_parse; + + bond_dev->neigh_setup = slave_dev->neigh_setup; + + bond_dev->type = slave_dev->type; + bond_dev->hard_header_len = slave_dev->hard_header_len; + bond_dev->addr_len = slave_dev->addr_len; + +memcpy (bond_dev->broadcast, slave_dev->broadcast, + slave_dev->addr_len); +} +/* enslave device <slave> to bond device <master> */ int bond_enslave (struct net_device *bond_dev,struct net_device *slave_dev) {
@@ -1311,6 +1331,25 @@ int bond_enslave(struct net_device *bond goto err_undo_flags; } +/* set bonding device ether type by slave - bonding netdevices are +* created with ether_setup, so when the slave type is not ARPHRD_ETHER +* there is a need to override some of the type dependent attribs/funcs. +* +* bond ether type mutual exclusion - don't allow slaves of dissimilar +* ether type (eg ARPHRD_ETHER and ARPHRD_INFINIBAND) share the same bond +*/ +if (bond->slave_cnt ==0 ) { +if (slave_dev->type !=ARPHRD_ETHER ) +bond_setup_by_slave (bond_dev, slave_dev); + }else if (bond_dev->type != slave_dev->type) { + printk(KERN_ERR DRV_NAME ": %s ether type (%d) is different " +"from other slaves (%d), can not enslave it.\n" , + slave_dev->name, + slave_dev->type, bond_dev->type); + res = -EINVAL ; + goto err_undo_flags; + } +if (slave_dev->set_mac_address ==NULL ) { printk(KERN_ERR DRV_NAME": %s: Error: The slave device you specified does "
PATCH v6 4/9 net/bonding: Enable bonding to enslave netdevices not supporting set_mac_address()
In reply to Moni ShouaThis patch allows for enslaving netdevices which do not support the set_mac_address() function. In that case the bond mac address is the one of the active slave, where remote peers are notified on the mac address (neighbour) change by Gratuitous ARP sent by bonding when fail-over occurs (this is already done by the bonding code).
--- drivers/net/bonding/bond_main.c | 87 +++++++++++++++++++++++++++------------- drivers/net/bonding/bonding.h | 1 2 files changed, 60 insertions(+), 28 deletions(-)
drivers/net/bonding/bond_main.c +59 -28
@@ -1095,6 +1095,14 @@ void bond_change_active_slave(struct bonif (new_active) {bond_set_slave_active_flags (new_active); } + +/* when bonding does not set the slave MAC address, the bond MAC +* address is the one of the active slave. +*/ +if (new_active && !bond->do_set_mac_addr) +memcpy (bond->dev->dev_addr, new_active->dev->dev_addr, + new_active->dev->addr_len); +bond_send_gratuitous_arp (bond); } }
@@ -1351,13 +1359,22 @@ int bond_enslave(struct net_device *bond }if (slave_dev->set_mac_address ==NULL ) { - printk(KERN_ERR DRV_NAME -": %s: Error: The slave device you specified does " -"not support setting the MAC address. " -"Your kernel likely does not support slave " - "devices.\n", bond_dev->name); - res = -EOPNOTSUPP ; - goto err_undo_flags; +if (bond->slave_cnt ==0 ) { + printk(KERN_WARNING DRV_NAME +": %s: Warning: The first slave device you " +"specified does not support setting the MAC " +"address. This bond MAC address would be that " + "of the active slave.\n", bond_dev->name); + bond->do_set_mac_addr =0 ; + }else if (bond->do_set_mac_addr) { + printk(KERN_ERR DRV_NAME +": %s: Error: The slave device you specified " +"does not support setting the MAC addres,." +"but this bond uses this practice. \n" + , bond_dev->name); + res = -EOPNOTSUPP ; + goto err_undo_flags; + } } new_slave =kzalloc (sizeof (struct slave ),GFP_KERNEL );
@@ -1378,16 +1395,18 @@ int bond_enslave(struct net_device *bond*/ memcpy (new_slave->perm_hwaddr, slave_dev->dev_addr,ETH_ALEN ); -/* -* Set slave to master's mac address. The application already -* set the master's mac address to that of the first slave -*/ -memcpy (addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); - addr.sa_family = slave_dev->type; - res =dev_set_mac_address (slave_dev, &addr); -if (res) { -dprintk ("Error %d calling set_mac_address\n" , res); - goto err_free; +if (bond->do_set_mac_addr) { +/* +* Set slave to master's mac address. The application already +* set the master's mac address to that of the first slave +*/ +memcpy (addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); + addr.sa_family = slave_dev->type; + res =dev_set_mac_address (slave_dev, &addr); +if (res) { +dprintk ("Error %d calling set_mac_address\n" , res); + goto err_free; + } } res =netdev_set_master (slave_dev, bond_dev);
@@ -1612,9 +1631,11 @@ err_close:dev_close (slave_dev); err_restore_mac: -memcpy (addr.sa_data, new_slave->perm_hwaddr,ETH_ALEN ); - addr.sa_family = slave_dev->type; -dev_set_mac_address (slave_dev, &addr); +if (bond->do_set_mac_addr) { +memcpy (addr.sa_data, new_slave->perm_hwaddr,ETH_ALEN ); + addr.sa_family = slave_dev->type; +dev_set_mac_address (slave_dev, &addr); + } err_free:kfree (new_slave);
@@ -1792,10 +1813,12 @@ int bond_release(struct net_device *bond/* close slave before restoring its mac address */ dev_close (slave_dev); -/* restore original ("permanent") mac address */ -memcpy (addr.sa_data, slave->perm_hwaddr,ETH_ALEN ); - addr.sa_family = slave_dev->type; -dev_set_mac_address (slave_dev, &addr); +if (bond->do_set_mac_addr) { +/* restore original ("permanent") mac address */ +memcpy (addr.sa_data, slave->perm_hwaddr,ETH_ALEN ); + addr.sa_family = slave_dev->type; +dev_set_mac_address (slave_dev, &addr); + } slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | IFF_SLAVE_INACTIVE | IFF_BONDING |
@@ -1882,10 +1905,12 @@ static int bond_release_all(struct net_d/* close slave before restoring its mac address */ dev_close (slave_dev); -/* restore original ("permanent") mac address*/ -memcpy (addr.sa_data, slave->perm_hwaddr,ETH_ALEN ); - addr.sa_family = slave_dev->type; -dev_set_mac_address (slave_dev, &addr); +if (bond->do_set_mac_addr) { +/* restore original ("permanent") mac address*/ +memcpy (addr.sa_data, slave->perm_hwaddr,ETH_ALEN ); + addr.sa_family = slave_dev->type; +dev_set_mac_address (slave_dev, &addr); + } slave_dev->priv_flags &= ~(IFF_MASTER_8023AD |IFF_MASTER_ALB |IFF_SLAVE_INACTIVE );
@@ -3922,6 +3947,9 @@ static int bond_set_mac_address(struct ndprintk ("bond=%p, name=%s\n" , bond, (bond_dev ? bond_dev->name :"None" )); +if (!bond->do_set_mac_addr) +return -EOPNOTSUPP ; +if (!is_valid_ether_addr (sa->sa_data)) {return -EADDRNOTAVAIL ; }
@@ -4312,6 +4340,9 @@ static int bond_init(struct net_device *bond_create_proc_entry (bond);#endif +/* set do_set_mac_addr to true on startup */ + bond->do_set_mac_addr =1 ; +list_add_tail (&bond->bond_list, &bond_dev_list);return 0 ;
drivers/net/bonding/bonding.h +1 -0
@@ -185,6 +185,7 @@ struct bonding {struct timer_list mii_timer;struct timer_list arp_timer;s8 kill_timers; +s8 do_set_mac_addr;struct net_device_stats stats;#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry;
PATCH v6 5/9 net/bonding: Enable IP multicast for bonding IPoIB devices
In reply to Moni ShouaAllow to enslave devices when the bonding device is not up. Over the discussion held at the previous post this seemed to be the most clean way to go, where it is not expected to cause instabilities.
Normally, the bonding driver is UP before any enslavement takes place. Once a netdevice is UP, the network stack acts to have it join some multicast groups (eg the all-hosts 224.0.0.1). Now, since ether_setup() have set the bonding device type to be ARPHRD_ETHER and address len to be ETHER_ALEN, the net core code computes a wrong multicast link address. This is b/c ip_eth_mc_map() is called where for multicast joins taking place after the enslavement another ip_xxx_mc_map() is called (eg ip_ib_mc_map() when the bond type is ARPHRD_INFINIBAND)
--- drivers/net/bonding/bond_main.c | 5 +++-- drivers/net/bonding/bond_sysfs.c | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/bonding/bond_main.c +3 -2
@@ -1285,8 +1285,9 @@ int bond_enslave(struct net_device *bond/* bond must be initialized by bond_open() before enslaving */ if (!(bond_dev->flags &IFF_UP )) { -dprintk ("Error, master_dev is not up\n" ); -return -EPERM ; + printk(KERN_WARNING DRV_NAME +" %s: master_dev is not up in bond_enslave\n" , + bond_dev->name); }/* already enslaved */
drivers/net/bonding/bond_sysfs.c +2 -4
@@ -266,11 +266,9 @@ static ssize_t bonding_store_slaves(stru/* Quick sanity check -- is the bond interface up? */ if (!(bond->dev->flags &IFF_UP )) { - printk(KERN_ERR DRV_NAME -": %s: Unable to update slaves because interface is down.\n" , + printk(KERN_WARNING DRV_NAME +": %s: doing slave updates when interface is down.\n" , bond->dev->name); - ret = -EPERM ; - goto out; }/* Note: We can't hold bond->lock here, as bond_create grabs it. */
Re: [PATCH V6 5/9] net/bonding: Enable IP multicast for bonding IPoIB devices
Quoted 42 lines · On Mon, 24 Sep 2007 17:37:00 +0200 Moni Shoua <[email protected]> wrote:
Allow to enslave devices when the bonding device is not up. Over the discussion held at the previous post this seemed to be the most clean way to go, where it is not expected to cause instabilities.
Normally, the bonding driver is UP before any enslavement takes place. Once a netdevice is UP, the network stack acts to have it join some multicast groups (eg the all-hosts 224.0.0.1). Now, since
ether_setup()have set the bonding device type to beARPHRD_ETHERand address len to beETHER_ALEN, the net core code computes a wrong multicast link address. This is b/cip_eth_mc_map()is called where for multicast joins taking place after the enslavement anotherip_xxx_mc_map()is called (egip_ib_mc_map()when the bond type isARPHRD_INFINIBAND)Signed-off-by Moni Shoua <monis at voltaire.com>Signed-off-by Or Gerlitz <ogerlitz at voltaire.com>--- drivers/net/bonding/bond_main.c | 5 +++-- drivers/net/bonding/bond_sysfs.c | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-)Index:
net-2.6/drivers/net/bonding/bond_main.c
===================================================================drivers/net/bonding/bond_main.c +3
-2@@ -1285,8 +1285,9 @@ int bond_enslave(struct net_device *bond/* bond must be initialized by bond_open() before enslaving */ if (!(bond_dev->flags &IFF_UP )) { -dprintk ("Error, master_dev is not up\n" ); -return -EPERM ; + printk(KERN_WARNING DRV_NAME +" %s: master_dev is not up in bond_enslave\n" , + bond_dev->name); }/* already enslaved */ Index:
net-2.6/drivers/net/bonding/bond_sysfs.c
===================================================================drivers/net/bonding/bond_sysfs.c +0
-0@@ -266,11 +266,9 @@ static ssize_t bonding_store_slaves(stru/* Quick sanity check -- is the bond interface up? */
drivers/net/bonding/bond_sysfs.c static ssize_t bonding_store_slaves(stru · line 273
Quoted 10 lines
drivers/net/bonding/bond_sysfs.c +2
-4if (!(bond->dev->flags &IFF_UP )) { - printk(KERN_ERR DRV_NAME -": %s: Unable to update slaves because interface is down.\n" , + printk(KERN_WARNING DRV_NAME +": %s: doing slave updates when interface is down.\n" , bond->dev->name); - ret = -EPERM ; - goto out; }
Please get rid of the warning. Make bonding work correctly and allow enslave/remove of device when bonding is down.
Re: [PATCH V6 5/9] net/bonding: Enable IP multicast for bonding IPoIB devices
Quoted 9 lines
Please get rid of the warning. Make bonding work correctly and allow enslave/remove of device when bonding is down.
-
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
Hi,
I prefer to postpone it till I submit another version of the patches or till after the patches are merged. Anyway, I've added this to the TODO list.
thanks
MoniS
PATCH v6 6/9 net/bonding: Handlle wrong assumptions that slave is always an Ethernet device
In reply to Moni Shouabonding sometimes uses Ethernet constants (such as MTU and address length) which are not good when it enslaves non Ethernet devices (such as InfiniBand).
--- drivers/net/bonding/bond_main.c | 3 ++- drivers/net/bonding/bond_sysfs.c | 10 ++++++++-- drivers/net/bonding/bonding.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +2 -1
@@ -1224,7 +1224,8 @@ static int bond_compute_features(structstruct slave *slave;struct net_device *bond_dev = bond->dev;unsigned long features = bond_dev->features; -unsigned short max_hard_header_len =ETH_HLEN ; +unsigned short max_hard_header_len =max ((u16 )ETH_HLEN , + bond_dev->hard_header_len);int i; features &= ~(NETIF_F_ALL_CSUM |BOND_VLAN_FEATURES );
drivers/net/bonding/bond_sysfs.c +8 -2
@@ -260,6 +260,7 @@ static ssize_t bonding_store_slaves(struchar command[IFNAMSIZ +1 ] = {0 , };char *ifname;int i, res, found, ret = count; +u32 original_mtu;struct slave *slave;struct net_device *dev =NULL ;struct bonding *bond =to_bond (d);
@@ -325,6 +326,7 @@ static ssize_t bonding_store_slaves(stru }/* Set the slave's MTU to match the bond */ + original_mtu = dev->mtu;if (dev->mtu != bond->dev->mtu) {if (dev->change_mtu) { res = dev->change_mtu(dev,
@@ -339,6 +341,9 @@ static ssize_t bonding_store_slaves(stru }rtnl_lock (); res =bond_enslave (bond->dev, dev); +bond_for_each_slave (bond, slave, i) +if (strnicmp (slave->dev->name, ifname,IFNAMSIZ ) ==0 ) + slave->original_mtu = original_mtu;rtnl_unlock ();if (res) { ret = res;
@@ -351,6 +356,7 @@ static ssize_t bonding_store_slaves(strubond_for_each_slave (bond, slave, i)if (strnicmp (slave->dev->name, ifname,IFNAMSIZ ) ==0 ) { dev = slave->dev; + original_mtu = slave->original_mtu;break ; }if (dev) {
@@ -365,9 +371,9 @@ static ssize_t bonding_store_slaves(stru }/* set the slave MTU to the default */ if (dev->change_mtu) { - dev->change_mtu (dev,1500 ); + dev->change_mtu (dev, original_mtu); }else { - dev->mtu =1500 ; + dev->mtu = original_mtu; } }else {
drivers/net/bonding/bonding.h +1 -0
@@ -156,6 +156,7 @@ struct slave {s8 link;/* one of BOND_LINK_XXXX */ s8 state;/* one of BOND_STATE_XXXX */ u32 original_flags; +u32 original_mtu;u32 link_failure_count;u16 speed;u8 duplex;
[ofa-general] PATCH V6 7/9] net/bonding: Delay sending of gratuitous ARP to avoid failure
In reply to Moni ShouaDelay sending a gratuitous_arp when LINK_STATE_LINKWATCH_PENDING bit in dev->state field is on. This improves the chances for the arp packet to be transmitted.
--- drivers/net/bonding/bond_main.c | 24 +++++++++++++++++++++--- drivers/net/bonding/bonding.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +21 -3
@@ -1102,8 +1102,14 @@ void bond_change_active_slave(struct bonif (new_active && !bond->do_set_mac_addr)memcpy (bond->dev->dev_addr, new_active->dev->dev_addr, new_active->dev->addr_len); - -bond_send_gratuitous_arp (bond); +if (bond->curr_active_slave && +test_bit (__LINK_STATE_LINKWATCH_PENDING, + &bond->curr_active_slave->dev->state)) { +dprintk ("delaying gratuitous arp on %s\n" , + bond->curr_active_slave->dev->name); + bond->send_grat_arp =1 ; + }else +bond_send_gratuitous_arp (bond); } }
@@ -2083,6 +2089,17 @@ void bond_mii_monitor(struct net_device* program could monitor the link itself if needed. */ +if (bond->send_grat_arp) { +if (bond->curr_active_slave &&test_bit (__LINK_STATE_LINKWATCH_PENDING, + &bond->curr_active_slave->dev->state)) +dprintk ("Needs to send gratuitous arp but not yet\n" ); +else { +dprintk ("sending delayed gratuitous arp on on %s\n" , + bond->curr_active_slave->dev->name); +bond_send_gratuitous_arp (bond); + bond->send_grat_arp =0 ; + } + }read_lock (&bond->curr_slave_lock); oldcurrent = bond->curr_active_slave;read_unlock (&bond->curr_slave_lock);
@@ -2484,7 +2501,7 @@ static void bond_send_gratuitous_arp(strif (bond->master_ip) {bond_arp_send (slave->dev,ARPOP_REPLY , bond->master_ip, - bond->master_ip,0 ); + bond->master_ip,0 ); }list_for_each_entry (vlan, &bond->vlan_list, vlan_list) {
@@ -4293,6 +4310,7 @@ static int bond_init(struct net_device * bond->current_arp_slave =NULL ; bond->primary_slave =NULL ; bond->dev = bond_dev; + bond->send_grat_arp =0 ;INIT_LIST_HEAD (&bond->vlan_list);/* Initialize the device entry points */
drivers/net/bonding/bonding.h +1 -0
@@ -187,6 +187,7 @@ struct bonding {struct timer_list arp_timer;s8 kill_timers;s8 do_set_mac_addr; +s8 send_grat_arp;struct net_device_stats stats;#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry;
PATCH v6 8/9 net/bonding: Destroy bonding master when last slave is gone
In reply to Moni ShouaWhen bonding enslaves non Ethernet devices it takes pointers to functions
in the module that owns the slaves. In this case it becomes unsafe
to keep the bonding master registered after last slave was unenslaved
because we don't know if the pointers are still valid. Destroying the bond when slave_cnt is zero ensures that these functions be used anymore.
--- drivers/net/bonding/bond_main.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 9 +++++---- drivers/net/bonding/bonding.h | 3 +++ 3 files changed, 45 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_main.c +37 -0
@@ -1256,6 +1256,7 @@ static int bond_compute_features(structstatic void bond_setup_by_slave (struct net_device *bond_dev,struct net_device *slave_dev) { +struct bonding *bond = bond_dev->priv; bond_dev->hard_header = slave_dev->hard_header; bond_dev->rebuild_header = slave_dev->rebuild_header; bond_dev->hard_header_cache = slave_dev->hard_header_cache;
@@ -1270,6 +1271,7 @@ static void bond_setup_by_slave(struct nmemcpy (bond_dev->broadcast, slave_dev->broadcast, slave_dev->addr_len); + bond->setup_by_slave =1 ; }/* enslave device <slave> to bond device <master> */
@@ -1838,6 +1840,35 @@ int bond_release(struct net_device *bond }/* +* Destroy a bonding device. +* Must be under rtnl_lock when this function is called. +*/ +void bond_destroy (struct bonding *bond) +{ +bond_deinit (bond->dev); +bond_destroy_sysfs_entry (bond); +unregister_netdevice (bond->dev); +} + +/* +* First release a slave and than destroy the bond if no more slaves iare left. +* Must be under rtnl_lock when this function is called. +*/ +int bond_release_and_destroy (struct net_device *bond_dev,struct net_device *slave_dev) +{ +struct bonding *bond = bond_dev->priv; +int ret; + + ret =bond_release (bond_dev, slave_dev); +if ((ret ==0 ) && (bond->slave_cnt ==0 )) { + printk(KERN_INFO DRV_NAME " %s: destroying bond %s.\n", + bond_dev->name); +bond_destroy (bond); + } +return ret; +} + +/* * This function releases all slaves. */ static int bond_release_all (struct net_device *bond_dev)
@@ -3337,6 +3368,11 @@ static int bond_slave_netdev_event(unsig* ... Or is it this? */ break ; +case NETDEV_GOING_DOWN : +dprintk ("slave %s is going down\n" , slave_dev->name); +if (bond->setup_by_slave) +bond_release_and_destroy (bond_dev, slave_dev); +break ;case NETDEV_CHANGEMTU :/* * TODO: Should slaves be allowed to
@@ -4311,6 +4347,7 @@ static int bond_init(struct net_device * bond->primary_slave =NULL ; bond->dev = bond_dev; bond->send_grat_arp =0 ; + bond->setup_by_slave =0 ;INIT_LIST_HEAD (&bond->vlan_list);/* Initialize the device entry points */
drivers/net/bonding/bonding.h +3 -0
@@ -188,6 +188,7 @@ struct bonding {s8 kill_timers;s8 do_set_mac_addr;s8 send_grat_arp; +s8 setup_by_slave;struct net_device_stats stats;#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry;
@@ -295,6 +296,8 @@ static inline void bond_unset_master_albstruct vlan_entry *bond_next_vlan (struct bonding *bond,struct vlan_entry *curr);int bond_dev_queue_xmit (struct bonding *bond,struct sk_buff *skb,struct net_device *slave_dev);int bond_create (char *name,struct bond_params *params,struct bonding **newbond); +void bond_destroy (struct bonding *bond); +int bond_release_and_destroy (struct net_device *bond_dev,struct net_device *slave_dev);void bond_deinit (struct net_device *bond_dev);int bond_create_sysfs (void );void bond_destroy_sysfs (void );
drivers/net/bonding/bond_sysfs.c +5 -4
@@ -164,9 +164,7 @@ static ssize_t bonding_store_bonds(struc printk(KERN_INFO DRV_NAME": %s is being deleted...\n" , bond->dev->name); -bond_deinit (bond->dev); -bond_destroy_sysfs_entry (bond); -unregister_netdevice (bond->dev); +bond_destroy (bond);rtnl_unlock (); goto out; }
@@ -363,7 +361,10 @@ static ssize_t bonding_store_slaves(stru printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", bond->dev->name, dev->name);rtnl_lock (); - res =bond_release (bond->dev, dev); +if (bond->setup_by_slave) + res =bond_release_and_destroy (bond->dev, dev); +else + res =bond_release (bond->dev, dev);rtnl_unlock ();if (res) { ret = res;
PATCH v6 9/9 bonding: Optionally allow ethernet slaves to keep own MAC
In reply to Moni ShouaUpdate the "don't change MAC of slaves" functionality added in previous changes to be a generic option, rather than something tied to IB devices, as it's occasionally useful for regular ethernet devices as well.
Adds "fail_over_mac" option (which is automatically enabled for IB
slaves), applicable only to active-backup mode.
Includes documentation update.
Updates bonding driver version to 3.2.0.
--- Documentation/networking/bonding.txt | 33 +++++++++++++++++++ drivers/net/bonding/bond_main.c | 57 +++++++++++++++++++++------------ drivers/net/bonding/bond_sysfs.c | 49 +++++++++++++++++++++++++++++ drivers/net/bonding/bonding.h | 6 ++-- 4 files changed, 121 insertions(+), 24 deletions(-)
Documentation/networking/bonding.txt +33 -0
@@ -281,6 +281,39 @@ downdelay will be rounded down to the nearest multiple. The default value is 0. +fail_over_mac + + Specifies whether active-backup mode should set all slaves to + the same MAC address (the traditional behavior), or, when + enabled, change the bond's MAC address when changing the + active interface (i.e., fail over the MAC address itself). + + Fail over MAC is useful for devices that cannot ever alter + their MAC address, or for devices that refuse incoming + broadcasts with their own source MAC (which interferes with + the ARP monitor). + + The down side of fail over MAC is that every device on the + network must be updated via gratuitous ARP, vs. just updating + a switch or set of switches (which often takes place for any + traffic, not just ARP traffic, if the switch snoops incoming + traffic to update its tables) for the traditional method. If + the gratuitous ARP is lost, communication may be disrupted. + + When fail over MAC is used in conjuction with the mii monitor, + devices which assert link up prior to being able to actually + transmit and receive are particularly susecptible to loss of + the gratuitous ARP, and an appropriate updelay setting may be + required. + + A value of 0 disables fail over MAC, and is the default. A + value of 1 enables fail over MAC. This option is enabled + automatically if the first slave added cannot change its MAC + address. This option may be modified via sysfs only when no + slaves are present in the bond. + + This option was added in bonding version 3.2.0. + lacp_rate Option specifying the rate in which we'll ask our link partner
drivers/net/bonding/bond_main.c +36 -21
138 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +49 -0
61 lines not on this page · raw message
drivers/net/bonding/bonding.h +3 -3
@@ -22,8 +22,8 @@#include "bond_3ad.h" #include "bond_alb.h" -#define DRV_VERSION "3.1.3" -#define DRV_RELDATE "June 13, 2007" +#define DRV_VERSION "3.2.0" +#define DRV_RELDATE "September 13, 2007"#define DRV_NAME "bonding"#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
@@ -128,6 +128,7 @@ struct bond_params {int arp_interval;int arp_validate;int use_carrier; +int fail_over_mac;int updelay;int downdelay;int lacp_fast;
@@ -186,7 +187,6 @@ struct bonding {struct timer_list mii_timer;struct timer_list arp_timer;s8 kill_timers; -s8 do_set_mac_addr;s8 send_grat_arp;s8 setup_by_slave;struct net_device_stats stats;
-- 1.5.2-rc2.GIT
Jay,
I think that all comments to the patches were discussed and handled. If you agree, can you please push then to the networking tree so they will be merged into 2.6.24?
This includes the IPoIB patches (agreed with Roland).
Note that there are *no* patches to net/core (like in V5).
thanks
MoniS
ACK patches 3 - 9.
Roland, are you comfortable with the IB changes in patches 1 and 2?
Jeff, when Roland acks patches 1 and 2, please apply all 9.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
Quoted 27 lines · Moni Shoua
This patch series is the sixth version (see below link to V5) of the suggested changes to the bonding driver so it would be able to support non
ARPHRD_ETHERnetdevices for its High-Availability (active-backup) mode.Patches 1-8 were originally submitted in V5 and patch 9 is an addition by Jay.
Major changes from the previous version:
----------------------------------------1. Remove the patches to net/core. Bonding will use the
NETDEV_GOING_DOWNnotification instead of NETDEV_CHANGE+IFF_SLAVE_DETACH. This reduces the amount of patches from 11 to 9.Links to earlier discussion:
----------------------------1. A discussion in netdev about bonding support for IPoIB.
http://lists.openwall.net/netdev/2006/11/30/462. V5 series
http://lists.openfabrics.org/pipermail/general/2007-September/040996.html-
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
Roland Dreier
Acked-byQuoted 1 line
Roland, are you comfortable with the IB changes in patches 1 and 2?
Yes, they look fine to me. Feel free to apply, with
- R.
Quoted 7 lines · Jay Vosburgh
ACK patches 3 - 9.
Roland, are you comfortable with the IB changes in patches 1 and 2?
Jeff, when Roland acks patches 1 and 2, please apply all 9.
-J
Hi Jeff,
Roland acked the IPoIB patches. If you haven't done so already can you please apply them? I'm not sure when 2.6.24 is going to open and I'm afraid to miss it.
thanks
Quoted 5 lines · Moni Shoua
Quoted 4 lines · Jay Vosburgh
ACK patches 3 - 9.
Roland, are you comfortable with the IB changes in patches 1 and 2?
Quoted 7 lines
Quoted 3 lines
Jeff, when Roland acks patches 1 and 2, please apply all 9. -JHi Jeff,
Roland acked the IPoIB patches. If you haven't done so already can you please apply them? I'm not sure when 2.6.24 is going to open and I'm afraid to miss it.
hrm, I don't see them in my inbox for some reason. can someone bounce them to me? or give me a git tree to pull from?
Jeff
Quoted 8 lines · Jeff Garzik
Quoted 7 lines · Moni Shoua
Quoted 6 lines · Jay Vosburgh
ACK patches 3 - 9.
Roland, are you comfortable with the IB changes in patches 1 and 2?
Jeff, when Roland acks patches 1 and 2, please apply all 9.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
-JHi Jeff,
Roland acked the IPoIB patches. If you haven't done so already can you please apply them? I'm not sure when 2.6.24 is going to open and I'm afraid to miss it.hrm, I don't see them in my inbox for some reason. can someone bounce them to me? or give me a git tree to pull from?
Moni, can you repost the patch series to Jeff, and put the
appropriate "Acked-by" lines in for myself (patches 3 - 8) and Roland (patches 1 and 2)? You can probably leave off the netdev and openfabrics lists, but cc me.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
Quoted 22 lines · Jay Vosburgh
Quoted 6 lines · Jeff Garzik
Quoted 5 lines · Moni Shoua
Quoted 4 lines · Jay Vosburgh
ACK patches 3 - 9.
Roland, are you comfortable with the IB changes in patches 1 and 2?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Jeff, when Roland acks patches 1 and 2, please apply all 9. -JHi Jeff,
Roland acked the IPoIB patches. If you haven't done so already can you please apply them? I'm not sure when 2.6.24 is going to open and I'm afraid to miss it.hrm, I don't see them in my inbox for some reason. can someone bounce them to me? or give me a git tree to pull from?
Moni, can you repost the patch series to Jeff, and put the
appropriate "Acked-by" lines in for myself (patches 3 - 8) and Roland (patches 1 and 2)? You can probably leave off the netdev and openfabrics lists, but cc me.
Quoted 5 lines
-J---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
Hi Jeff,
I don't commits of the patches in http://git.kernel.org/?p=linux/kernel/git/jgarzik/netdev-2.6.git;a=summary
(I hope that I'm looking in the right place).
Did you get them?
thanks
MoniS