Subject: Re: [PATCH net-next V6 2/5] selftests: drv-net: Test XDP_PASS/DROP support

From: Jakub Kicinski <[email-masked]>
Date: Mon, 21 Jul 2025 08:40:46 -0700

On Mon, 21 Jul 2025 14:43:15 +0300 Nimrod Oren wrote:
> > +static struct udphdr *filter_udphdr(struct xdp_md *ctx, __u16 port)
> > +{
> > +	void *data_end = (void *)(long)ctx->data_end;
> > +	void *data = (void *)(long)ctx->data;
> > +	struct udphdr *udph = NULL;
> > +	struct ethhdr *eth = data;
> > +
> > +	if (data + sizeof(*eth) > data_end)
> > +		return NULL;
> > +  
> 
> This check assumes that the packet headers reside in the linear part of
> the xdp_buff. However, this assumption does not hold across all drivers.
> For example, in mlx5, the linear part is empty when using multi-buffer
> mode with striding rq configuration. This causes all multi-buffer test
> cases to fail over mlx5.
> 
> To ensure correctness across all drivers, all direct accesses to packet
> data should use these safer helper functions instead:
> bpf_xdp_load_bytes() and bpf_xdp_store_bytes().
> 
> Related discussion and context can be found here:
> https://github.com/xdp-project/xdp-tools/pull/409

That's a reasonable way to modify the test. But I'm not sure it's
something that should be blocking merging the patches.
Or for that matter whether it's Mohsin's responsibility to make the
test cater to quirks of mlx5, which is not even part of NIPA testing -
we have no way of knowing what passes for mlx5, what regresses it etc.

Not related to this series, but I'd be curious what the perf hit is for
having to load the headers.