Skip to contentSkip to conversation

Any implementation of NETPOLL for bonding?

DISCUSSION Paul Smith 3 participants 8 messages Jun 15, 2009 – Jul 1, 2009 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Paul Smith

author
#0 lore raw

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

This is a big bummer for me :-).

Is there any possibility of NETPOLL being supported in the bonding driver? I found a very old patch set from Jeff Moyer (circa 2005) adding NETPOLL support to the bonding driver but as far as I can determine it's not present in current kernels.

Anything ever happen with this since then?

Cheers!

#1 lore raw
Quoted 6 lines · Paul Smith

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

This is a big bummer for me :-).

I did some work in the not-too-distant past on this and can probably dig-up the patches and port them to the latest upstream. Would you be able to test a patch?

Quoted 5 lines

Is there any possibility of NETPOLL being supported in the bonding driver? I found a very old patch set from Jeff Moyer (circa 2005) adding NETPOLL support to the bonding driver but as far as I can determine it's not present in current kernels.

It's a bit unclear to me why Jeff's patches were never accepted, but I suspect if there were many that didn't like them before, they won't be well received now, but it sure would be nice to use kgdb and use netconsole on bonding interfaces, wouldn't it? :-)

author
#2 lore raw
Quoted 8 lines · Andy Gospodarek
Quoted 3 lines · Paul Smith

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

I did some work in the not-too-distant past on this and can probably dig-up the patches and port them to the latest upstream. Would you be able to test a patch?

I can definitely test patches, but for my embedded systems I can't move past 2.6.27.x. I can make a stab at backporting whatever you have though.

Quoted 4 lines

It's a bit unclear to me why Jeff's patches were never accepted, but I suspect if there were many that didn't like them before, they won't be well received now, but it sure would be nice to use kgdb and use netconsole on bonding interfaces, wouldn't it? :-)

Yes, it so would :-).

I didn't see much objection to Jeff's patches. There was one email from Matt Mackall saying "Not really happy about how incestuous this makes the bonding driver with netpoll. I'll try to think more about it over the weekend." but there was no followup from Matt and I don't see a new set of patches by Jeff (although I might have just missed them).

#3 lore raw
Quoted 9 lines · Paul Smith
Quoted 8 lines · Andy Gospodarek
Quoted 3 lines · Paul Smith

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

I did some work in the not-too-distant past on this and can probably dig-up the patches and port them to the latest upstream. Would you be able to test a patch?

Hi Andy; did you have any time to dig these out and forward them to me? I'm happy to test them for you.

Thanks!

#4 lore raw
Quoted 7 lines · Paul Smith
Quoted 6 lines · Paul Smith
Quoted 5 lines · Andy Gospodarek
Quoted 3 lines · Paul Smith

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

I did some work in the not-too-distant past on this and can probably dig-up the patches and port them to the latest upstream.  Would you be able to test a patch?

Hi Andy; did you have any time to dig these out and forward them to me? I'm happy to test them for you.

Thanks!

I did, but they are in rough shape right now since they are so old (they don't apply at all).

I should be able to get them compiling and running by the end of the day today.

#6 lore raw
In reply to a message not in the archive
Quoted 10 lines · Bert Barbe

Hi,

We also ported netpoll to bonding for EL5 in kernel 2.6.18-92.1.22.0.1.el5

You can see the src rpm with the patch here:
http://oss.oracle.com/el5/SRPMS-updates/kernel-2.6.18-92.1.22.0.1.el5.src.rpm

Regards,
Bert

There certainly are some older bonding+netpoll patches lying around if you have a kernel based on something as old as RHEL5 (2.6.18-based).

Like this one, for example:

http://people.redhat.com/agospoda/rhel5/0075-bonding-add-netconsole-support.patch

#7 lore raw
In reply to Paul Smith
Quoted 7 lines · Paul Smith
Quoted 6 lines · Paul Smith
Quoted 5 lines · Andy Gospodarek
Quoted 3 lines · Paul Smith

I wanted to attach to my kernel with KGDBOE but failed because the bonding driver doesn't support NETPOLL, and the only network access to the system is over a bonded interface.

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

I did some work in the not-too-distant past on this and can probably dig-up the patches and port them to the latest upstream. Would you be able to test a patch?

Hi Andy; did you have any time to dig these out and forward them to me? I'm happy to test them for you.

Thanks!

Paul,

I finally had some time to get this going again. This is a patch against a Linus' latest tree.

It's still a little rough around the edges, so you need to make sure you

(1) start netconsole after your bond has all the slaves it's going to have

and

(2) rmmod netconsole before doing any operations on the bond itself (like taking it down or adding slaves).

I know what needs to be fixed, but I would rather see you get your debugging going than hold up the patch to fix those quirks. They definitely need to be fixed before this is even close to something that could be acceptable upstream, but at least we can work in parallel a little bit.

-andy

drivers/net/bonding/bond_main.c +80 -1
index d927f71..6304720 100644
@@ -75,6 +75,7 @@
 #include <linux/jiffies.h>
 #include <net/route.h>
 #include <net/net_namespace.h>
+#include <linux/netpoll.h>
 #include "bonding.h"
 #include "bond_3ad.h"
 #include "bond_alb.h"
@@ -415,7 +416,12 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
 	}
 
 	skb->priority = 1;
-	dev_queue_xmit(skb);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	if (bond->netpoll)
+		netpoll_send_skb(bond->netpoll, skb);
+	else
+#endif
+		dev_queue_xmit(skb);
 
 	return 0;
 }
@@ -1305,6 +1311,44 @@ static void bond_detach_slave(struct bonding *bond, struct slave *slave)
 	bond->slave_cnt--;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static int slaves_support_netpoll(struct net_device *bond_dev)
+{
+	struct bonding *bond = netdev_priv(bond_dev);
+	struct slave *slave;
+	int i;
+
+	bond_for_each_slave(bond, slave, i)
+		if (!slave->dev->netdev_ops->ndo_poll_controller)
+			return 0;
+	return 1;
+}
+
+static void bond_poll_controller(struct net_device *bond_dev)
+{
+	struct bonding *bond = netdev_priv(bond_dev);
+	struct slave *slave;
+	int i;
+
+	if (slaves_support_netpoll(bond_dev))
+		bond_for_each_slave(bond, slave, i)
+			netpoll_poll_dev(slave->dev);
+}
+
+static int bond_netpoll_setup(struct net_device *bond_dev,
+			      struct netpoll_info *npinfo)
+{
+	struct bonding *bond = netdev_priv(bond_dev);
+	struct slave *slave;
+	int i;
+
+	bond_for_each_slave(bond, slave, i)
+		if (slave->dev)
+			slave->dev->npinfo = npinfo;
+	return 0;
+}
+#endif
+
 /*---------------------------------- IOCTL ----------------------------------*/
 
 static int bond_sethwaddr(struct net_device *bond_dev,
@@ -1670,6 +1714,16 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 			bond->primary_slave = new_slave;
 	}
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	if (slaves_support_netpoll(bond_dev))
+		slave_dev->npinfo = bond_dev->npinfo;
+	else {
+		pr_err(DRV_NAME "New slave device %s does not support netpoll.\n",
+		       slave_dev->name);
+		pr_err(DRV_NAME "netpoll disabled for %s.\n", bond_dev->name);
+	}
+#endif
+
 	write_lock_bh(&bond->curr_slave_lock);
 
 	switch (bond->params.mode) {
@@ -1741,6 +1795,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 
 /* Undo stages on error */
 err_close:
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	if (slave_dev->npinfo)
+		slave_dev->npinfo = NULL;
+#endif
 	dev_close(slave_dev);
 
 err_unset_master:
@@ -1949,6 +2007,10 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 				   IFF_SLAVE_INACTIVE | IFF_BONDING |
 				   IFF_SLAVE_NEEDARP);
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	if (slave_dev->npinfo)
+		slave_dev->npinfo = NULL;
+#endif
 	kfree(slave);
 
 	return 0;  /* deletion OK */
@@ -4417,6 +4479,20 @@ out:
 	return 0;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+int bond_netpoll_start_xmit(struct netpoll *np, struct sk_buff *skb)
+{
+	struct bonding *bond = netdev_priv(skb->dev);
+	int ret;
+
+	bond->netpoll = np;
+	ret = bond->dev->netdev_ops->ndo_start_xmit(skb, bond->dev);
+	bond->netpoll = NULL;
+
+	return ret;
+}
+#endif
+
 /*------------------------- Device initialization ---------------------------*/
 
 static void bond_set_xmit_hash_policy(struct bonding *bond)
@@ -4530,6 +4606,9 @@ static const struct net_device_ops bond_netdev_ops = {
 	.ndo_change_mtu		= bond_change_mtu,
 	.ndo_set_mac_address 	= bond_set_mac_address,
 	.ndo_neigh_setup	= bond_neigh_setup,
+	.ndo_netpoll_setup	= bond_netpoll_setup,
+	.ndo_netpoll_start_xmit	= bond_netpoll_start_xmit,
+	.ndo_poll_controller	= bond_poll_controller,
 	.ndo_vlan_rx_register	= bond_vlan_rx_register,
 	.ndo_vlan_rx_add_vid 	= bond_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= bond_vlan_rx_kill_vid,
drivers/net/bonding/bonding.h +5 -0
index 6290a50..563d28c 100644
@@ -18,6 +18,7 @@
 #include <linux/timer.h>
 #include <linux/proc_fs.h>
 #include <linux/if_bonding.h>
+#include <linux/netpoll.h>
 #include <linux/kobject.h>
 #include <linux/in6.h>
 #include "bond_3ad.h"
@@ -222,6 +223,10 @@ struct bonding {
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	struct   in6_addr master_ipv6;
 #endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	struct   netpoll *netpoll;
+#endif
+
 };
 
 /**
include/linux/netdevice.h +5 -0
index d4a4d98..e1724b2 100644
@@ -52,6 +52,7 @@
 
 struct vlan_group;
 struct netpoll_info;
+struct netpoll;
 /* 802.11 specific */
 struct wireless_dev;
 					/* source back-compat hooks */
@@ -624,6 +625,10 @@ struct net_device_ops {
 						        unsigned short vid);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 #define HAVE_NETDEV_POLL
+	int                     (*ndo_netpoll_setup)(struct net_device *dev,
+						     struct netpoll_info *npinfo);
+	int			(*ndo_netpoll_start_xmit)(struct netpoll *np,
+							  struct sk_buff *skb);
 	void                    (*ndo_poll_controller)(struct net_device *dev);
 #endif
 #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
include/linux/netpoll.h +2 -0
index 2524267..39d42e4 100644
@@ -34,7 +34,9 @@ struct netpoll_info {
 };
 
 void netpoll_poll(struct netpoll *np);
+void netpoll_poll_dev(struct net_device *dev);
 void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
+void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
 void netpoll_print_options(struct netpoll *np);
 int netpoll_parse_options(struct netpoll *np, char *opt);
 int netpoll_setup(struct netpoll *np);
net/core/netpoll.c +17 -5
index 9675f31..3776b26 100644
@@ -174,9 +174,8 @@ static void service_arp_queue(struct netpoll_info *npi)
 	}
 }
 
-void netpoll_poll(struct netpoll *np)
+void netpoll_poll_dev(struct net_device *dev)
 {
-	struct net_device *dev = np->dev;
 	const struct net_device_ops *ops;
 
 	if (!dev || !netif_running(dev))
@@ -196,6 +195,11 @@ void netpoll_poll(struct netpoll *np)
 	zap_completion_queue();
 }
 
+void netpoll_poll(struct netpoll *np)
+{
+	netpoll_poll_dev(np->dev);
+}
+
 static void refill_skbs(void)
 {
 	struct sk_buff *skb;
@@ -277,11 +281,11 @@ static int netpoll_owner_active(struct net_device *dev)
 	return 0;
 }
 
-static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
+void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
 	int status = NETDEV_TX_BUSY;
 	unsigned long tries;
-	struct net_device *dev = np->dev;
+	struct net_device *dev = skb->dev;
 	const struct net_device_ops *ops = dev->netdev_ops;
 	struct netpoll_info *npinfo = np->dev->npinfo;
 
@@ -303,7 +307,10 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 		     tries > 0; --tries) {
 			if (__netif_tx_trylock(txq)) {
 				if (!netif_tx_queue_stopped(txq)) {
-					status = ops->ndo_start_xmit(skb, dev);
+					if (ops->ndo_netpoll_start_xmit)
+						status = ops->ndo_netpoll_start_xmit(np,skb);
+					else
+						status = ops->ndo_start_xmit(skb, dev);
 					if (status == NETDEV_TX_OK)
 						txq_trans_update(txq);
 				}
@@ -789,6 +796,9 @@ int netpoll_setup(struct netpoll *np)
 	/* avoid racing with NAPI reading npinfo */
 	synchronize_rcu();
 
+	if (ndev->netdev_ops->ndo_netpoll_setup)
+		ndev->netdev_ops->ndo_netpoll_setup(ndev, npinfo);
+
 	return 0;
 
  release:
@@ -859,4 +869,6 @@ EXPORT_SYMBOL(netpoll_parse_options);
 EXPORT_SYMBOL(netpoll_setup);
 EXPORT_SYMBOL(netpoll_cleanup);
 EXPORT_SYMBOL(netpoll_send_udp);
+EXPORT_SYMBOL(netpoll_send_skb);
 EXPORT_SYMBOL(netpoll_poll);
+EXPORT_SYMBOL(netpoll_poll_dev);
#8 lore raw
Quoted 2 lines · Andy Gospodarek

I finally had some time to get this going again. This is a patch against a Linus' latest tree.

Excellent; I'll throw it in and see how it goes.

Thanks Andy!