aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/macvlan.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-07-21 17:44:31 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-22 16:08:56 -0400
commit8a35747a5d13b99e076b0222729e0caa48cb69b6 (patch)
tree387e2840fe46edd9cc36027cf188778f2c5ab1ff /drivers/net/macvlan.c
parentbded64a7ff82f6af56426a4ff2483888e5ad5fe9 (diff)
macvtap: Limit packet queue length
Mark Wagner reported OOM symptoms when sending UDP traffic over a macvtap link to a kvm receiver. This appears to be caused by the fact that macvtap packet queues are unlimited in length. This means that if the receiver can't keep up with the rate of flow, then we will hit OOM. Of course it gets worse if the OOM killer then decides to kill the receiver. This patch imposes a cap on the packet queue length, in the same way as the tuntap driver, using the device TX queue length. Please note that macvtap currently has no way of giving congestion notification, that means the software device TX queue cannot be used and packets will always be dropped once the macvtap driver queue fills up. This shouldn't be a great problem for the scenario where macvtap is used to feed a kvm receiver, as the traffic is most likely external in origin so congestion notification can't be applied anyway. Of course, if anybody decides to complain about guest-to-guest UDP packet loss down the track, then we may have to revisit this. Incidentally, this patch also fixes a real memory leak when macvtap_get_queue fails. Chris Wright noticed that for this patch to work, we need a non-zero TX queue length. This patch includes his work to change the default macvtap TX queue length to 500. Reported-by: Mark Wagner <mwagner@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Chris Wright <chrisw@sous-sol.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvlan.c')
-rw-r--r--drivers/net/macvlan.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 87e8d4cb4057..f15fe2cf72ae 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -499,7 +499,7 @@ static const struct net_device_ops macvlan_netdev_ops = {
499 .ndo_validate_addr = eth_validate_addr, 499 .ndo_validate_addr = eth_validate_addr,
500}; 500};
501 501
502static void macvlan_setup(struct net_device *dev) 502void macvlan_common_setup(struct net_device *dev)
503{ 503{
504 ether_setup(dev); 504 ether_setup(dev);
505 505
@@ -508,6 +508,12 @@ static void macvlan_setup(struct net_device *dev)
508 dev->destructor = free_netdev; 508 dev->destructor = free_netdev;
509 dev->header_ops = &macvlan_hard_header_ops, 509 dev->header_ops = &macvlan_hard_header_ops,
510 dev->ethtool_ops = &macvlan_ethtool_ops; 510 dev->ethtool_ops = &macvlan_ethtool_ops;
511}
512EXPORT_SYMBOL_GPL(macvlan_common_setup);
513
514static void macvlan_setup(struct net_device *dev)
515{
516 macvlan_common_setup(dev);
511 dev->tx_queue_len = 0; 517 dev->tx_queue_len = 0;
512} 518}
513 519
@@ -705,7 +711,6 @@ int macvlan_link_register(struct rtnl_link_ops *ops)
705 /* common fields */ 711 /* common fields */
706 ops->priv_size = sizeof(struct macvlan_dev); 712 ops->priv_size = sizeof(struct macvlan_dev);
707 ops->get_tx_queues = macvlan_get_tx_queues; 713 ops->get_tx_queues = macvlan_get_tx_queues;
708 ops->setup = macvlan_setup;
709 ops->validate = macvlan_validate; 714 ops->validate = macvlan_validate;
710 ops->maxtype = IFLA_MACVLAN_MAX; 715 ops->maxtype = IFLA_MACVLAN_MAX;
711 ops->policy = macvlan_policy; 716 ops->policy = macvlan_policy;
@@ -719,6 +724,7 @@ EXPORT_SYMBOL_GPL(macvlan_link_register);
719 724
720static struct rtnl_link_ops macvlan_link_ops = { 725static struct rtnl_link_ops macvlan_link_ops = {
721 .kind = "macvlan", 726 .kind = "macvlan",
727 .setup = macvlan_setup,
722 .newlink = macvlan_newlink, 728 .newlink = macvlan_newlink,
723 .dellink = macvlan_dellink, 729 .dellink = macvlan_dellink,
724}; 730};