Re: [PATCH bpf-next] xsk: fix destination buffer address when copying with metadata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stanislav Fomichev <sdf@xxxxxxxxxx> writes:

> While working on a simplified test for [0] it occurred to me that
> the following looks fishy:
>
> 	data = xsk_umem__get_data(xsk->umem_area, rx_desc->addr);
> 	data_meta = data - sizeof(my metadata);
>
> Since the data points to umem frame at addr X, data_mem points to
> the end of umem frame X-1.
>
> I don't think it's by design?

It is by design. :-)

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 9f0561b67c12..0547fe37ba7e 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -163,7 +163,7 @@ static void xsk_copy_xdp(struct xdp_buff *to, struct xdp_buff *from, u32 len)
>  	} else {
>  		from_buf = from->data_meta;
>  		metalen = from->data - from->data_meta;
> -		to_buf = to->data - metalen;

This is to include the XDP meta data in the receive buffer. Note that
AF_XDP descriptor that you get back on the RX ring points to the *data*
not the metadata.

For the unaligned mode you can pass any address (umem offset) into the
fill ring, and the kernel will simply mask it and setup headroom
accordingly.

The buffer allocator guarantees that there's XDP_PACKET_HEADROOM
available.

IOW your example userland code above is correct.


Björn






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux