netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost)
@ 2011-03-12 13:14 Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

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(-)

-- 
1.7.4


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-13 23:52   ` Changli Gao
  2011-03-12 13:14 ` [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler Jiri Pirko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

Since skb_iif has the desired value (ifindex of physical device actually
received the traffic) use that instead.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Changli Gao <xiaosuo@gmail.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 net/packet/af_packet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index b5362e9..714383c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -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;
 
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-16 19:52   ` David Miller
  2011-03-12 13:14 ` [patch net-next-2.6 3/6] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

Register 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.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 drivers/net/bonding/bond_main.c |   17 +++++++++++------
 drivers/net/bonding/bonding.h   |    3 +++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 68a5ce0..29f69da 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index c4e2343..ff9af31 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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
  *
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 3/6] net: get rid of multiple bond-related netdevice->priv_flags
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-16 18:45   ` [patch net-next-2.6 3/6 v2] " Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 4/6] bonding: wrap slave state work Jiri Pirko
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

Now 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.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 29f69da..3c6ac2f 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 72bb0f6..05e0ae5 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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 =
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ff9af31..049619f 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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);
diff --git a/include/linux/if.h b/include/linux/if.h
index 3bc63e6..2fdd47a 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -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 */
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 4/6] bonding: wrap slave state work
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
                   ` (2 preceding siblings ...)
  2011-03-12 13:14 ` [patch net-next-2.6 3/6] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-16 19:52   ` David Miller
  2011-03-12 13:14 ` [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that Jiri Pirko
  5 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

transfers slave->state into slave->backup (that it's going to transfer
into bitfield. Introduce wrapper inlines to do the work with it.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 1024ae1..047af0b 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -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);
 }
 
 /**
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3c6ac2f..c5f3a01 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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 pack
 	memcpy(&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_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;
 		}
@@ -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) {
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 05e0ae5..344d23f 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 049619f..63e9cf7 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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;
 }
 
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
                   ` (3 preceding siblings ...)
  2011-03-12 13:14 ` [patch net-next-2.6 4/6] bonding: wrap slave state work Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-14  5:29   ` WANG Cong
  2011-03-16 18:46   ` [patch net-next-2.6 5/6 v2] " Jiri Pirko
  2011-03-12 13:14 ` [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that Jiri Pirko
  5 siblings, 2 replies; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

Since 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

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c5f3a01..c3150df 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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 */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 344d23f..5161183 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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:
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 63e9cf7..6b26962 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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);
diff --git a/include/linux/if.h b/include/linux/if.h
index 2fdd47a..0da7991 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -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 */
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
  2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
                   ` (4 preceding siblings ...)
  2011-03-12 13:14 ` [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko
@ 2011-03-12 13:14 ` Jiri Pirko
  2011-03-12 13:24   ` Nicolas de Pesloüan
  5 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

This 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.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
eviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c3150df..fdba1a1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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> */
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 6ed577b..ead9a8f 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -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)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6bd5d46..6275a95 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -390,7 +390,55 @@ enum gro_result {
 };
 typedef enum gro_result gro_result_t;
 
-typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb);
+/*
+ * enum rx_handler_result - Possible return values for rx_handlers.
+ * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it
+ * further.
+ * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in
+ * case skb->dev was changed by rx_handler.
+ * @RX_HANDLER_EXACT: Force exact delivery, no wildcard.
+ * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called.
+ *
+ * rx_handlers are functions called from inside __netif_receive_skb(), to do
+ * special processing of the skb, prior to delivery to protocol handlers.
+ *
+ * Currently, a net_device can only have a single rx_handler registered. Trying
+ * to register a second rx_handler will return -EBUSY.
+ *
+ * To register a rx_handler on a net_device, use netdev_rx_handler_register().
+ * To unregister a rx_handler on a net_device, use
+ * netdev_rx_handler_unregister().
+ *
+ * Upon return, rx_handler is expected to tell __netif_receive_skb() what to
+ * do with the skb.
+ *
+ * If the rx_handler consumed to skb in some way, it should return
+ * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for
+ * the skb to be delivered in some other ways.
+ *
+ * If the rx_handler changed skb->dev, to divert the skb to another
+ * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the
+ * new device will be called if it exists.
+ *
+ * If the rx_handler consider the skb should be ignored, it should return
+ * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that
+ * are registred on exact device (ptype->dev == skb->dev).
+ *
+ * If the rx_handler didn't changed skb->dev, but want the skb to be normally
+ * delivered, it should return RX_HANDLER_PASS.
+ *
+ * A device without a registered rx_handler will behave as if rx_handler
+ * returned RX_HANDLER_PASS.
+ */
+
+enum rx_handler_result {
+	RX_HANDLER_CONSUMED,
+	RX_HANDLER_ANOTHER,
+	RX_HANDLER_EXACT,
+	RX_HANDLER_PASS,
+};
+typedef enum rx_handler_result rx_handler_result_t;
+typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
 
 extern void __napi_schedule(struct napi_struct *n);
 
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 31f02d0..24cfa62 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -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);
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 88e4aa9..e216079 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -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;
 }
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index f7afc36..19e2f46 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -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);
diff --git a/net/core/dev.c b/net/core/dev.c
index 9f66de9..329e670 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1eb526a..801dd08 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -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
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
  2011-03-12 13:14 ` [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that Jiri Pirko
@ 2011-03-12 13:24   ` Nicolas de Pesloüan
  2011-03-12 13:25     ` Nicolas de Pesloüan
  0 siblings, 1 reply; 23+ messages in thread
From: Nicolas de Pesloüan @ 2011-03-12 13:24 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy,
	xiaosuo

Le 12/03/2011 14:14, Jiri Pirko a écrit :
> This 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.
>
> Signed-off-by: Jiri Pirko<jpirko@redhat.com>
> eviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr>

Typo in [R]eviewed-by and missing space between Pesloüan and <nicolas.

	Nicolas.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
  2011-03-12 13:24   ` Nicolas de Pesloüan
@ 2011-03-12 13:25     ` Nicolas de Pesloüan
  2011-03-12 13:36       ` Jiri Pirko
  0 siblings, 1 reply; 23+ messages in thread
From: Nicolas de Pesloüan @ 2011-03-12 13:25 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy,
	xiaosuo

Le 12/03/2011 14:24, Nicolas de Pesloüan a écrit :
> Le 12/03/2011 14:14, Jiri Pirko a écrit :
>> This 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.
>>
>> Signed-off-by: Jiri Pirko<jpirko@redhat.com>
>> eviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr>
>
> 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.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
  2011-03-12 13:25     ` Nicolas de Pesloüan
@ 2011-03-12 13:36       ` Jiri Pirko
  2011-03-16 19:53         ` David Miller
  0 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-12 13:36 UTC (permalink / raw)
  To: Nicolas de Pesloüan; +Cc: netdev, davem

Sat, Mar 12, 2011 at 02:25:39PM CET, nicolas.2p.debian@gmail.com wrote:
>Le 12/03/2011 14:24, Nicolas de Pesloüan a écrit :
>>Le 12/03/2011 14:14, Jiri Pirko a écrit :
>>>This 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.
>>>
>>>Signed-off-by: Jiri Pirko<jpirko@redhat.com>
>>>eviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr>
>>
>>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
>
>	Nicolas.
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-12 13:14 ` [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko
@ 2011-03-13 23:52   ` Changli Gao
  2011-03-14  6:54     ` Jiri Pirko
  0 siblings, 1 reply; 23+ messages in thread
From: Changli Gao @ 2011-03-13 23:52 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet,
	nicolas.2p.debian, andy

On Sat, Mar 12, 2011 at 9:14 PM, Jiri Pirko <jpirko@redhat.com> wrote:
> Since skb_iif has the desired value (ifindex of physical device actually
> received the traffic) use that instead.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Reviewed-by: Changli Gao <xiaosuo@gmail.com>
> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
> ---

This may "break" the ptype handlers in TX path, as we always assign
skb->dev to origdev there. Thanks.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
  2011-03-12 13:14 ` [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko
@ 2011-03-14  5:29   ` WANG Cong
  2011-03-16 18:46   ` [patch net-next-2.6 5/6 v2] " Jiri Pirko
  1 sibling, 0 replies; 23+ messages in thread
From: WANG Cong @ 2011-03-14  5:29 UTC (permalink / raw)
  To: netdev

On Sat, 12 Mar 2011 14:14:38 +0100, Jiri Pirko wrote:

> Since 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
> 

Good work, Jiri!

IFF_ flags are valuable and are going to be exhausted, moving
these slave-specific flags to struct slave is indeed good.

Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>

Thanks.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-13 23:52   ` Changli Gao
@ 2011-03-14  6:54     ` Jiri Pirko
  2011-03-14  6:59       ` Changli Gao
  0 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-14  6:54 UTC (permalink / raw)
  To: Changli Gao
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet,
	nicolas.2p.debian, andy

Mon, Mar 14, 2011 at 12:52:37AM CET, xiaosuo@gmail.com wrote:
>On Sat, Mar 12, 2011 at 9:14 PM, Jiri Pirko <jpirko@redhat.com> wrote:
>> Since skb_iif has the desired value (ifindex of physical device actually
>> received the traffic) use that instead.
>>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>> Reviewed-by: Changli Gao <xiaosuo@gmail.com>
>> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
>> ---
>
>This may "break" the ptype handlers in TX path, as we always assign
>skb->dev to origdev there. Thanks.

Changli, would you please point me the relevant code?. Thanks!

Jirka
>
>-- 
>Regards,
>Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-14  6:54     ` Jiri Pirko
@ 2011-03-14  6:59       ` Changli Gao
  2011-03-14  7:43         ` Jiri Pirko
  0 siblings, 1 reply; 23+ messages in thread
From: Changli Gao @ 2011-03-14  6:59 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet,
	nicolas.2p.debian, andy

On Mon, Mar 14, 2011 at 2:54 PM, Jiri Pirko <jpirko@redhat.com> wrote:
> Mon, Mar 14, 2011 at 12:52:37AM CET, xiaosuo@gmail.com wrote:
>>On Sat, Mar 12, 2011 at 9:14 PM, Jiri Pirko <jpirko@redhat.com> wrote:
>>> Since skb_iif has the desired value (ifindex of physical device actually
>>> received the traffic) use that instead.
>>>
>>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>>> Reviewed-by: Changli Gao <xiaosuo@gmail.com>
>>> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
>>> ---
>>
>>This may "break" the ptype handlers in TX path, as we always assign
>>skb->dev to 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 }

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-14  6:59       ` Changli Gao
@ 2011-03-14  7:43         ` Jiri Pirko
  2011-03-14 15:10           ` Changli Gao
  0 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-14  7:43 UTC (permalink / raw)
  To: Changli Gao
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet,
	nicolas.2p.debian, andy

Mon, Mar 14, 2011 at 07:59:39AM CET, xiaosuo@gmail.com wrote:
>On Mon, Mar 14, 2011 at 2:54 PM, Jiri Pirko <jpirko@redhat.com> wrote:
>> Mon, Mar 14, 2011 at 12:52:37AM CET, xiaosuo@gmail.com wrote:
>>>On Sat, Mar 12, 2011 at 9:14 PM, Jiri Pirko <jpirko@redhat.com> wrote:
>>>> Since skb_iif has the desired value (ifindex of physical device actually
>>>> received the traffic) use that instead.
>>>>
>>>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>>>> Reviewed-by: Changli Gao <xiaosuo@gmail.com>
>>>> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
>>>> ---
>>>
>>>This may "break" the ptype handlers in TX path, as we always assign
>>>skb->dev to 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 }

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

>
>-- 
>Regards,
>Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex
  2011-03-14  7:43         ` Jiri Pirko
@ 2011-03-14 15:10           ` Changli Gao
  0 siblings, 0 replies; 23+ messages in thread
From: Changli Gao @ 2011-03-14 15:10 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet,
	nicolas.2p.debian, andy

On Mon, Mar 14, 2011 at 3:43 PM, Jiri Pirko <jpirko@redhat.com> wrote:
> Mon, Mar 14, 2011 at 07:59:39AM CET, xiaosuo@gmail.com wrote:
>>>
>>
>>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 }
>
> 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
>

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.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 3/6 v2] net: get rid of multiple bond-related netdevice->priv_flags
  2011-03-12 13:14 ` [patch net-next-2.6 3/6] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko
@ 2011-03-16 18:45   ` Jiri Pirko
  2011-03-16 19:52     ` David Miller
  0 siblings, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-16 18:45 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

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.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 29f69da..3c6ac2f 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 72bb0f6..05e0ae5 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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 =
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ff9af31..049619f 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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);
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [patch net-next-2.6 5/6 v2] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
  2011-03-12 13:14 ` [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko
  2011-03-14  5:29   ` WANG Cong
@ 2011-03-16 18:46   ` Jiri Pirko
  2011-03-16 19:52     ` David Miller
  1 sibling, 1 reply; 23+ messages in thread
From: Jiri Pirko @ 2011-03-16 18:46 UTC (permalink / raw)
  To: netdev
  Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

Since 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

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 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(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c5f3a01..c3150df 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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 */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 344d23f..5161183 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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:
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 63e9cf7..6b26962 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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);
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler
  2011-03-12 13:14 ` [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler Jiri Pirko
@ 2011-03-16 19:52   ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2011-03-16 19:52 UTC (permalink / raw)
  To: jpirko
  Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 12 Mar 2011 14:14:35 +0100

> Register 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.
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 3/6 v2] net: get rid of multiple bond-related netdevice->priv_flags
  2011-03-16 18:45   ` [patch net-next-2.6 3/6 v2] " Jiri Pirko
@ 2011-03-16 19:52     ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2011-03-16 19:52 UTC (permalink / raw)
  To: jpirko
  Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 16 Mar 2011 19:45:23 +0100

> 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.
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 4/6] bonding: wrap slave state work
  2011-03-12 13:14 ` [patch net-next-2.6 4/6] bonding: wrap slave state work Jiri Pirko
@ 2011-03-16 19:52   ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2011-03-16 19:52 UTC (permalink / raw)
  To: jpirko
  Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 12 Mar 2011 14:14:37 +0100

> transfers slave->state into slave->backup (that it's going to transfer
> into bitfield. Introduce wrapper inlines to do the work with it.
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 5/6 v2] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
  2011-03-16 18:46   ` [patch net-next-2.6 5/6 v2] " Jiri Pirko
@ 2011-03-16 19:52     ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2011-03-16 19:52 UTC (permalink / raw)
  To: jpirko
  Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
	andy, xiaosuo

From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 16 Mar 2011 19:46:43 +0100

> Since 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
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that
  2011-03-12 13:36       ` Jiri Pirko
@ 2011-03-16 19:53         ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2011-03-16 19:53 UTC (permalink / raw)
  To: jpirko; +Cc: nicolas.2p.debian, netdev

From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 12 Mar 2011 14:36:44 +0100

> Sat, Mar 12, 2011 at 02:25:39PM CET, nicolas.2p.debian@gmail.com wrote:
>>Le 12/03/2011 14:24, Nicolas de Pesloüan a écrit :
>>>Le 12/03/2011 14:14, Jiri Pirko a écrit :
>>>>This 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.
>>>>
>>>>Signed-off-by: Jiri Pirko<jpirko@redhat.com>
>>>>eviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr>
>>>
>>>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.

I will, thanks.

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2011-03-16 19:52 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-12 13:14 [patch net-next-2.6 0/6] mostly bonding cleanups (partial repost) Jiri Pirko
2011-03-12 13:14 ` [patch net-next-2.6 1/6] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko
2011-03-13 23:52   ` Changli Gao
2011-03-14  6:54     ` Jiri Pirko
2011-03-14  6:59       ` Changli Gao
2011-03-14  7:43         ` Jiri Pirko
2011-03-14 15:10           ` Changli Gao
2011-03-12 13:14 ` [patch net-next-2.6 2/6] bonding: register slave pointer for rx_handler Jiri Pirko
2011-03-16 19:52   ` David Miller
2011-03-12 13:14 ` [patch net-next-2.6 3/6] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko
2011-03-16 18:45   ` [patch net-next-2.6 3/6 v2] " Jiri Pirko
2011-03-16 19:52     ` David Miller
2011-03-12 13:14 ` [patch net-next-2.6 4/6] bonding: wrap slave state work Jiri Pirko
2011-03-16 19:52   ` David Miller
2011-03-12 13:14 ` [patch net-next-2.6 5/6] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko
2011-03-14  5:29   ` WANG Cong
2011-03-16 18:46   ` [patch net-next-2.6 5/6 v2] " Jiri Pirko
2011-03-16 19:52     ` David Miller
2011-03-12 13:14 ` [patch net-next-2.6 6/6] net: introduce rx_handler results and logic around that Jiri Pirko
2011-03-12 13:24   ` Nicolas de Pesloüan
2011-03-12 13:25     ` Nicolas de Pesloüan
2011-03-12 13:36       ` Jiri Pirko
2011-03-16 19:53         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).