On Thu, Nov 12, 2026 at 12:19:38PM +0100, Steffen Trumtrar wrote: > The header is cast from skb->cb and from device buffers, so its layout > must not change silently. Add static_asserts for the offset of tstamp, > the total size, the alignment, and that the header fits into skb->cb. > > Signed-off-by: Steffen Trumtrar <[email protected]> > --- > include/linux/virtio_net.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h > index 2abd8a614a23f..e7776a37a486b 100644 > --- a/include/linux/virtio_net.h > +++ b/include/linux/virtio_net.h > @@ -29,6 +29,17 @@ struct virtio_net_common_hdr { > __le16 tstamp[4]; /* le64 TAI receive time in ns, 0 if none */ > }; > > +/* > + * The header is cast from skb->cb and from device buffers, the layout must > not > + * change silently. > + */ > +static_assert(offsetof(struct virtio_net_common_hdr, tstamp) == 32); > +static_assert(sizeof(struct virtio_net_common_hdr) == > + offsetofend(struct virtio_net_common_hdr, tstamp)); > +static_assert(__alignof__(struct virtio_net_common_hdr) == 2); > +/* virtio_net_common_hdr must fit into skb->cb */ > +static_assert(sizeof(struct virtio_net_common_hdr) <= sizeof_field(struct > sk_buff, cb)); > + > static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type) > { > switch (gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
Waste of time. We know how to maintain stable UAPIs without this kind of stuff. > -- > 2.56.0
