lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 3 May 2010 11:25:20 +0200
From:	Martín Ferrari <martin.ferrari@...il.com>
To:	netdev <netdev@...r.kernel.org>
Cc:	Mathieu Lacage <mathieu.lacage@...hia.inria.fr>
Subject: Performance problem in network namespaces

Hi,

When running some benchmarks to test the feasibility of using
namespaces for emulating networks, I have found a big drop in
performance when one of the namespaces is performing routing of
packets.

After some search, we found that  in ip_forward() the skb is being
copied. It seems that (ICMP and UDP, does not happen with TCP) packets
start with a small headroom (16 bytes in our observation) but skb_cow
always allocates at least NET_SKB_PAD (32 in x86) bytes of headroom,
thus triggering this unnecessary memcpy.

We made two crude attempts at fixing this, which are surely incorrect,
but hopefully somebody here could come up with a correct solution.

Our attempts are: 1. remove the lower bound in headroom size at
skb_cow, and 2. set needed_headroom in veth.c to NET_SKB_PAD; patches
included below.

Thanks.


diff -Naurp linux-2.6.34-rc5/include/linux/skbuff.h
../linux-2.6.34-rc5/include/linux/skbuff.h
--- linux-2.6.34-rc5/include/linux/skbuff.h	2010-04-20 01:29:56.000000000 +0200
+++ ../linux-2.6.34-rc5/include/linux/skbuff.h	2010-05-03
11:17:13.000000000 +0200
@@ -1526,8 +1526,6 @@ static inline int __skb_cow(struct sk_bu
 {
 	int delta = 0;

-	if (headroom < NET_SKB_PAD)
-		headroom = NET_SKB_PAD;
 	if (headroom > skb_headroom(skb))
 		delta = headroom - skb_headroom(skb);


diff -Naurp linux-2.6.34-rc5/drivers/net/veth.c
../linux-2.6.34-rc5/drivers/net/veth.c
--- linux-2.6.34-rc5/drivers/net/veth.c	2010-04-20 01:29:56.000000000 +0200
+++ ../linux-2.6.34-rc5/drivers/net/veth.c	2010-04-30 11:29:39.000000000 +0200
@@ -303,6 +303,8 @@ static void veth_setup(struct net_device
 	dev->ethtool_ops = &veth_ethtool_ops;
 	dev->features |= NETIF_F_LLTX;
 	dev->destructor = veth_dev_free;
+	/* Try to avoid skb copies when passing packets around */
+	dev->needed_headroom = NET_SKB_PAD;
 }

 /*


-- 
Martín Ferrari
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ