1 From foo@baz Tue Jan 26 22:24:47 PST 2016
2 From: Vijay Pandurangan <vijayp@vijayp.ca>
3 Date: Fri, 18 Dec 2015 14:34:59 -0500
4 Subject: =?UTF-8?q?veth:=20don=E2=80=99t=20modify=20ip=5Fsum?= =?UTF-8?q?med;=20doing=20so=20treats=20packets=20with=20bad=20checksums?= =?UTF-8?q?=20as=20good.?=
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
12 From: Vijay Pandurangan <vijayp@vijayp.ca>
14 [ Upstream commit ce8c839b74e3017996fad4e1b7ba2e2625ede82f ]
16 Packets that arrive from real hardware devices have ip_summed ==
17 CHECKSUM_UNNECESSARY if the hardware verified the checksums, or
18 CHECKSUM_NONE if the packet is bad or it was unable to verify it. The
19 current version of veth will replace CHECKSUM_NONE with
20 CHECKSUM_UNNECESSARY, which causes corrupt packets routed from hardware to
21 a veth device to be delivered to the application. This caused applications
22 at Twitter to receive corrupt data when network hardware was corrupting
25 We believe this was added as an optimization to skip computing and
26 verifying checksums for communication between containers. However, locally
27 generated packets have ip_summed == CHECKSUM_PARTIAL, so the code as
28 written does nothing for them. As far as we can tell, after removing this
29 code, these packets are transmitted from one stack to another unmodified
30 (tcpdump shows invalid checksums on both sides, as expected), and they are
31 delivered correctly to applications. We didn’t test every possible network
32 configuration, but we tried a few common ones such as bridging containers,
33 using NAT between the host and a container, and routing from hardware
34 devices to containers. We have effectively deployed this in production at
35 Twitter (by disabling RX checksum offloading on veth devices).
37 This code dates back to the first version of the driver, commit
38 <e314dbdc1c0dc6a548ecf> ("[NET]: Virtual ethernet device driver"), so I
39 suspect this bug occurred mostly because the driver API has evolved
40 significantly since then. Commit <0b7967503dc97864f283a> ("net/veth: Fix
41 packet checksumming") (in December 2010) fixed this for packets that get
42 created locally and sent to hardware devices, by not changing
43 CHECKSUM_PARTIAL. However, the same issue still occurs for packets coming
44 in from hardware devices.
46 Co-authored-by: Evan Jones <ej@evanjones.ca>
47 Signed-off-by: Evan Jones <ej@evanjones.ca>
48 Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
49 Cc: Phil Sutter <phil@nwl.cc>
50 Cc: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
51 Cc: netdev@vger.kernel.org
52 Cc: linux-kernel@vger.kernel.org
53 Signed-off-by: Vijay Pandurangan <vijayp@vijayp.ca>
54 Acked-by: Cong Wang <cwang@twopensource.com>
55 Signed-off-by: David S. Miller <davem@davemloft.net>
56 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
58 drivers/net/veth.c | 6 ------
59 1 file changed, 6 deletions(-)
61 --- a/drivers/net/veth.c
62 +++ b/drivers/net/veth.c
63 @@ -116,12 +116,6 @@ static netdev_tx_t veth_xmit(struct sk_b
67 - /* don't change ip_summed == CHECKSUM_PARTIAL, as that
68 - * will cause bad checksum on forwarded packets
70 - if (skb->ip_summed == CHECKSUM_NONE &&
71 - rcv->features & NETIF_F_RXCSUM)
72 - skb->ip_summed = CHECKSUM_UNNECESSARY;
74 if (likely(dev_forward_skb(rcv, skb) == NET_RX_SUCCESS)) {
75 struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats);