Juergen Gross 04b216
Patch-mainline: v5.16-rc7
Juergen Gross 04b216
Git-commit: 1ed1d592113959f00cc552c3b9f47ca2d157768f
Juergen Gross 04b216
References: git-fixes
Juergen Gross 04b216
From: Willem de Bruijn <willemb@google.com>
Juergen Gross 04b216
Date: Mon, 20 Dec 2021 09:50:27 -0500
Juergen Gross 04b216
Subject: [PATCH] net: skip virtio_net_hdr_set_proto if protocol already set
Juergen Gross 04b216
Juergen Gross 04b216
virtio_net_hdr_set_proto infers skb->protocol from the virtio_net_hdr
Juergen Gross 04b216
gso_type, to avoid packets getting dropped for lack of a proto type.
Juergen Gross 04b216
Juergen Gross 04b216
Its protocol choice is a guess, especially in the case of UFO, where
Juergen Gross 04b216
the single VIRTIO_NET_HDR_GSO_UDP label covers both UFOv4 and UFOv6.
Juergen Gross 04b216
Juergen Gross 04b216
Skip this best effort if the field is already initialized. Whether
Juergen Gross 04b216
explicitly from userspace, or implicitly based on an earlier call to
Juergen Gross 04b216
dev_parse_header_protocol (which is more robust, but was introduced
Juergen Gross 04b216
after this patch).
Juergen Gross 04b216
Juergen Gross 04b216
Fixes: 9d2f67e43b73 ("net/packet: fix packet drop as of virtio gso")
Juergen Gross 04b216
Signed-off-by: Willem de Bruijn <willemb@google.com>
Juergen Gross 04b216
Link: https://lore.kernel.org/r/20211220145027.2784293-1-willemdebruijn.kernel@gmail.com
Juergen Gross 04b216
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Juergen Gross 04b216
Signed-off-by: Juergen Gross <jgross@suse.com>
Juergen Gross 04b216
---
Juergen Gross 04b216
 include/linux/virtio_net.h | 3 +++
Juergen Gross 04b216
 1 file changed, 3 insertions(+)
Juergen Gross 04b216
Juergen Gross 04b216
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
Juergen Gross 04b216
index 22dd48c82560..a960de68ac69 100644
Juergen Gross 04b216
--- a/include/linux/virtio_net.h
Juergen Gross 04b216
+++ b/include/linux/virtio_net.h
Juergen Gross 04b216
@@ -25,6 +25,9 @@ static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
Juergen Gross 04b216
 static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
Juergen Gross 04b216
 					   const struct virtio_net_hdr *hdr)
Juergen Gross 04b216
 {
Juergen Gross 04b216
+	if (skb->protocol)
Juergen Gross 04b216
+		return 0;
Juergen Gross 04b216
+
Juergen Gross 04b216
 	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
Juergen Gross 04b216
 	case VIRTIO_NET_HDR_GSO_TCPV4:
Juergen Gross 04b216
 	case VIRTIO_NET_HDR_GSO_UDP:
Juergen Gross 04b216
-- 
Juergen Gross 04b216
2.35.3
Juergen Gross 04b216