From: Joe Damato <jdamato@fastly.com>
To: Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, stfomichev@gmail.com, horms@kernel.org,
kuba@kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>, Shuah Khan <shuah@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
open list <linux-kernel@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
"open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)"
<bpf@vger.kernel.org>
Subject: Re: [PATCH net-next v6 3/3] selftests: drv-net: Test queue xsk attribute
Date: Tue, 11 Feb 2025 11:57:27 -0800 [thread overview]
Message-ID: <Z6urp3d41nvBoSbG@LQ3V64L9R2> (raw)
In-Reply-To: <Z6uM1IDP9JgvGvev@LQ3V64L9R2>
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:
> > > +def check_xdp(cfg, nl, xdp_queue_id=0) -> None:
> > > + test_dir = os.path.dirname(os.path.realpath(__file__))
> > > + xdp = subprocess.Popen([f"{test_dir}/xdp_helper", f"{cfg.ifindex}", f"{xdp_queue_id}"],
> > > + stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1,
> > > + text=True)
> > > + defer(xdp.kill)
> > > +
> > > + stdout, stderr = xdp.communicate(timeout=10)
> > > + rx = tx = False
> > > +
> > > + queues = nl.queue_get({'ifindex': cfg.ifindex}, dump=True)
> > > + if not queues:
> > > + raise KsftSkipEx("Netlink reports no queues")
> > > +
> > > + for q in queues:
> > > + if q['id'] == 0:
> > > + if q['type'] == 'rx':
> > > + rx = True
> > > + if q['type'] == 'tx':
> > > + tx = True
> > > +
> > > + ksft_eq(q['xsk'], {})
> > > + else:
> > > + if 'xsk' in q:
> > > + _fail("Check failed: xsk attribute set.")
> > > +
> > > + ksft_eq(rx, True)
> > > + ksft_eq(tx, True)
> >
> > 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.
next prev parent reply other threads:[~2025-02-11 19:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 19:38 [PATCH net-next v6 0/3] netdev-genl: Add an xsk attribute to queues Joe Damato
2025-02-10 19:38 ` [PATCH net-next v6 1/3] netlink: Add nla_put_empty_nest helper Joe Damato
2025-02-10 19:38 ` [PATCH net-next v6 2/3] netdev-genl: Add an XSK attribute to queues Joe Damato
2025-02-10 19:38 ` [PATCH net-next v6 3/3] selftests: drv-net: Test queue xsk attribute Joe Damato
2025-02-11 11:09 ` Paolo Abeni
2025-02-11 17:45 ` Joe Damato
2025-02-11 19:57 ` Joe Damato [this message]
2025-02-11 20:00 ` Stanislav Fomichev
2025-02-11 22:37 ` Joe Damato
2025-02-11 23:10 ` Stanislav Fomichev
2025-02-12 2:37 ` Jakub Kicinski
2025-02-12 13:30 ` Joe Damato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6urp3d41nvBoSbG@LQ3V64L9R2 \
--to=jdamato@fastly.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stfomichev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).