diff mbox series

[net] net: skip virtio_net_hdr_set_proto if protocol already set

Message ID 20211220145027.2784293-1-willemdebruijn.kernel@gmail.com (mailing list archive)
State Accepted
Commit 1ed1d592113959f00cc552c3b9f47ca2d157768f
Delegated to: Netdev Maintainers
Headers show
Series [net] net: skip virtio_net_hdr_set_proto if protocol already set | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 3 maintainers not CCed: virtualization@lists.linux-foundation.org jasowang@redhat.com mst@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Willem de Bruijn Dec. 20, 2021, 2:50 p.m. UTC
From: Willem de Bruijn <willemb@google.com>

virtio_net_hdr_set_proto infers skb->protocol from the virtio_net_hdr
gso_type, to avoid packets getting dropped for lack of a proto type.

Its protocol choice is a guess, especially in the case of UFO, where
the single VIRTIO_NET_HDR_GSO_UDP label covers both UFOv4 and UFOv6.

Skip this best effort if the field is already initialized. Whether
explicitly from userspace, or implicitly based on an earlier call to
dev_parse_header_protocol (which is more robust, but was introduced
after this patch).

Fixes: 9d2f67e43b73 ("net/packet: fix packet drop as of virtio gso")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/linux/virtio_net.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 21, 2021, 3:10 a.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 20 Dec 2021 09:50:27 -0500 you wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> virtio_net_hdr_set_proto infers skb->protocol from the virtio_net_hdr
> gso_type, to avoid packets getting dropped for lack of a proto type.
> 
> Its protocol choice is a guess, especially in the case of UFO, where
> the single VIRTIO_NET_HDR_GSO_UDP label covers both UFOv4 and UFOv6.
> 
> [...]

Here is the summary with links:
  - [net] net: skip virtio_net_hdr_set_proto if protocol already set
    https://git.kernel.org/netdev/net/c/1ed1d5921139

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 22dd48c82560..a960de68ac69 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -25,6 +25,9 @@  static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
 static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
 					   const struct virtio_net_hdr *hdr)
 {
+	if (skb->protocol)
+		return 0;
+
 	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
 	case VIRTIO_NET_HDR_GSO_TCPV4:
 	case VIRTIO_NET_HDR_GSO_UDP: