mostly bonding cleanups (partial repost)
Subsystems (5)
cover mostly bonding cleanups (partial repost)
My original series had 2 more patches. That ones I posponed until I resolve problems with delivering vlan arps to bond_frame_handler on non-vlan_hw_accel path.
So for now, there are following patches that are ready to be applied I believe.
Note the dependency on "fcoe: correct checking for bonding" patch that has not been applied so far on scsi-misc. I believe that maybe this patch could be applied on net-next instead.
Jiri Pirko (6):
af_packet: use skb->skb_iif instead of orig_dev->ifindex
bonding: register slave pointer for rx_handler
net: get rid of multiple bond-related netdevice->priv_flags
bonding: wrap slave state work
bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
net: introduce rx_handler results and logic around that
drivers/net/bonding/bond_3ad.c | 2 +- drivers/net/bonding/bond_main.c | 102 +++++++++++++++++++------------------- drivers/net/bonding/bond_sysfs.c | 14 +---- drivers/net/bonding/bonding.h | 60 +++++++++++++---------- drivers/net/macvlan.c | 11 ++-- include/linux/if.h | 23 +++----- include/linux/netdevice.h | 50 ++++++++++++++++++- include/linux/skbuff.h | 5 +-- net/bridge/br_input.c | 25 ++++++---- net/bridge/br_private.h | 2 +- net/core/dev.c | 21 +++++--- net/core/skbuff.c | 1 - net/packet/af_packet.c | 4 +- 13 files changed, 186 insertions(+), 134 deletions(-)
Signature · 1 line
1.7.4
PATCH 1/6 af_packet: use skb->skb_iif instead of orig_dev->ifindex
Since skb_iif has the desired value (ifindex of physical device actually received the traffic) use that instead.
--- net/packet/af_packet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/packet/af_packet.c +2 -2
@@ -627,7 +627,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type;if (unlikely (po->origdev)) - sll->sll_ifindex = orig_dev->ifindex; + sll->sll_ifindex = skb->skb_iif;else sll->sll_ifindex = dev->ifindex;
@@ -812,7 +812,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type;if (unlikely (po->origdev)) - sll->sll_ifindex = orig_dev->ifindex; + sll->sll_ifindex = skb->skb_iif;else sll->sll_ifindex = dev->ifindex;
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
Quoted 7 lines · Jiri Pirko
Since
skb_iifhas the desired value (ifindex of physical device actually received the traffic) use that instead.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Changli Gao <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>---
This may "break" the ptype handlers in TX path, as we always assign skb->dev to origdev there. Thanks.
Signature · 2 lines
Regards, Changli Gao([email protected])
Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
Quoted 11 lines · Mon, Mar 14, 2011 at 12:52:37AM CET, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Since
skb_iifhas the desired value (ifindex of physical device actually received the traffic) use that instead.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Changli Gao <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>---
This may "break" the ptype handlers in TX path, as we always assign
skb->devto origdev there. Thanks.
Changli, would you please point me the relevant code?. Thanks!
Jirka
Quoted 4 lines
Signature · 3 lines
-- Regards, Changli Gao([email protected])
Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
Quoted 10 lines · Jiri Pirko
Quoted 9 lines · Mon, Mar 14, 2011 at 12:52:37AM CET, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Since
skb_iifhas the desired value (ifindex of physical device actually received the traffic) use that instead.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Changli Gao <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>---
Quoted 5 lines
Quoted 2 lines
This may "break" the ptype handlers in TX path, as we always assign
skb->devto origdev there. Thanks.Changli, would you please point me the relevant code?. Thanks!
1557 static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
....
1571 if (pt_prev) {
1572 deliver_skb(skb2, pt_prev, skb->dev); 1573 pt_prev = ptype; 1574 continue;
1575 }
...
1603 }
1604 if (pt_prev)
1605 pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
1606 rcu_read_unlock();
1607 }
Signature · 2 lines
Regards, Changli Gao([email protected])
Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
Quoted 24 lines · Mon, Mar 14, 2011 at 07:59:39AM CET, [email protected] wrote:
Quoted 10 lines · Jiri Pirko
Quoted 9 lines · Mon, Mar 14, 2011 at 12:52:37AM CET, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Since
skb_iifhas the desired value (ifindex of physical device actually received the traffic) use that instead.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Changli Gao <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>---
Quoted 5 lines
Quoted 2 lines
This may "break" the ptype handlers in TX path, as we always assign
skb->devto origdev there. Thanks.Changli, would you please point me the relevant code?. Thanks!
1557 static void
dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
....1571 if (
pt_prev) {1572 deliver_skb(skb2, pt_prev, skb->dev); 1573 pt_prev = ptype; 1574 continue;
Quoted 7 lines
1575 }
...
1603 }
1604 if (pt_prev)
1605pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
1606rcu_read_unlock();
1607 }
I'm probably missign something but I do not see the connection between this and setting up sll->sll_ifindex in net/packet/af_packet.c
Quoted 4 lines
Signature · 3 lines
-- Regards, Changli Gao([email protected])
Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
Quoted 18 lines · Jiri Pirko
Quoted 5 lines · Mon, Mar 14, 2011 at 07:59:39AM CET, [email protected] wrote:
Quoted 1 line
1557 static void
dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
....Quoted 11 lines
1571 if (
pt_prev) {
1572deliver_skb(skb2, pt_prev, skb->dev); 1573pt_prev= ptype;
1574 continue;
1575 }
...
1603 }
1604 if (pt_prev)
1605pt_prev->func(skb2, skb->dev, pt_prev, skb->dev); 1606rcu_read_unlock();
1607 }
Quoted 3 lines
I'm probably missign something but I do not see the connection between this and setting up
sll->sll_ifindexinnet/packet/af_packet.c
Think about a packet socket(with origdev set) for packets emitted via NIC eth0, and sll->sll_ifindex is eth0->ifindex, but after your patch, sll->sll_ifindex may be ZERO or the ifindex of the RX NIC for the forwarded packets. However, I don't know if this origdev usage is valid. Thanks.
Signature · 2 lines
Regards, Changli Gao([email protected])
PATCH 2/6 bonding: register slave pointer for rx_handler
In reply to Jiri PirkoRegister slave pointer as rx_handler data. That would eventually prevent need to loop over slave devices to find the right slave.
Use synchronize_net to ensure that bond_handle_frame does not get slave structure freed when working with that.
--- drivers/net/bonding/bond_main.c | 17 +++++++++++------ drivers/net/bonding/bonding.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/bonding/bond_main.c +11 -6
@@ -1482,21 +1482,22 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb,static struct sk_buff *bond_handle_frame (struct sk_buff *skb) { -struct net_device *slave_dev; +struct slave *slave;struct net_device *bond_dev; skb =skb_share_check (skb,GFP_ATOMIC );if (unlikely (!skb))return NULL ; - slave_dev = skb->dev; - bond_dev =ACCESS_ONCE (slave_dev->master); + + slave =bond_slave_get_rcu (skb->dev); + bond_dev =ACCESS_ONCE (slave->dev->master);if (unlikely (!bond_dev))return skb;if (bond_dev->priv_flags &IFF_MASTER_ARPMON ) - slave_dev->last_rx = jiffies; + slave->dev->last_rx = jiffies; -if (bond_should_deliver_exact_match (skb, slave_dev, bond_dev)) { +if (bond_should_deliver_exact_match (skb, slave->dev, bond_dev)) { skb->deliver_no_wcard =1 ;return skb; }
@@ -1694,7 +1695,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)pr_debug ("Error %d calling netdev_set_bond_master\n" , res); goto err_restore_mac; } - res =netdev_rx_handler_register (slave_dev, bond_handle_frame,NULL ); + res =netdev_rx_handler_register (slave_dev, bond_handle_frame, + new_slave);if (res) {pr_debug ("Error %d calling netdev_rx_handler_register\n" , res); goto err_unset_master;
@@ -1916,6 +1918,7 @@ err_close: err_unreg_rxhandler:netdev_rx_handler_unregister (slave_dev); +synchronize_net (); err_unset_master:netdev_set_bond_master (slave_dev,NULL );
@@ -2099,6 +2102,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) }netdev_rx_handler_unregister (slave_dev); +synchronize_net ();netdev_set_bond_master (slave_dev,NULL );slave_disable_netpoll (slave);
@@ -2213,6 +2217,7 @@ static int bond_release_all(struct net_device *bond_dev) }netdev_rx_handler_unregister (slave_dev); +synchronize_net ();netdev_set_bond_master (slave_dev,NULL );slave_disable_netpoll (slave);
drivers/net/bonding/bonding.h +3 -0
@@ -266,6 +266,9 @@ struct bonding {#endif /* CONFIG_DEBUG_FS */ }; +#define bond_slave_get_rcu (dev) \ + ((struct slave *) rcu_dereference(dev->rx_handler_data)) +/** * Returns NULL if the net_device does not belong to any of the bond's slaves *
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler
From: Jiri Pirko <[email protected]>
Date: Sat, 12 Mar 2011 14:14:35 +0100
Quoted 8 lines
Register slave pointer as
rx_handlerdata. That would eventually prevent need to loop over slave devices to find the right slave.Use
synchronize_netto ensure thatbond_handle_framedoes not get slave structure freed when working with that.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>
Applied.
PATCH 3/6 net: get rid of multiple bond-related netdevice->priv_flags
In reply to Jiri PirkoNow when bond-related code is moved from net/core/dev.c into bonding code, multiple priv_flags are not needed anymore. So toss them out.
--- drivers/net/bonding/bond_main.c | 33 ++++++++++++++------------------- drivers/net/bonding/bond_sysfs.c | 8 -------- drivers/net/bonding/bonding.h | 24 +----------------------- include/linux/if.h | 22 +++++++++------------- 4 files changed, 24 insertions(+), 63 deletions(-)
drivers/net/bonding/bond_main.c +14 -19
@@ -1458,20 +1458,20 @@ static void bond_setup_by_slave(struct net_device *bond_dev,* ARP on active-backup slaves with arp_validate enabled. */ static bool bond_should_deliver_exact_match (struct sk_buff *skb, -struct net_device *slave_dev, -struct net_device *bond_dev) +struct slave *slave, +struct bonding *bond) { -if (slave_dev->priv_flags &IFF_SLAVE_INACTIVE ) { -if (slave_dev->priv_flags &IFF_SLAVE_NEEDARP && +if (slave->dev->priv_flags &IFF_SLAVE_INACTIVE ) { +if (slave_do_arp_validate (bond, slave) && skb->protocol ==__cpu_to_be16 (ETH_P_ARP ))return false; -if (bond_dev->priv_flags &IFF_MASTER_ALB && +if (bond->params.mode ==BOND_MODE_ALB && skb->pkt_type !=PACKET_BROADCAST && skb->pkt_type !=PACKET_MULTICAST )return false; -if (bond_dev->priv_flags &IFF_MASTER_8023AD && +if (bond->params.mode ==BOND_MODE_8023AD && skb->protocol ==__cpu_to_be16 (ETH_P_SLOW ))return false;
@@ -1484,6 +1484,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) {struct slave *slave;struct net_device *bond_dev; +struct bonding *bond; skb =skb_share_check (skb,GFP_ATOMIC );if (unlikely (!skb))
@@ -1494,17 +1495,19 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)if (unlikely (!bond_dev))return skb; -if (bond_dev->priv_flags &IFF_MASTER_ARPMON ) + bond =netdev_priv (bond_dev); + +if (bond->params.arp_interval) slave->dev->last_rx = jiffies; -if (bond_should_deliver_exact_match (skb, slave->dev, bond_dev)) { +if (bond_should_deliver_exact_match (skb, slave, bond)) { skb->deliver_no_wcard =1 ;return skb; } skb->dev = bond_dev; -if (bond_dev->priv_flags &IFF_MASTER_ALB && +if (bond->params.mode ==BOND_MODE_ALB && bond_dev->priv_flags &IFF_BRIDGE_PORT && skb->pkt_type ==PACKET_HOST ) {
@@ -2119,9 +2122,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)dev_set_mtu (slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD |IFF_MASTER_ALB | -IFF_SLAVE_INACTIVE |IFF_BONDING | -IFF_SLAVE_NEEDARP ); + slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_BONDING );kfree (slave);
@@ -2232,8 +2233,7 @@ static int bond_release_all(struct net_device *bond_dev)dev_set_mac_address (slave_dev, &addr); } - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD |IFF_MASTER_ALB | -IFF_SLAVE_INACTIVE ); + slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE ;kfree (slave);
@@ -4416,11 +4416,9 @@ void bond_set_mode_ops(struct bonding *bond, int mode)case BOND_MODE_BROADCAST :break ;case BOND_MODE_8023AD : -bond_set_master_3ad_flags (bond);bond_set_xmit_hash_policy (bond);break ;case BOND_MODE_ALB : -bond_set_master_alb_flags (bond);/* FALLTHRU */ case BOND_MODE_TLB :break ;
@@ -4511,9 +4509,6 @@ static void bond_setup(struct net_device *bond_dev) bond_dev->priv_flags |=IFF_BONDING ; bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE ; -if (bond->params.arp_interval) - bond_dev->priv_flags |=IFF_MASTER_ARPMON ; -/* At first, we block adding VLANs. That's the only way to * prevent problems that occur when adding VLANs over an * empty bond. The block will be removed once non-challenged
drivers/net/bonding/bond_sysfs.c +0 -8
@@ -322,11 +322,6 @@ static ssize_t bonding_store_mode(struct device *d, ret = -EINVAL ; goto out; } -if (bond->params.mode ==BOND_MODE_8023AD ) -bond_unset_master_3ad_flags (bond); - -if (bond->params.mode ==BOND_MODE_ALB ) -bond_unset_master_alb_flags (bond); bond->params.mode = new_value;bond_set_mode_ops (bond, bond->params.mode);
@@ -527,8 +522,6 @@ static ssize_t bonding_store_arp_interval(struct device *d,pr_info ("%s: Setting ARP monitoring interval to %d.\n" , bond->dev->name, new_value); bond->params.arp_interval = new_value; -if (bond->params.arp_interval) - bond->dev->priv_flags |=IFF_MASTER_ARPMON ;if (bond->params.miimon) {pr_info ("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n" , bond->dev->name, bond->dev->name);
@@ -1004,7 +997,6 @@ static ssize_t bonding_store_miimon(struct device *d,pr_info ("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n" , bond->dev->name); bond->params.arp_interval =0 ; - bond->dev->priv_flags &= ~IFF_MASTER_ARPMON ;if (bond->params.arp_validate) {bond_unregister_arp (bond); bond->params.arp_validate =
drivers/net/bonding/bonding.h +1 -23
@@ -356,34 +356,12 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) slave->state =BOND_STATE_BACKUP ;if (!bond->params.all_slaves_active) slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; -if (slave_do_arp_validate (bond, slave)) - slave->dev->priv_flags |=IFF_SLAVE_NEEDARP ; }static inline void bond_set_slave_active_flags (struct slave *slave) { slave->state =BOND_STATE_ACTIVE ; - slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_SLAVE_NEEDARP ); -} - -static inline void bond_set_master_3ad_flags (struct bonding *bond) -{ - bond->dev->priv_flags |=IFF_MASTER_8023AD ; -} - -static inline void bond_unset_master_3ad_flags (struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_8023AD ; -} - -static inline void bond_set_master_alb_flags (struct bonding *bond) -{ - bond->dev->priv_flags |=IFF_MASTER_ALB ; -} - -static inline void bond_unset_master_alb_flags (struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_ALB ; + slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; }struct vlan_entry *bond_next_vlan (struct bonding *bond,struct vlan_entry *curr);
include/linux/if.h +9 -13
@@ -60,21 +60,17 @@#define IFF_802_1Q_VLAN 0x1/* 802.1Q VLAN device. */ #define IFF_EBRIDGE 0x2/* Ethernet bridging device. */ #define IFF_SLAVE_INACTIVE 0x4/* bonding slave not the curr. active */ -#define IFF_MASTER_8023AD 0x8/* bonding master, 802.3ad. */ -#define IFF_MASTER_ALB 0x10/* bonding master, balance-alb. */ -#define IFF_BONDING 0x20/* bonding master or slave */ -#define IFF_SLAVE_NEEDARP 0x40/* need ARPs for validation */ -#define IFF_ISATAP 0x80/* ISATAP interface (RFC4214) */ -#define IFF_MASTER_ARPMON 0x100/* bonding master, ARP mon in use */ -#define IFF_WAN_HDLC 0x200/* WAN HDLC device */ -#define IFF_XMIT_DST_RELEASE 0x400/* dev_hard_start_xmit() is allowed to +#define IFF_BONDING 0x8/* bonding master or slave */ +#define IFF_ISATAP 0x10/* ISATAP interface (RFC4214) */ +#define IFF_WAN_HDLC 0x20/* WAN HDLC device */ +#define IFF_XMIT_DST_RELEASE 0x40/* dev_hard_start_xmit() is allowed to * release skb->dst */ -#define IFF_DONT_BRIDGE 0x800/* disallow bridging this ether dev */ -#define IFF_DISABLE_NETPOLL 0x1000/* disable netpoll at run-time */ -#define IFF_MACVLAN_PORT 0x2000/* device used as macvlan port */ -#define IFF_BRIDGE_PORT 0x4000/* device used as bridge port */ -#define IFF_OVS_DATAPATH 0x8000/* device used as Open vSwitch +#define IFF_DONT_BRIDGE 0x80/* disallow bridging this ether dev */ +#define IFF_DISABLE_NETPOLL 0x100/* disable netpoll at run-time */ +#define IFF_MACVLAN_PORT 0x200/* device used as macvlan port */ +#define IFF_BRIDGE_PORT 0x400/* device used as bridge port */ +#define IFF_OVS_DATAPATH 0x800/* device used as Open vSwitch * datapath port */ #define IF_GET_IFACE 0x0001/* for querying only */
Signature · 1 line
1.7.4
PATCH v2 3/6 net: get rid of multiple bond-related netdevice->priv_flags
Now when bond-related code is moved from net/core/dev.c into bonding code, multiple priv_flags are not needed anymore. So let them rot.
--- drivers/net/bonding/bond_main.c | 33 ++++++++++++++------------------- drivers/net/bonding/bond_sysfs.c | 8 -------- drivers/net/bonding/bonding.h | 24 +----------------------- 3 files changed, 15 insertions(+), 50 deletions(-)
drivers/net/bonding/bond_main.c +14 -19
@@ -1458,20 +1458,20 @@ static void bond_setup_by_slave(struct net_device *bond_dev,* ARP on active-backup slaves with arp_validate enabled. */ static bool bond_should_deliver_exact_match (struct sk_buff *skb, -struct net_device *slave_dev, -struct net_device *bond_dev) +struct slave *slave, +struct bonding *bond) { -if (slave_dev->priv_flags &IFF_SLAVE_INACTIVE ) { -if (slave_dev->priv_flags &IFF_SLAVE_NEEDARP && +if (slave->dev->priv_flags &IFF_SLAVE_INACTIVE ) { +if (slave_do_arp_validate (bond, slave) && skb->protocol ==__cpu_to_be16 (ETH_P_ARP ))return false; -if (bond_dev->priv_flags &IFF_MASTER_ALB && +if (bond->params.mode ==BOND_MODE_ALB && skb->pkt_type !=PACKET_BROADCAST && skb->pkt_type !=PACKET_MULTICAST )return false; -if (bond_dev->priv_flags &IFF_MASTER_8023AD && +if (bond->params.mode ==BOND_MODE_8023AD && skb->protocol ==__cpu_to_be16 (ETH_P_SLOW ))return false;
@@ -1484,6 +1484,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) {struct slave *slave;struct net_device *bond_dev; +struct bonding *bond; skb =skb_share_check (skb,GFP_ATOMIC );if (unlikely (!skb))
@@ -1494,17 +1495,19 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)if (unlikely (!bond_dev))return skb; -if (bond_dev->priv_flags &IFF_MASTER_ARPMON ) + bond =netdev_priv (bond_dev); + +if (bond->params.arp_interval) slave->dev->last_rx = jiffies; -if (bond_should_deliver_exact_match (skb, slave->dev, bond_dev)) { +if (bond_should_deliver_exact_match (skb, slave, bond)) { skb->deliver_no_wcard =1 ;return skb; } skb->dev = bond_dev; -if (bond_dev->priv_flags &IFF_MASTER_ALB && +if (bond->params.mode ==BOND_MODE_ALB && bond_dev->priv_flags &IFF_BRIDGE_PORT && skb->pkt_type ==PACKET_HOST ) {
@@ -2119,9 +2122,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)dev_set_mtu (slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD |IFF_MASTER_ALB | -IFF_SLAVE_INACTIVE |IFF_BONDING | -IFF_SLAVE_NEEDARP ); + slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_BONDING );kfree (slave);
@@ -2232,8 +2233,7 @@ static int bond_release_all(struct net_device *bond_dev)dev_set_mac_address (slave_dev, &addr); } - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD |IFF_MASTER_ALB | -IFF_SLAVE_INACTIVE ); + slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE ;kfree (slave);
@@ -4416,11 +4416,9 @@ void bond_set_mode_ops(struct bonding *bond, int mode)case BOND_MODE_BROADCAST :break ;case BOND_MODE_8023AD : -bond_set_master_3ad_flags (bond);bond_set_xmit_hash_policy (bond);break ;case BOND_MODE_ALB : -bond_set_master_alb_flags (bond);/* FALLTHRU */ case BOND_MODE_TLB :break ;
@@ -4511,9 +4509,6 @@ static void bond_setup(struct net_device *bond_dev) bond_dev->priv_flags |=IFF_BONDING ; bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE ; -if (bond->params.arp_interval) - bond_dev->priv_flags |=IFF_MASTER_ARPMON ; -/* At first, we block adding VLANs. That's the only way to * prevent problems that occur when adding VLANs over an * empty bond. The block will be removed once non-challenged
drivers/net/bonding/bond_sysfs.c +0 -8
@@ -322,11 +322,6 @@ static ssize_t bonding_store_mode(struct device *d, ret = -EINVAL ; goto out; } -if (bond->params.mode ==BOND_MODE_8023AD ) -bond_unset_master_3ad_flags (bond); - -if (bond->params.mode ==BOND_MODE_ALB ) -bond_unset_master_alb_flags (bond); bond->params.mode = new_value;bond_set_mode_ops (bond, bond->params.mode);
@@ -527,8 +522,6 @@ static ssize_t bonding_store_arp_interval(struct device *d,pr_info ("%s: Setting ARP monitoring interval to %d.\n" , bond->dev->name, new_value); bond->params.arp_interval = new_value; -if (bond->params.arp_interval) - bond->dev->priv_flags |=IFF_MASTER_ARPMON ;if (bond->params.miimon) {pr_info ("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n" , bond->dev->name, bond->dev->name);
@@ -1004,7 +997,6 @@ static ssize_t bonding_store_miimon(struct device *d,pr_info ("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n" , bond->dev->name); bond->params.arp_interval =0 ; - bond->dev->priv_flags &= ~IFF_MASTER_ARPMON ;if (bond->params.arp_validate) {bond_unregister_arp (bond); bond->params.arp_validate =
drivers/net/bonding/bonding.h +1 -23
@@ -356,34 +356,12 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) slave->state =BOND_STATE_BACKUP ;if (!bond->params.all_slaves_active) slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; -if (slave_do_arp_validate (bond, slave)) - slave->dev->priv_flags |=IFF_SLAVE_NEEDARP ; }static inline void bond_set_slave_active_flags (struct slave *slave) { slave->state =BOND_STATE_ACTIVE ; - slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_SLAVE_NEEDARP ); -} - -static inline void bond_set_master_3ad_flags (struct bonding *bond) -{ - bond->dev->priv_flags |=IFF_MASTER_8023AD ; -} - -static inline void bond_unset_master_3ad_flags (struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_8023AD ; -} - -static inline void bond_set_master_alb_flags (struct bonding *bond) -{ - bond->dev->priv_flags |=IFF_MASTER_ALB ; -} - -static inline void bond_unset_master_alb_flags (struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_ALB ; + slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; }struct vlan_entry *bond_next_vlan (struct bonding *bond,struct vlan_entry *curr);
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 3/6 v2] net: get rid of multiple bond-related netdevice->priv_flags
From: Jiri Pirko <[email protected]>
Date: Wed, 16 Mar 2011 19:45:23 +0100
Quoted 5 lines
Now when bond-related code is moved from
net/core/dev.cinto bonding code, multiplepriv_flagsare not needed anymore. So let them rot.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>
Applied.
PATCH 4/6 bonding: wrap slave state work
In reply to Jiri Pirkotransfers slave->state into slave->backup (that it's going to transfer into bitfield. Introduce wrapper inlines to do the work with it.
--- drivers/net/bonding/bond_3ad.c | 2 +- drivers/net/bonding/bond_main.c | 36 ++++++++++++++++++------------------ drivers/net/bonding/bond_sysfs.c | 2 +- drivers/net/bonding/bonding.h | 31 ++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 25 deletions(-)
drivers/net/bonding/bond_3ad.c +1 -1
@@ -246,7 +246,7 @@ static inline void __enable_port(struct port *port)*/ static inline int __port_is_enabled (struct port *port) { -return port->slave->state ==BOND_STATE_ACTIVE ; +return bond_is_active_slave (port->slave); }/**
drivers/net/bonding/bond_main.c +18 -18
@@ -1863,7 +1863,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)break ;case BOND_MODE_TLB :case BOND_MODE_ALB : - new_slave->state =BOND_STATE_ACTIVE ; +bond_set_active_slave (new_slave);bond_set_slave_inactive_flags (new_slave);bond_select_active_slave (bond);break ;
@@ -1871,7 +1871,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)pr_debug ("This slave is always active in trunk mode\n" );/* always active in trunk mode */ - new_slave->state =BOND_STATE_ACTIVE ; +bond_set_active_slave (new_slave);/* In trunking mode there is little meaning to curr_active_slave * anyway (it holds no special properties of the bond device),
@@ -1909,7 +1909,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)pr_info ("%s: enslaving %s as a%s interface with a%s link.\n" , bond_dev->name, slave_dev->name, - new_slave->state ==BOND_STATE_ACTIVE ?"n active" :" backup" , +bond_is_active_slave (new_slave) ?"n active" :" backup" , new_slave->link !=BOND_LINK_DOWN ?"n up" :" down" );/* enslave is successful */
@@ -2007,7 +2007,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)pr_info ("%s: releasing %s interface %s\n" , bond_dev->name, - (slave->state ==BOND_STATE_ACTIVE ) ?"active" :"backup" , +bond_is_active_slave (slave) ?"active" :"backup" , slave_dev->name); oldcurrent = bond->curr_active_slave;
@@ -2348,7 +2348,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in res =0 ;strcpy (info->slave_name, slave->dev->name); info->link = slave->link; - info->state = slave->state; + info->state =bond_slave_state (slave); info->link_failure_count = slave->link_failure_count;break ; }
@@ -2387,7 +2387,7 @@ static int bond_miimon_inspect(struct bonding *bond) bond->dev->name, (bond->params.mode ==BOND_MODE_ACTIVEBACKUP ) ? - ((slave->state ==BOND_STATE_ACTIVE ) ? + (bond_is_active_slave (slave) ?"active " :"backup " ) :"" , slave->dev->name, bond->params.downdelay * bond->params.miimon);
@@ -2478,13 +2478,13 @@ static void bond_miimon_commit(struct bonding *bond)if (bond->params.mode ==BOND_MODE_8023AD ) {/* prevent it from being the active one */ - slave->state =BOND_STATE_BACKUP ; +bond_set_backup_slave (slave); }else if (bond->params.mode !=BOND_MODE_ACTIVEBACKUP ) {/* make it immediately active */ - slave->state =BOND_STATE_ACTIVE ; +bond_set_active_slave (slave); }else if (slave != bond->primary_slave) {/* prevent it from being the active one */ - slave->state =BOND_STATE_BACKUP ; +bond_set_backup_slave (slave); }bond_update_speed_duplex (slave);
@@ -2862,7 +2862,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packmemcpy (&tip, arp_ptr,4 );pr_debug ("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n" , - bond->dev->name, slave->dev->name, slave->state, + bond->dev->name, slave->dev->name,bond_slave_state (slave), bond->params.arp_validate,slave_do_arp_validate (bond, slave), &sip, &tip);
@@ -2874,7 +2874,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack* the active, through one switch, the router, then the other * switch before reaching the backup. */ -if (slave->state ==BOND_STATE_ACTIVE ) +if (bond_is_active_slave (slave))bond_validate_arp (bond, slave, sip, tip);else bond_validate_arp (bond, slave, tip, sip);
@@ -2936,7 +2936,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) slave->dev->last_rx + delta_in_ticks)) { slave->link =BOND_LINK_UP ; - slave->state =BOND_STATE_ACTIVE ; +bond_set_active_slave (slave);/* primary_slave has no meaning in round-robin * mode. the window of a slave being up and
@@ -2969,7 +2969,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) slave->dev->last_rx + 2 * delta_in_ticks)) { slave->link =BOND_LINK_DOWN ; - slave->state =BOND_STATE_BACKUP ; +bond_set_backup_slave (slave);if (slave->link_failure_count <UINT_MAX ) slave->link_failure_count++;
@@ -3063,7 +3063,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)* gives each slave a chance to tx/rx traffic * before being taken out */ -if (slave->state ==BOND_STATE_BACKUP && +if (!bond_is_active_slave (slave) && !bond->current_arp_slave && !time_in_range(jiffies, slave_last_rx(bond, slave) - delta_in_ticks,
@@ -3080,7 +3080,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)* the bond has an IP address) */ trans_start =dev_trans_start (slave->dev); - if ((slave->state == BOND_STATE_ACTIVE) && + if (bond_is_active_slave(slave) && (!time_in_range(jiffies, trans_start - delta_in_ticks, trans_start + 2 * delta_in_ticks) ||
@@ -4144,7 +4144,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_devbond_for_each_slave_from (bond, slave, i, start_at) {if (IS_UP (slave->dev) && (slave->link ==BOND_LINK_UP ) && - (slave->state ==BOND_STATE_ACTIVE )) { +bond_is_active_slave (slave)) { res =bond_dev_queue_xmit (bond, skb, slave->dev);break ; }
@@ -4221,7 +4221,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)bond_for_each_slave_from (bond, slave, i, start_at) {if (IS_UP (slave->dev) && (slave->link ==BOND_LINK_UP ) && - (slave->state ==BOND_STATE_ACTIVE )) { +bond_is_active_slave (slave)) { res =bond_dev_queue_xmit (bond, skb, slave->dev);break ; }
@@ -4262,7 +4262,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)bond_for_each_slave_from (bond, slave, i, start_at) {if (IS_UP (slave->dev) && (slave->link ==BOND_LINK_UP ) && - (slave->state ==BOND_STATE_ACTIVE )) { +bond_is_active_slave (slave)) {if (tx_dev) {struct sk_buff *skb2 =skb_clone (skb,GFP_ATOMIC );if (!skb2) {
drivers/net/bonding/bond_sysfs.c +1 -1
@@ -1579,7 +1579,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, }bond_for_each_slave (bond, slave, i) { -if (slave->state ==BOND_STATE_BACKUP ) { +if (!bond_is_active_slave (slave)) {if (new_value) slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ;else
drivers/net/bonding/bonding.h +26 -5
@@ -55,7 +55,7 @@ (((slave)->dev->flags &IFF_UP ) && \netif_running ((slave)->dev) && \ ((slave)->link ==BOND_LINK_UP ) && \ - ((slave)->state == BOND_STATE_ACTIVE)) + bond_is_active_slave(slave))#define USES_PRIMARY (mode) \
@@ -192,7 +192,8 @@ struct slave {unsigned long last_arp_rx;s8 link;/* one of BOND_LINK_XXXX */ s8 new_link; -s8 state;/* one of BOND_STATE_XXXX */ +u8 backup;/* indicates backup slave. Value corresponds with +BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ u32 original_mtu;u32 link_failure_count;u8 perm_hwaddr[ETH_ALEN ];
@@ -304,6 +305,26 @@ static inline bool bond_is_lb(const struct bonding *bond) bond->params.mode == BOND_MODE_ALB); } +static inline void bond_set_active_slave (struct slave *slave) +{ + slave->backup =0 ; +} + +static inline void bond_set_backup_slave (struct slave *slave) +{ + slave->backup =1 ; +} + +static inline int bond_slave_state (struct slave *slave) +{ +return slave->backup; +} + +static inline bool bond_is_active_slave (struct slave *slave) +{ +return !bond_slave_state (slave); +} +#define BOND_PRI_RESELECT_ALWAYS 0#define BOND_PRI_RESELECT_BETTER 1#define BOND_PRI_RESELECT_FAILURE 2
@@ -321,7 +342,7 @@ static inline bool bond_is_lb(const struct bonding *bond)static inline int slave_do_arp_validate (struct bonding *bond,struct slave *slave) { -return bond->params.arp_validate & (1 << slave->state); +return bond->params.arp_validate & (1 <<bond_slave_state (slave)); } static inline unsigned long slave_last_rx(struct bonding *bond,
@@ -353,14 +374,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) {struct bonding *bond =netdev_priv (slave->dev->master);if (!bond_is_lb (bond)) - slave->state =BOND_STATE_BACKUP ; +bond_set_backup_slave (slave);if (!bond->params.all_slaves_active) slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; }static inline void bond_set_slave_active_flags (struct slave *slave) { - slave->state =BOND_STATE_ACTIVE ; +bond_set_active_slave (slave); slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; }
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 4/6] bonding: wrap slave state work
From: Jiri Pirko <[email protected]>
Date: Sat, 12 Mar 2011 14:14:37 +0100
Quoted 5 lines
transfers
slave->stateintoslave->backup(that it's going to transfer into bitfield. Introduce wrapper inlines to do the work with it.Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>
Applied.
PATCH 5/6 bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
In reply to Jiri PirkoSince bond-related code was moved from net/core/dev.c into bonding, IFF_SLAVE_INACTIVE is no longer needed. Replace is with flag "inactive" stored in slave structure
--- drivers/net/bonding/bond_main.c | 6 ++---- drivers/net/bonding/bond_sysfs.c | 4 ++-- drivers/net/bonding/bonding.h | 14 ++++++++++---- include/linux/if.h | 19 +++++++++---------- 4 files changed, 23 insertions(+), 20 deletions(-)
drivers/net/bonding/bond_main.c +2 -4
@@ -1461,7 +1461,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, struct slave *slave, struct bonding *bond) { -if (slave->dev->priv_flags &IFF_SLAVE_INACTIVE ) { + if (bond_is_slave_inactive(slave)) { if (slave_do_arp_validate(bond, slave) && skb->protocol == __cpu_to_be16(ETH_P_ARP)) return false;
@@ -2122,7 +2122,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)dev_set_mtu (slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_BONDING ); + slave_dev->priv_flags &= ~IFF_BONDING ;kfree (slave);
@@ -2233,8 +2233,6 @@ static int bond_release_all(struct net_device *bond_dev)dev_set_mac_address (slave_dev, &addr); } - slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; -kfree (slave);/* re-acquire the lock before getting the next slave */
drivers/net/bonding/bond_sysfs.c +2 -2
@@ -1581,9 +1581,9 @@ static ssize_t bonding_store_slaves_active(struct device *d,bond_for_each_slave (bond, slave, i) {if (!bond_is_active_slave (slave)) {if (new_value) - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; + slave->inactive =0 ;else - slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; + slave->inactive =1 ; } } out:
drivers/net/bonding/bonding.h +10 -4
@@ -192,8 +192,9 @@ struct slave {unsigned long last_arp_rx;s8 link;/* one of BOND_LINK_XXXX */ s8 new_link; -u8 backup;/* indicates backup slave. Value corresponds with -BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + u8 backup:1, /* indicates backup slave. Value corresponds with +BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + inactive:1; /* indicates inactive slave */u32 original_mtu;u32 link_failure_count;u8 perm_hwaddr[ETH_ALEN ];
@@ -376,13 +377,18 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave)if (!bond_is_lb (bond))bond_set_backup_slave (slave);if (!bond->params.all_slaves_active) - slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; + slave->inactive =1 ; }static inline void bond_set_slave_active_flags (struct slave *slave) {bond_set_active_slave (slave); - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; + slave->inactive =0 ; +} + +static inline bool bond_is_slave_inactive (struct slave *slave) +{ +return slave->inactive; }struct vlan_entry *bond_next_vlan (struct bonding *bond,struct vlan_entry *curr);
include/linux/if.h +9 -10
@@ -59,18 +59,17 @@/* Private (from user) interface flags (netdevice->priv_flags). */ #define IFF_802_1Q_VLAN 0x1/* 802.1Q VLAN device. */ #define IFF_EBRIDGE 0x2/* Ethernet bridging device. */ -#define IFF_SLAVE_INACTIVE 0x4/* bonding slave not the curr. active */ -#define IFF_BONDING 0x8/* bonding master or slave */ -#define IFF_ISATAP 0x10/* ISATAP interface (RFC4214) */ -#define IFF_WAN_HDLC 0x20/* WAN HDLC device */ -#define IFF_XMIT_DST_RELEASE 0x40/* dev_hard_start_xmit() is allowed to +#define IFF_BONDING 0x4/* bonding master or slave */ +#define IFF_ISATAP 0x8/* ISATAP interface (RFC4214) */ +#define IFF_WAN_HDLC 0x10/* WAN HDLC device */ +#define IFF_XMIT_DST_RELEASE 0x20/* dev_hard_start_xmit() is allowed to * release skb->dst */ -#define IFF_DONT_BRIDGE 0x80/* disallow bridging this ether dev */ -#define IFF_DISABLE_NETPOLL 0x100/* disable netpoll at run-time */ -#define IFF_MACVLAN_PORT 0x200/* device used as macvlan port */ -#define IFF_BRIDGE_PORT 0x400/* device used as bridge port */ -#define IFF_OVS_DATAPATH 0x800/* device used as Open vSwitch +#define IFF_DONT_BRIDGE 0x40/* disallow bridging this ether dev */ +#define IFF_DISABLE_NETPOLL 0x80/* disable netpoll at run-time */ +#define IFF_MACVLAN_PORT 0x100/* device used as macvlan port */ +#define IFF_BRIDGE_PORT 0x200/* device used as bridge port */ +#define IFF_OVS_DATAPATH 0x400/* device used as Open vSwitch * datapath port */ #define IF_GET_IFACE 0x0001/* for querying only */
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
Quoted 4 lines · Jiri Pirko
Since bond-related code was moved from
net/core/dev.cinto bonding,IFF_SLAVE_INACTIVEis no longer needed. Replace is with flag "inactive" stored in slave structure
Good work, Jiri!
IFF_ flags are valuable and are going to be exhausted, moving these slave-specific flags to struct slave is indeed good.
Thanks.
PATCH v2 5/6 bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
In reply to Jiri PirkoSince bond-related code was moved from net/core/dev.c into bonding, IFF_SLAVE_INACTIVE is no longer needed. Replace is with flag "inactive" stored in slave structure
--- drivers/net/bonding/bond_main.c | 6 ++---- drivers/net/bonding/bond_sysfs.c | 4 ++-- drivers/net/bonding/bonding.h | 14 ++++++++++---- 3 files changed, 14 insertions(+), 10 deletions(-)
drivers/net/bonding/bond_main.c +2 -4
@@ -1461,7 +1461,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, struct slave *slave, struct bonding *bond) { -if (slave->dev->priv_flags &IFF_SLAVE_INACTIVE ) { + if (bond_is_slave_inactive(slave)) { if (slave_do_arp_validate(bond, slave) && skb->protocol == __cpu_to_be16(ETH_P_ARP)) return false;
@@ -2122,7 +2122,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)dev_set_mtu (slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE |IFF_BONDING ); + slave_dev->priv_flags &= ~IFF_BONDING ;kfree (slave);
@@ -2233,8 +2233,6 @@ static int bond_release_all(struct net_device *bond_dev)dev_set_mac_address (slave_dev, &addr); } - slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; -kfree (slave);/* re-acquire the lock before getting the next slave */
drivers/net/bonding/bond_sysfs.c +2 -2
@@ -1581,9 +1581,9 @@ static ssize_t bonding_store_slaves_active(struct device *d,bond_for_each_slave (bond, slave, i) {if (!bond_is_active_slave (slave)) {if (new_value) - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; + slave->inactive =0 ;else - slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; + slave->inactive =1 ; } } out:
drivers/net/bonding/bonding.h +10 -4
@@ -192,8 +192,9 @@ struct slave {unsigned long last_arp_rx;s8 link;/* one of BOND_LINK_XXXX */ s8 new_link; -u8 backup;/* indicates backup slave. Value corresponds with -BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + u8 backup:1, /* indicates backup slave. Value corresponds with +BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + inactive:1; /* indicates inactive slave */u32 original_mtu;u32 link_failure_count;u8 perm_hwaddr[ETH_ALEN ];
@@ -376,13 +377,18 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave)if (!bond_is_lb (bond))bond_set_backup_slave (slave);if (!bond->params.all_slaves_active) - slave->dev->priv_flags |=IFF_SLAVE_INACTIVE ; + slave->inactive =1 ; }static inline void bond_set_slave_active_flags (struct slave *slave) {bond_set_active_slave (slave); - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE ; + slave->inactive =0 ; +} + +static inline bool bond_is_slave_inactive (struct slave *slave) +{ +return slave->inactive; }struct vlan_entry *bond_next_vlan (struct bonding *bond,struct vlan_entry *curr);
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 5/6 v2] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
From: Jiri Pirko <[email protected]>
Date: Wed, 16 Mar 2011 19:46:43 +0100
Quoted 6 lines
Since bond-related code was moved from
net/core/dev.cinto bonding,IFF_SLAVE_INACTIVEis no longer needed. Replace is with flag "inactive" stored in slave structureSigned-off-by Jiri Pirko <[email protected]>Reviewed-by Nicolas de Pesloüan <[email protected]>
Applied.
PATCH 6/6 net: introduce rx_handler results and logic around that
In reply to Jiri PirkoThis patch allows rx_handlers to better signalize what to do next to it's caller. That makes skb->deliver_no_wcard no longer needed.
kernel-doc for rx_handler_result is taken from Nicolas' patch.
--- drivers/net/bonding/bond_main.c | 22 +++++++++------- drivers/net/macvlan.c | 11 ++++---- include/linux/netdevice.h | 50 ++++++++++++++++++++++++++++++++++++++- include/linux/skbuff.h | 5 +--- net/bridge/br_input.c | 25 +++++++++++------- net/bridge/br_private.h | 2 +- net/core/dev.c | 21 +++++++++++----- net/core/skbuff.c | 1 - 8 files changed, 98 insertions(+), 39 deletions(-)
drivers/net/bonding/bond_main.c +12 -10
@@ -1480,20 +1480,23 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb,return false; } -static struct sk_buff *bond_handle_frame (struct sk_buff *skb) +static rx_handler_result_t bond_handle_frame (struct sk_buff **pskb) { +struct sk_buff *skb = *pskb;struct slave *slave;struct net_device *bond_dev;struct bonding *bond; - skb =skb_share_check (skb,GFP_ATOMIC ); -if (unlikely (!skb)) -return NULL ; - slave =bond_slave_get_rcu (skb->dev); bond_dev =ACCESS_ONCE (slave->dev->master);if (unlikely (!bond_dev)) -return skb; +return RX_HANDLER_PASS ; + + skb =skb_share_check (skb,GFP_ATOMIC ); +if (unlikely (!skb)) +return RX_HANDLER_CONSUMED ; + + *pskb = skb; bond =netdev_priv (bond_dev);
@@ -1501,8 +1504,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) slave->dev->last_rx = jiffies;if (bond_should_deliver_exact_match (skb, slave, bond)) { - skb->deliver_no_wcard =1 ; -return skb; +return RX_HANDLER_EXACT ; } skb->dev = bond_dev;
@@ -1514,12 +1516,12 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)if (unlikely (skb_cow_head (skb, skb->data -skb_mac_header (skb)))) {kfree_skb (skb); -return NULL ; +return RX_HANDLER_CONSUMED ; }memcpy (eth_hdr (skb)->h_dest, bond_dev->dev_addr,ETH_ALEN ); } -return skb; +return RX_HANDLER_ANOTHER ; }/* enslave device <slave> to bond device <master> */
drivers/net/macvlan.c +6 -5
@@ -152,9 +152,10 @@ static void macvlan_broadcast(struct sk_buff *skb, }/* called under rcu_read_lock() from netif_receive_skb */ -static struct sk_buff *macvlan_handle_frame (struct sk_buff *skb) +static rx_handler_result_t macvlan_handle_frame (struct sk_buff **pskb) {struct macvlan_port *port; +struct sk_buff *skb = *pskb;const struct ethhdr *eth =eth_hdr (skb);const struct macvlan_dev *vlan;const struct macvlan_dev *src;
@@ -184,7 +185,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb)*/ macvlan_broadcast (skb, port, src->dev,MACVLAN_MODE_VEPA ); -return skb; +return RX_HANDLER_PASS ; }if (port->passthru)
@@ -192,12 +193,12 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb)else vlan =macvlan_hash_lookup (port, eth->h_dest);if (vlan ==NULL ) -return skb; +return RX_HANDLER_PASS ; dev = vlan->dev;if (unlikely (!(dev->flags &IFF_UP ))) {kfree_skb (skb); -return NULL ; +return RX_HANDLER_CONSUMED ; } len = skb->len +ETH_HLEN ; skb =skb_share_check (skb,GFP_ATOMIC );
@@ -211,7 +212,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) out:macvlan_count_rx (vlan, len, ret ==NET_RX_SUCCESS ,0 ); -return NULL ; +return RX_HANDLER_CONSUMED ; }static int macvlan_queue_xmit (struct sk_buff *skb,struct net_device *dev)
include/linux/netdevice.h +49 -1
56 lines not on this page · raw message
include/linux/skbuff.h +1 -4
@@ -388,10 +388,7 @@ struct sk_buff {kmemcheck_bitfield_begin (flags2); __u16 queue_mapping:16;#ifdef CONFIG_IPV6_NDISC_NODETYPE - __u8 ndisc_nodetype:2, - deliver_no_wcard:1; -#else - __u8 deliver_no_wcard:1; + __u8 ndisc_nodetype:2;#endif __u8 ooo_okay:1;kmemcheck_bitfield_end (flags2);
net/bridge/br_input.c +15 -10
@@ -139,21 +139,22 @@ static inline int is_link_local(const unsigned char *dest)* Return NULL if skb is handled * note: already called with rcu_read_lock */ -struct sk_buff *br_handle_frame (struct sk_buff *skb) +rx_handler_result_t br_handle_frame (struct sk_buff **pskb) {struct net_bridge_port *p; +struct sk_buff *skb = *pskb;const unsigned char *dest =eth_hdr (skb)->h_dest;br_should_route_hook_t *rhook;if (unlikely (skb->pkt_type ==PACKET_LOOPBACK )) -return skb; +return RX_HANDLER_PASS ;if (!is_valid_ether_addr (eth_hdr (skb)->h_source)) goto drop; skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) -return NULL ; +return RX_HANDLER_CONSUMED ; p =br_port_get_rcu (skb->dev);
@@ -167,10 +168,12 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb) goto forward;if (NF_HOOK (NFPROTO_BRIDGE ,NF_BR_LOCAL_IN , skb, skb->dev, -NULL , br_handle_local_finish)) -return NULL ;/* frame consumed by filter */ -else -return skb;/* continue processing */ +NULL , br_handle_local_finish)) { +return RX_HANDLER_CONSUMED ;/* consumed by filter */ + }else { + *pskb = skb; +return RX_HANDLER_PASS ;/* continue processing */ + } } forward:
@@ -178,8 +181,10 @@ forward:case BR_STATE_FORWARDING : rhook =rcu_dereference (br_should_route_hook);if (rhook) { -if ((*rhook)(skb)) -return skb; +if ((*rhook)(skb)) { + *pskb = skb; +return RX_HANDLER_PASS ; + } dest =eth_hdr (skb)->h_dest; }/* fall through */
@@ -194,5 +199,5 @@ forward: drop:kfree_skb (skb); } -return NULL ; +return RX_HANDLER_CONSUMED ; }
net/bridge/br_private.h +1 -1
@@ -379,7 +379,7 @@ extern void br_features_recompute(struct net_bridge *br);/* br_input.c */ extern int br_handle_frame_finish (struct sk_buff *skb); -extern struct sk_buff *br_handle_frame (struct sk_buff *skb); +extern rx_handler_result_t br_handle_frame (struct sk_buff **pskb);/* br_ioctl.c */ extern int br_dev_ioctl (struct net_device *dev,struct ifreq *rq,int cmd);
net/core/dev.c +14 -7
@@ -3062,6 +3062,8 @@ out:* on a failure. * * The caller must hold the rtnl_mutex. +* +* For a general description of rx_handler, see enum rx_handler_result. */ int netdev_rx_handler_register(struct net_device *dev, rx_handler_func_t *rx_handler,
@@ -3121,6 +3123,7 @@ static int __netif_receive_skb(struct sk_buff *skb)rx_handler_func_t *rx_handler;struct net_device *orig_dev;struct net_device *null_or_dev; +bool deliver_exact = false;int ret =NET_RX_DROP ;__be16 type;
@@ -3173,18 +3176,22 @@ ncls: rx_handler =rcu_dereference (skb->dev->rx_handler);if (rx_handler) { -struct net_device *prev_dev; -if (pt_prev) { ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev =NULL ; } - prev_dev = skb->dev; - skb =rx_handler (skb); -if (!skb) +switch (rx_handler (&skb)) { +case RX_HANDLER_CONSUMED : goto out; -if (skb->dev != prev_dev) +case RX_HANDLER_ANOTHER : goto another_round; +case RX_HANDLER_EXACT : + deliver_exact = true; +case RX_HANDLER_PASS : +break ; +default : +BUG (); + } }if (vlan_tx_tag_present (skb)) {
@@ -3202,7 +3209,7 @@ ncls:vlan_on_bond_hook (skb);/* deliver only exact match when indicated */ - null_or_dev = skb->deliver_no_wcard ? skb->dev :NULL ; + null_or_dev = deliver_exact ? skb->dev :NULL ; type = skb->protocol; list_for_each_entry_rcu(ptype,
net/core/skbuff.c +0 -1
@@ -523,7 +523,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->ip_summed = old->ip_summed;skb_copy_queue_mapping (new, old); new->priority = old->priority; - new->deliver_no_wcard = old->deliver_no_wcard;#if defined(CONFIG_IP_VS ) || defined(CONFIG_IP_VS_MODULE ) new->ipvs_property = old->ipvs_property;#endif
Signature · 1 line
1.7.4
Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
Quoted 7 lines · Jiri Pirko
This patch allows
rx_handlersto better signalize what to do next to it's caller. That makesskb->deliver_no_wcardno longer needed.kernel-doc for
rx_handler_resultis taken from Nicolas' patch.Signed-off-by Jiri Pirko<[email protected]>eviewed-by Nicolas de Pesloüan<[email protected]>
Typo in [R]eviewed-by and missing space between Pesloüan and <nicolas.
Nicolas.
Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
Quoted 4 lines · Nicolas de Pesloüan
Quoted 3 lines · Jiri Pirko
This patch allows
rx_handlersto better signalize what to do next to it's caller. That makesskb->deliver_no_wcardno longer needed.
Quoted 8 lines
Quoted 4 lines
kernel-doc for
rx_handler_resultis taken from Nicolas' patch.Signed-off-by Jiri Pirko<[email protected]>eviewed-by Nicolas de Pesloüan<[email protected]>Typo in [R]eviewed-by and missing space between Pesloüan and <nicolas.
Nicolas.
Only the missing R in Reviewed-by:. The space was removed by my mail client, sorry.
Nicolas.
Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
Quoted 7 lines · Sat, Mar 12, 2011 at 02:25:39PM CET, [email protected] wrote:
Quoted 6 lines · Nicolas de Pesloüan
Quoted 5 lines · Jiri Pirko
This patch allows
rx_handlersto better signalize what to do next to it's caller. That makesskb->deliver_no_wcardno longer needed.kernel-doc for
rx_handler_resultis taken from Nicolas' patch.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Jiri Pirko<[email protected]>eviewed-by Nicolas de Pesloüan<[email protected]>Typo in [R]eviewed-by and missing space between Pesloüan and <nicolas.
Nicolas.
Only the missing R in Reviewed-by:. The space was removed by my mail client, sorry.
Copypaste err :( Sorry..
Dave would you please add "R" before you apply. Many thanks.
Jirka
Quoted 3 lines
Nicolas.
Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
From: Jiri Pirko <[email protected]>
Date: Sat, 12 Mar 2011 14:36:44 +0100
Quoted 13 lines
Quoted 12 lines · Sat, Mar 12, 2011 at 02:25:39PM CET, [email protected] wrote:
Quoted 11 lines · Nicolas de Pesloüan
Quoted 7 lines · Jiri Pirko
This patch allows
rx_handlersto better signalize what to do next to it's caller. That makesskb->deliver_no_wcardno longer needed.kernel-doc for
rx_handler_resultis taken from Nicolas' patch.Signed-off-by Jiri Pirko<[email protected]>eviewed-by Nicolas de Pesloüan<[email protected]>Typo in [R]eviewed-by and missing space between Pesloüan and <nicolas.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Nicolas.
Only the missing R in Reviewed-by:. The space was removed by my mail client, sorry.
Copypaste err :( Sorry..
Dave would you please add "R" before you apply. Many thanks.
I will, thanks.
Applied.