OSDN Git Service

net: skip virtio_net_hdr_set_proto if protocol already set
authorWillem de Bruijn <willemb@google.com>
Mon, 20 Dec 2021 14:50:27 +0000 (09:50 -0500)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Dec 2021 02:47:37 +0000 (18:47 -0800)
commit1ed1d592113959f00cc552c3b9f47ca2d157768f
tree38c8f57fc5231b57a47b0b0b5f98327f244d89d9
parent7e5cced9ca84df52d874aca6b632f930b3dc5bc6
net: skip virtio_net_hdr_set_proto if protocol already set

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>
Link: https://lore.kernel.org/r/20211220145027.2784293-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/virtio_net.h