Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/drivers/net: Add an xdp test to xdp.py

In "bpf: Disallow freplace on XDP with mismatched xdp_has_frags values" [1],
this XDP test is suggested to add to xdp.py.

1. Verify the failure of updating frag-capable prog with non-frag-capable
prog, when the frag-capable prog attaches to mtu=9k driver.

The test has been verified against Mellanox CX6 and Intel 82599ES NICs.

With dropping other tests, here is the test log.

# ethtool -i eth0
driver: mlx5_core
version: 6.19.0-061900-generic

# NETIF=eth0 python3 xdp.py
TAP version 13
1..1
ok 1 xdp.test_xdp_native_update_mb_to_sb
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

# ethtool -i eth0
driver: ixgbe
version: 6.19.0-061900-generic

# NETIF=eth0 python3 xdp.py
TAP version 13
1..1
# CMD: ip link set dev eth0 xdpdrv obj /path/to/tools/testing/selftests/net/lib/xdp_dummy.bpf.o sec xdp.frags
# EXIT: 2
# STDERR: RTNETLINK answers: Invalid argument
ok 1 xdp.test_xdp_native_update_mb_to_sb # SKIP device does not support multi-buffer XDP
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

Signed-off-by: Leon Hwang <leon.huangfu@shopee.com>
Link: https://patch.msgid.link/20260406072655.368173-1-leon.huangfu@shopee.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Leon Hwang and committed by
Jakub Kicinski
5ae4ba98 68911235

+30 -1
+30 -1
tools/testing/selftests/drivers/net/xdp.py
··· 13 13 14 14 from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ge, ksft_ne, ksft_pr 15 15 from lib.py import KsftNamedVariant, ksft_variants 16 - from lib.py import KsftFailEx, NetDrvEpEnv 16 + from lib.py import KsftFailEx, KsftSkipEx, NetDrvEpEnv 17 17 from lib.py import EthtoolFamily, NetdevFamily, NlError 18 18 from lib.py import bkg, cmd, rand_port, wait_port_listen 19 19 from lib.py import ip, defer ··· 693 693 ksft_ge(after['tx-packets'], before['tx-packets']) 694 694 695 695 696 + def test_xdp_native_update_mb_to_sb(cfg): 697 + """ 698 + Test multi-buf to single-buf replacement with jumbo MTU. 699 + """ 700 + obj = cfg.net_lib_dir / "xdp_dummy.bpf.o" 701 + mtu = 9000 702 + 703 + ip(f"link set dev {cfg.ifname} mtu {mtu}") 704 + defer(ip, f"link set dev {cfg.ifname} mtu {cfg.dev['mtu']} xdpdrv off") 705 + 706 + attach = cmd(f"ip link set dev {cfg.ifname} xdpdrv obj {obj} sec xdp", fail=False) 707 + if attach.ret == 0: 708 + raise KsftSkipEx(f"device supports single-buffer XDP with mtu {mtu}") 709 + 710 + attach = cmd(f"ip link set dev {cfg.ifname} xdpdrv obj {obj} sec xdp.frags", fail=False) 711 + if attach.ret != 0: 712 + ksft_pr(attach) 713 + raise KsftSkipEx("device does not support multi-buffer XDP") 714 + 715 + # Verify updating mb -> mb program works. 716 + cmd(f"ip -force link set dev {cfg.ifname} xdpdrv obj {obj} sec xdp.frags") 717 + 718 + # Verify updating mb -> sb program does not work. 719 + update = cmd(f"ip -force link set dev {cfg.ifname} xdpdrv obj {obj} sec xdp", fail=False) 720 + if update.ret == 0: 721 + raise KsftFailEx("device unexpectedly updates non-multi-buffer XDP") 722 + 723 + 696 724 def main(): 697 725 """ 698 726 Main function to execute the XDP tests. ··· 746 718 test_xdp_native_adjst_head_grow_data, 747 719 test_xdp_native_adjst_head_shrnk_data, 748 720 test_xdp_native_qstats, 721 + test_xdp_native_update_mb_to_sb, 749 722 ], 750 723 args=(cfg,)) 751 724 ksft_exit()