bonding: Refactor, fix, and updates
Subsystems (3)
cover bonding: Refactor, fix, and updates
Five patches for bonding; these apply to net-next-2.6.
Patch 1 is a refactor of the MII monitor, similar to the previous
refactor of the ARP active-backup monitor. It replaces the monolithic monitor function that uses conditional locking with a two phase (inspect and commit) approach with strict locking (RTNL) required only for the commit phase (which is only called when things actually change). The long term goal here is to ultimately consolidate all monitors within a generic framework.
Patch 2 makes a change to the Infiniband slave removal processing
to avoid a system crash when removing the final slave via sysfs.
Patches 3 - 5 provide support for allowing slaves to receive
traffic independently from the master, and require some explanation.
The goal of the last three patches is to permit slaves to receive
incoming traffic independently from the master; there are legitimate reasons for wanting to do so, e.g., LLDP. There are two ways to implement
this: a special case within bonding (skb_bond_should_drop) that would require a hard-coded list of protocols to pass through, or a generic method, that modifies the packet receive logic within netif_receive_skb. The latter method is what is presented here.
Please apply patches 1 - 2, and review and apply or provide
feedback for patches 3 - 5.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
PATCH 1/5 bonding: refactor mii monitor
Refactor mii monitor. As with the previous ARP monitor refactor,
the motivation for this is to handle locking rationally (in this case, removing conditional locking) and generally clean up the code.
This patch breaks up the monolithic mii monitor into two phases:
an inspection phase, followed by an optional commit phase. The commit phase is the only portion that requires RTNL or makes changes to state, and is only called when inspection finds something to change.
--- drivers/net/bonding/bond_3ad.c | 1 + drivers/net/bonding/bond_main.c | 394 +++++++++++++++++---------------------- 2 files changed, 173 insertions(+), 222 deletions(-)
drivers/net/bonding/bond_3ad.c +1 -0
@@ -2107,6 +2107,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) aggregator =__get_first_agg (port);ad_agg_selection_logic (aggregator); } +bond_3ad_set_carrier (bond); }// for each port run the state machines
drivers/net/bonding/bond_main.c +172 -222
463 lines not on this page · raw message
Signature · 1 line
1.5.2.4
PATCH 2/5 bonding: Don't destroy bonding master when removing slave via sysfs
From: Moni Shoua <[email protected]>
It is wrong to destroy a bonding master from a context that uses the sysfs of that bond. When last IPoIB slave is unenslaved from by writing to a sysfs file (for bond0 this would be /sys/class/net/bond0/bonding/slaves) the driver tries to destroy the bond. This is wrong and can lead to a lockup or a crash. This fix lets the bonding master stay and relies on the user to destroy the bonding master if necessary (i.e. before module ib_ipoib is unloaded)
This patch affects only bonds of IPoIB slaves. Ethernet slaves stay unaffected.
--- drivers/net/bonding/bond_sysfs.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_sysfs.c +0 -3
@@ -350,9 +350,6 @@ static ssize_t bonding_store_slaves(struct device *d,if (dev) { printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", bond->dev->name, dev->name); -if (bond->setup_by_slave) - res =bond_release_and_destroy (bond->dev, dev); -else res =bond_release (bond->dev, dev);if (res) { ret = res;
Signature · 1 line
1.5.2.4
PATCH 3/5 net/core: Uninline skb_bond().
From: Joe Eykholt <[email protected]>
Otherwise subsequent changes need multiple return values.
--- net/core/dev.c | 28 ++++++++-------------------- 1 files changed, 8 insertions(+), 20 deletions(-)
net/core/dev.c +8 -20
@@ -1872,22 +1872,6 @@ int netif_rx_ni(struct sk_buff *skb)EXPORT_SYMBOL (netif_rx_ni); -static inline struct net_device *skb_bond (struct sk_buff *skb) -{ -struct net_device *dev = skb->dev; - -if (dev->master) { -if (skb_bond_should_drop (skb)) { -kfree_skb (skb); -return NULL ; - } - skb->dev = dev->master; - } - -return dev; -} - -static void net_tx_action (struct softirq_action *h) {struct softnet_data *sd = &__get_cpu_var (softnet_data);
@@ -2092,10 +2076,14 @@ int netif_receive_skb(struct sk_buff *skb)if (!skb->iif) skb->iif = skb->dev->ifindex; - orig_dev =skb_bond (skb); - -if (!orig_dev) -return NET_RX_DROP ; + orig_dev = skb->dev; +if (orig_dev->master) { +if (skb_bond_should_drop (skb)) { +kfree_skb (skb); +return NET_RX_DROP ; + } + skb->dev = orig_dev->master; + }__get_cpu_var (netdev_rx_stat).total++;
Signature · 1 line
1.5.2.4
PATCH 4/5 net/core: Allow certain receives on inactive slave.
From: Joe Eykholt <[email protected]>
Allow a packet_type that specifies the exact device to receive even on an inactive bonding slave devices. This is important for some L2 protocols such as LLDP and FCoE. This can eventually be used for the bonding special cases as well.
--- net/core/dev.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
net/core/dev.c +8 -7
@@ -2063,6 +2063,7 @@ int netif_receive_skb(struct sk_buff *skb) {struct packet_type *ptype, *pt_prev;struct net_device *orig_dev; +struct net_device *null_or_orig;int ret =NET_RX_DROP ;__be16 type;
@@ -2076,13 +2077,13 @@ int netif_receive_skb(struct sk_buff *skb)if (!skb->iif) skb->iif = skb->dev->ifindex; + null_or_orig =NULL ; orig_dev = skb->dev;if (orig_dev->master) { -if (skb_bond_should_drop (skb)) { -kfree_skb (skb); -return NET_RX_DROP ; - } - skb->dev = orig_dev->master; +if (skb_bond_should_drop (skb)) + null_or_orig = orig_dev;/* deliver only exact match */ +else + skb->dev = orig_dev->master; }__get_cpu_var (netdev_rx_stat).total++;
@@ -2103,7 +2104,7 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (!ptype->dev || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
@@ -2128,7 +2129,7 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (!ptype->dev || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev)) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
Signature · 1 line
1.5.2.4
PATCH 5/5 net/core: Allow receive on active slaves.
From: Joe Eykholt <[email protected]>
If a packet_type specifies an active slave to bonding and not just any interface, allow it to receive frames that came in on that interface.
--- net/core/dev.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
net/core/dev.c +4 -2
@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
@@ -2129,7 +2130,8 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
Signature · 1 line
1.5.2.4
Re: [PATCH 5/5] net/core: Allow receive on active slaves.
Quoted 26 lines · Jay Vosburgh
From: Joe Eykholt <[email protected]>
If a
packet_typespecifies an active slave to bonding and not just any interface, allow it to receive frames that came in on that interface.Signed-off-by Joe Eykholt <[email protected]>Signed-off-by Jay Vosburgh <[email protected]>--- net/core/dev.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)net/core/dev.c +2
-1@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
net/core/dev.c ncls: · line 2135
Quoted 7 lines
net/core/dev.c +2
-1@@ -2129,7 +2130,8 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev)
This needs a review&ack from David, then OK...
David Miller
maintainerRe: [PATCH 5/5] net/core: Allow receive on active slaves.
From: Jeff Garzik <[email protected]>
Date: Fri, 04 Jul 2008 08:45:52 -0400
Quoted 13 lines
Quoted 12 lines · Jay Vosburgh
net/core/dev.c +2
-1@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;@@ -2129,7 +2130,8 @@ ncls: list_for_each_entry_rcu(ptype,
Quoted 8 lines
net/core/dev.c ncls: · line 2135
Quoted 6 lines
net/core/dev.c +2
-1&ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev)This needs a review&ack from David, then OK...
I fear this bit of the changes will break AF_PACKET device binding. So for example, if a tap registers it wants to hear eth0, it will now hear bond0 as well as eth0 if eth0 is a part of bond0.
Re: [PATCH 5/5] net/core: Allow receive on active slaves.
Quoted 24 lines · David Miller
From: Jeff Garzik <[email protected]>
Date: Fri, 04 Jul 2008 08:45:52 -0400Quoted 4 lines
Quoted 3 lines · Jay Vosburgh
(quoted diff) +0
-0@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb) #endifQuoted 16 lines
Quoted 8 lines
net/core/dev.c +2
-1list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;net/core/dev.c ncls: · line 2135
Quoted 7 lines
net/core/dev.c +2
-1@@ -2129,7 +2130,8 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev)This needs a review&ack from David, then OK...
Quoted 3 lines
I fear this bit of the changes will break
AF_PACKETdevice binding. So for example, if a tap registers it wants to hear eth0, it will now hear bond0 as well as eth0 if eth0 is a part of bond0.
Each ptype will get matched and delivered to at most once. So if someone binds AF_PACKET to only eth0, they'll only see the packet once. Whereas before patch 4, the frame wouldn't be delivered to them
at all, since skb->dev has already been changed to the bond.
Regards,
Joe Eykholt
Re: [PATCH 5/5] net/core: Allow receive on active slaves.
From: Joe Eykholt <[email protected]>
Date: Sat, 05 Jul 2008 21:36:42 -0700
Quoted 25 lines
Quoted 24 lines · David Miller
From: Jeff Garzik <[email protected]>
Date: Fri, 04 Jul 2008 08:45:52 -0400Quoted 20 lines
Quoted 11 lines · Jay Vosburgh
net/core/dev.c +2
-1@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;net/core/dev.c ncls: · line 2135
Quoted 7 lines
net/core/dev.c +2
-1@@ -2129,7 +2130,8 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev)This needs a review&ack from David, then OK...
Quoted 8 lines
Quoted 3 lines
I fear this bit of the changes will break
AF_PACKETdevice binding. So for example, if a tap registers it wants to hear eth0, it will now hear bond0 as well as eth0 if eth0 is a part of bond0.Each ptype will get matched and delivered to at most once. So if someone binds
AF_PACKETto only eth0, they'll only see the packet once. Whereas before patch 4, the frame wouldn't be delivered to them at all, sinceskb->devhas already been changed to the bond.
Ok, that works.
Jeff, I ACK this patch and the others that go with it:
Re: [PATCH 5/5] net/core: Allow receive on active slaves.
Quoted 34 lines · David Miller
From: Joe Eykholt <[email protected]>
Date: Sat, 05 Jul 2008 21:36:42 -0700Quoted 24 lines
Quoted 23 lines · David Miller
From: Jeff Garzik <[email protected]>
Date: Fri, 04 Jul 2008 08:45:52 -0400Quoted 20 lines
Quoted 11 lines · Jay Vosburgh
net/core/dev.c +2
-1@@ -2104,7 +2104,8 @@ int netif_receive_skb(struct sk_buff *skb)#endif list_for_each_entry_rcu (ptype, &ptype_all, list) { -if (ptype->dev == null_or_orig || ptype->dev == skb->dev) { +if (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;net/core/dev.c ncls: · line 2135
Quoted 7 lines
net/core/dev.c +2
-1@@ -2129,7 +2130,8 @@ ncls:list_for_each_entry_rcu (ptype, &ptype_base[ntohs (type) &PTYPE_HASH_MASK ], list) {if (ptype->type == type && - (ptype->dev == null_or_orig || ptype->dev == skb->dev)) { + (ptype->dev == null_or_orig || ptype->dev == skb->dev || + ptype->dev == orig_dev)) {if (pt_prev)This needs a review&ack from David, then OK...
Quoted 6 lines
Quoted 3 lines
I fear this bit of the changes will break
AF_PACKETdevice binding. So for example, if a tap registers it wants to hear eth0, it will now hear bond0 as well as eth0 if eth0 is a part of bond0.Each ptype will get matched and delivered to at most once. So if someone binds
AF_PACKETto only eth0, they'll only see the packet once. Whereas before patch 4, the frame wouldn't be delivered to them
at all, sinceskb->devhas already been changed to the bond.
Quoted 5 lines
Ok, that works.
Jeff, I ACK this patch and the others that go with it:
Acked-by David S. Miller <[email protected]>
Is there something more that I need to do to get this integrated? Do I need to refresh the patches or something?
Will it go in during the next merge window?
Thanks,
Joe
Jeff, are you still waiting for net-next-2.6 to settle before
forwarding patches? It's been a couple of weeks since your last status update, and I want check to see if I should resend the patches from this series.
Davem did ack the relevant patches.
From: Jay Vosburgh <[email protected]>
To: [email protected]
Cc: Jeff Garzik <[email protected]>, David Miller <[email protected]>
Subject: [PATCH net-next-2.6 0/5] bonding: Refactor, fix, and updates
Date: Wed, 2 Jul 2008 18:21:57 -0700
Five patches for bonding; these apply to net-next-2.6.
Patch 1 is a refactor of the MII monitor, similar to the previous
refactor of the ARP active-backup monitor. It replaces the monolithic monitor function that uses conditional locking with a two phase (inspect and commit) approach with strict locking (RTNL) required only for the commit phase (which is only called when things actually change). The long term goal here is to ultimately consolidate all monitors within a generic framework.
Patch 2 makes a change to the Infiniband slave removal processing
to avoid a system crash when removing the final slave via sysfs.
Patches 3 - 5 provide support for allowing slaves to receive
traffic independently from the master, and require some explanation.
The goal of the last three patches is to permit slaves to receive
incoming traffic independently from the master; there are legitimate reasons for wanting to do so, e.g., LLDP. There are two ways to implement
this: a special case within bonding (skb_bond_should_drop) that would require a hard-coded list of protocols to pass through, or a generic method, that modifies the packet receive logic within netif_receive_skb. The latter method is what is presented here.
Please apply patches 1 - 2, and review and apply or provide
feedback for patches 3 - 5.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
Re: [PATCH 1/5] bonding: refactor mii monitor
In reply to Jay VosburghQuoted 9 lines · Jay Vosburgh
Refactor mii monitor. As with the previous ARP monitor refactor,
the motivation for this is to handle locking rationally (in this case, removing conditional locking) and generally clean up the code.This patch breaks up the monolithic mii monitor into two phases:
an inspection phase, followed by an optional commit phase. The commit phase is the only portion that requires RTNL or makes changes to state, and is only called when inspection finds something to change.
Quoted 5 lines
Signed-off-by Jay Vosburgh <[email protected]>--- drivers/net/bonding/bond_3ad.c | 1 + drivers/net/bonding/bond_main.c | 394 +++++++++++++++++---------------------- 2 files changed, 173 insertions(+), 222 deletions(-)
applied 1-5