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