selftests: drv-net: probe for AF_XDP sockets more explicitly

Separate the support check from socket binding for easier refactoring.
Use: ./helper - - just to probe if we can open the socket.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Tested-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20250219234956.520599-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski
2025-02-19 15:49:53 -08:00
parent bab59dcf71
commit d3726ab45c
2 changed files with 14 additions and 5 deletions

View File

@@ -25,6 +25,13 @@ def nl_get_queues(cfg, nl, qtype='rx'):
return None
def check_xdp(cfg, nl, xdp_queue_id=0) -> None:
# Probe for support
xdp = cmd(cfg.rpath("xdp_helper") + ' - -', fail=False)
if xdp.ret == 255:
raise KsftSkipEx('AF_XDP unsupported')
elif xdp.ret > 0:
raise KsftFailEx('unable to create AF_XDP socket')
xdp = subprocess.Popen([cfg.rpath("xdp_helper"), f"{cfg.ifindex}", f"{xdp_queue_id}"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1,
text=True)
@@ -33,11 +40,6 @@ def check_xdp(cfg, nl, xdp_queue_id=0) -> None:
stdout, stderr = xdp.communicate(timeout=10)
rx = tx = False
if xdp.returncode == 255:
raise KsftSkipEx('AF_XDP unsupported')
elif xdp.returncode > 0:
raise KsftFailEx('unable to create AF_XDP socket')
queues = nl.queue_get({'ifindex': cfg.ifindex}, dump=True)
if not queues:
raise KsftSkipEx("Netlink reports no queues")