> virtnet_xdp_rx_hash() reads the hash from the vnet header at
> xdp->data - vi->hdr_len when the XDP program calls
> bpf_xdp_metadata_rx_hash(). That is only the header until the program
> changes the buffer: bpf_xdp_adjust_meta() writes the metadata right in
> front of xdp->data, over the header, and bpf_xdp_adjust_head() moves
> xdp->data, so the callback then reads metadata or packet bytes.
> 
> Wrap struct xdp_buff in struct virtnet_xdp_buff, copy hash value and
> report type into it in virtnet_xdp_handler() before
> bpf_prog_run_xdp(), and let the callback read the copy. The small and
> mergeable paths put the wrapper on the stack; for AF_XDP the fields are
> in the cb of struct xdp_buff_xsk, checked with XSK_CHECK_PRIV_TYPE().
> 
> Move virtio_net_hash_value() up so the copy can use it.
> 
> Fixes: aa37f8916d20 ("virtio_net: Support RX hash XDP hint")
> Signed-off-by: Steffen Trumtrar <[email protected]>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20261112-v6-7-topic-virtio-net-ptp-v5-0-7ab67b572...@pengutronix.de?part=3


Reply via email to