All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: skip virtio_net_hdr_set_proto if protocol already set
@ 2021-12-20 14:50 Willem de Bruijn
  2021-12-21  3:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2021-12-20 14:50 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jianfeng.tan, Willem de Bruijn

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(+)

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:
-- 
2.34.1.173.g76aa8bc2d0-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: skip virtio_net_hdr_set_proto if protocol already set
  2021-12-20 14:50 [PATCH net] net: skip virtio_net_hdr_set_proto if protocol already set Willem de Bruijn
@ 2021-12-21  3:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-21  3:10 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev, davem, kuba, jianfeng.tan, willemb

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-21  3:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-20 14:50 [PATCH net] net: skip virtio_net_hdr_set_proto if protocol already set Willem de Bruijn
2021-12-21  3:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.