[PATCH RFC v4 1/6] virtio-net: move virtio_net_common_hdr to virtio_net.h

From: Steffen Trumtrar

Date: Mon Oct 26 2026 - 04:32:45 EST


tun and vhost need to know the layout and size of the virtio-net
header as the driver uses it, e.g. to fill in fields behind
virtio_net_hdr_v1_hash_tunnel. Move struct virtio_net_common_hdr to
the kernel-internal header that they include already.

No functional change.

Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
Assisted-by: Claude:claude-opus-5-5
---
drivers/net/virtio_net.c | 9 ---------
include/linux/virtio_net.h | 9 +++++++++
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index daab43ac92ce4..17d3e32eed9d6 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -492,15 +492,6 @@ struct padded_vnet_hdr {
char padding[12];
};

-struct virtio_net_common_hdr {
- union {
- struct virtio_net_hdr hdr;
- struct virtio_net_hdr_mrg_rxbuf mrg_hdr;
- struct virtio_net_hdr_v1_hash hash_v1_hdr;
- struct virtio_net_hdr_v1_hash_tunnel tnl_hdr;
- };
-};
-
static struct virtio_net_common_hdr xsk_hdr;

static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf);
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index d6466f96cdd00..a6de308b8f25e 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -10,6 +10,15 @@
#include <uapi/linux/tcp.h>
#include <uapi/linux/virtio_net.h>

+struct virtio_net_common_hdr {
+ union {
+ struct virtio_net_hdr hdr;
+ struct virtio_net_hdr_mrg_rxbuf mrg_hdr;
+ struct virtio_net_hdr_v1_hash hash_v1_hdr;
+ struct virtio_net_hdr_v1_hash_tunnel tnl_hdr;
+ };
+};
+
static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
{
switch (gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {

--
2.52.0