diff mbox

tun: teach the tun/tap driver to support netpoll

Message ID 1308151501-8434-1-git-send-email-nhorman@tuxdriver.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Neil Horman June 15, 2011, 3:25 p.m. UTC
Commit 8d8fc29d02a33e4bd5f4fa47823c1fd386346093 changed the behavior of slave
devices in regards to netpoll.  Specifically it created a mutually exclusive
relationship between being a slave and a netpoll-capable device.  This creates
problems for KVM because guests relied on needing netconsole active on a slave
device to a bridge.  Ideally libvirtd could just attach netconsole to the bridge
device instead, but thats currently infeasible, because while the bridge device
supports netpoll, it requires that all slave interface also support it, but the
tun/tap driver currently does not.  The most direct solution is to teach tun/tap
to support netpoll, which is implemented by the patch below.

I've not tested this yet, but its pretty straightforward.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reported-by: Rik van Riel <riel@redhat.com>
CC: Rik van Riel <riel@redhat.com>
CC: Maxim Krasnyansky <maxk@qualcomm.com>
CC: Cong Wang <amwang@redhat.com>
CC: "David S. Miller" <davem@davemloft.net>
---
 drivers/net/tun.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

Comments

Rik van Riel June 15, 2011, 5:50 p.m. UTC | #1
On 06/15/2011 11:25 AM, Neil Horman wrote:
> Commit 8d8fc29d02a33e4bd5f4fa47823c1fd386346093 changed the behavior of slave
> devices in regards to netpoll.  Specifically it created a mutually exclusive
> relationship between being a slave and a netpoll-capable device.  This creates
> problems for KVM because guests relied on needing netconsole active on a slave
> device to a bridge.  Ideally libvirtd could just attach netconsole to the bridge
> device instead, but thats currently infeasible, because while the bridge device
> supports netpoll, it requires that all slave interface also support it, but the
> tun/tap driver currently does not.  The most direct solution is to teach tun/tap
> to support netpoll, which is implemented by the patch below.
>
> I've not tested this yet, but its pretty straightforward.

I have tested it.  I can run netconsole and my KVM guests
simultaneously again.

Thank you, Neil!

Now all I have to do is log whatever other bugs are haunting
3.0-rc and causing my system to hang :)

> Signed-off-by: Neil Horman<nhorman@tuxdriver.com>
> Reported-by: Rik van Riel<riel@redhat.com>
> CC: Rik van Riel<riel@redhat.com>
> CC: Maxim Krasnyansky<maxk@qualcomm.com>
> CC: Cong Wang<amwang@redhat.com>
> CC: "David S. Miller"<davem@davemloft.net>

Reviewed-by: Rik van Riel <riel@redhat.com>
Tested-by: Rik van Riel <riel@redhat.com>
Amerigo Wang June 16, 2011, 1:44 a.m. UTC | #2
于 2011年06月15日 23:25, Neil Horman 写道:
> Commit 8d8fc29d02a33e4bd5f4fa47823c1fd386346093 changed the behavior of slave
> devices in regards to netpoll.  Specifically it created a mutually exclusive
> relationship between being a slave and a netpoll-capable device.  This creates
> problems for KVM because guests relied on needing netconsole active on a slave
> device to a bridge.  Ideally libvirtd could just attach netconsole to the bridge
> device instead, but thats currently infeasible, because while the bridge device
> supports netpoll, it requires that all slave interface also support it, but the
> tun/tap driver currently does not.  The most direct solution is to teach tun/tap
> to support netpoll, which is implemented by the patch below.
>

Yeah, bridge checks if all the underlying devices support netpoll,
that is why Rik saw the failure.


> I've not tested this yet, but its pretty straightforward.
>
> Signed-off-by: Neil Horman<nhorman@tuxdriver.com>
> Reported-by: Rik van Riel<riel@redhat.com>
> CC: Rik van Riel<riel@redhat.com>
> CC: Maxim Krasnyansky<maxk@qualcomm.com>
> CC: Cong Wang<amwang@redhat.com>
> CC: "David S. Miller"<davem@davemloft.net>

Reviewed-by: WANG Cong <amwang@redhat.com>

Thanks for fixing it!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller June 17, 2011, 3:53 a.m. UTC | #3
From: Neil Horman <nhorman@tuxdriver.com>
Date: Wed, 15 Jun 2011 11:25:01 -0400

> Commit 8d8fc29d02a33e4bd5f4fa47823c1fd386346093 changed the behavior of slave
> devices in regards to netpoll.  Specifically it created a mutually exclusive
> relationship between being a slave and a netpoll-capable device.  This creates
> problems for KVM because guests relied on needing netconsole active on a slave
> device to a bridge.  Ideally libvirtd could just attach netconsole to the bridge
> device instead, but thats currently infeasible, because while the bridge device
> supports netpoll, it requires that all slave interface also support it, but the
> tun/tap driver currently does not.  The most direct solution is to teach tun/tap
> to support netpoll, which is implemented by the patch below.
> 
> I've not tested this yet, but its pretty straightforward.
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> Reported-by: Rik van Riel <riel@redhat.com>
> CC: Rik van Riel <riel@redhat.com>
> CC: Maxim Krasnyansky <maxk@qualcomm.com>
> CC: Cong Wang <amwang@redhat.com>
> CC: "David S. Miller" <davem@davemloft.net>

Applied, thanks Neil.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 4dab85e..9a6b382 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -460,7 +460,23 @@  static u32 tun_net_fix_features(struct net_device *dev, u32 features)
 
 	return (features & tun->set_features) | (features & ~TUN_USER_FEATURES);
 }
-
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void tun_poll_controller(struct net_device *dev)
+{
+	/*
+	 * Tun only receives frames when:
+	 * 1) the char device endpoint gets data from user space
+	 * 2) the tun socket gets a sendmsg call from user space
+	 * Since both of those are syncronous operations, we are guaranteed
+	 * never to have pending data when we poll for it
+	 * so theres nothing to do here but return.
+	 * We need this though so netpoll recognizes us as an interface that
+	 * supports polling, which enables bridge devices in virt setups to
+	 * still use netconsole
+	 */
+	return;
+}
+#endif
 static const struct net_device_ops tun_netdev_ops = {
 	.ndo_uninit		= tun_net_uninit,
 	.ndo_open		= tun_net_open,
@@ -468,6 +484,9 @@  static const struct net_device_ops tun_netdev_ops = {
 	.ndo_start_xmit		= tun_net_xmit,
 	.ndo_change_mtu		= tun_net_change_mtu,
 	.ndo_fix_features	= tun_net_fix_features,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= tun_poll_controller,
+#endif
 };
 
 static const struct net_device_ops tap_netdev_ops = {
@@ -480,6 +499,9 @@  static const struct net_device_ops tap_netdev_ops = {
 	.ndo_set_multicast_list	= tun_net_mclist,
 	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= tun_poll_controller,
+#endif
 };
 
 /* Initialize net device. */