Re: [PATCH net-next v6 3/3] selftests: drv-net: Test queue xsk attribute

From: Stanislav Fomichev
Date: Tue Feb 11 2025 - 18:11:07 EST


On 02/11, Joe Damato wrote:
> On Tue, Feb 11, 2025 at 12:00:38PM -0800, Stanislav Fomichev wrote:
> > On 02/11, Joe Damato wrote:
> > > On Tue, Feb 11, 2025 at 09:45:56AM -0800, Joe Damato wrote:
> > > > On Tue, Feb 11, 2025 at 12:09:50PM +0100, Paolo Abeni wrote:
> > > > > On 2/10/25 8:38 PM, Joe Damato wrote:
>
> [...]
>
> > > > >
> > > > > This causes self-test failures:
> > > > >
> > > > > https://netdev-3.bots.linux.dev/vmksft-net-drv/results/987742/4-queues-py/stdout
> > > > >
> > > > > but I really haven't done any real investigation here.
> > > >
> > > > I think it's because the test kernel in this case has
> > > > CONFIG_XDP_SOCKETS undefined [1].
> > > >
> > > > The error printed in the link you mentioned:
> > > >
> > > > socket creation failed: Address family not supported by protocol
> > > >
> > > > is coming from the C program, which fails to create the AF_XDP
> > > > socket.
> > > >
> > > > I think the immediate reaction is to add more error checking to the
> > > > python to make sure that the subprocess succeeded and if it failed,
> > > > skip.
> > > >
> > > > But, we may want it to fail for other error states instead of
> > > > skipping? Not sure if there's general guidance on this, but my plan
> > > > was to have the AF_XDP socket creation failure return a different
> > > > error code (I dunno maybe -1?) and only skip the test in that case.
> > > >
> > > > Will that work or is there a better way? I only want to skip if
> > > > AF_XDP doesn't exist in the test kernel.
> > > >
> > > > [1]: https://netdev-3.bots.linux.dev/vmksft-net-drv/results/987742/config
> > >
> > > I'll give it a few more hours incase anyone has comments before I
> > > resend, but I got something working (tested on kernels with and
> > > without XDP sockets).
> > >
> > > xdp_helper returns -1 if (errno == EAFNOSUPPORT). All other error
> > > cases return 1.
> > >
> > > Updated the python to do this:
> > >
> > > if xdp.returncode == 255:
> > > raise KsftSkipEx('AF_XDP unsupported')
> > > elif xdp.returncode > 0:
> > > raise KsftFailEx('unable to create AF_XDP socket')
> > >
> > > Which seems to work on both types of kernels?
> > >
> > > Happy to take feedback; will hold off on respinning for a bit just
> > > incase there's a better way I don't know about.
> >
> > Any reason not to enable CONFIG_XDP_SOCKETS on NIPA kernels? Seems a bit
> > surprising that we run networking tests without XSKs enabled.
>
> I can't comment on NIPA because I have no idea how it works. Maybe
> there is a kernel with some options enabled and other kernels with
> various options disabled?

Sorry, should've been more clear. My suggestion is to add
CONFIG_XDP_SOCKETS to tools/testing/selftests/drivers/net/config
to make your new testcase run in a proper environment with XSKs enabled.

> I wonder if that's a separate issue though?
>
> In other words: maybe writing the test as I've mentioned above so it
> works regardless of whether CONFIG_XDP_SOCKETS is set or not is a
> good idea just on its own?
>
> I'm just not sure if there's some other pattern I should be
> following other than what I proposed above. I'm hesitant to re-spin
> until I get feedback on the proposed approach.

I'd keep your test as is (fail hard if XSK is not there), but
let's see if Paolo/Jakub have any other suggestions.