From nobody Sun Apr 5 13:14:54 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07D1431F991 for ; Wed, 1 Apr 2026 05:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775021282; cv=none; b=XH33qWNCnVdosezXISjflSlkDodcIuwHbEpc1xCY2Q0fUQCBXvsMFWwobbCZDAmAn+tc4dWDkiYaQxofm5Yspe+1YLpbUVreIXMzmCw37TASuxQHS9ElHbWJ+iTQXtxmhDSw2nSSgthlcRAREpygYPX5ES35aRprtWqnsT9A+18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775021282; c=relaxed/simple; bh=VD/BrkY+P9EZvzyKieGsPzn58utPMgfLt7RRVf8OBvg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MfAz7tziUlIjreD70MR3e3HwhAetavJ5RWNMvaBMi395QPP1WjPoy0KUQ5UU801Ni9ABsBmsTe4ZwMTuM674ThxBxWrguVJHYv/32bCofrJpzYJqx+T2AQHUGCd+tc/761j+TrvCT74w/J98lbcDDMEw4Gw9E6CiKr1scyn9Mgw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=ktMLcu5X; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="ktMLcu5X" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c76b0cda2aeso679790a12.2 for ; Tue, 31 Mar 2026 22:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1775021280; x=1775626080; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+dtnjV/UQsHz5i0eYil7AmCFv4jaBC0RE9vTuxD9kdg=; b=ktMLcu5XPuPdlQoZ+w0ftcniQbvv+JariVNU6Q9c+4hnjfd7qsJzH4VG244gD0CNzD 80QtsygCSL1rH9gUYEBMBLGasR5zc9FYK7SlsZfopXTJYlLwfWqOU/VeD1fr0PX3VuwC MwZq4Au2bOlLY4zxyEZAlnni5KIPcowzd9pDrBqB1jD93YldM35jpzbTazxnRasJMFDk 628k6FP+hlHSZJxkOMGFcxreOrW/CEMv77zwtrwv7MCJ/ofnuUaJcRSeFBUcUK5GZucA T9AjwI6BjhSCTzGwjUj1Fkq9Q4t+6Vr2hJHi7QxTsCqqHSm91pB1pxFgk5bDs/Q6AbRF Dsnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775021280; x=1775626080; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+dtnjV/UQsHz5i0eYil7AmCFv4jaBC0RE9vTuxD9kdg=; b=SHgx8MVrQ7JNeULaPB6VlHFtSOLEimTVmLjzIxnI++CAfAs6RTBCM0R9pBqGHjOMNq 4rlzYVvebpVfNAU/NUkkxsDL0lTvD9HreEQLNNQuKsiR+tVrQyild+tg5xww5zmgn1c+ 9fv/Qy0jgom8IzKDhilyyyN+DP0yLmfkG/gFJD4UqDZc/qaZ72QIgEypk8RVRE81sPHU Bd4frIflPSJxQxmAST4IYkK0pjLzQtbo32q/Jft93d+8r6QcjHHhKMPQeJD55MDpX6OD Df+DbQnHtWaRAJWTUE4HO/VxpiNjKPRUXhgQ5aNiQY2cTsS4rCdOKKSt0n3Pk/LXBDel C3IQ== X-Forwarded-Encrypted: i=1; AJvYcCV9lkU/k8shWR9DCZWl74HHexOgC3rYfXRWTTjYQPOf/jaj4wo44Z1NBwxfccTPilRQ+vna9ZdYnHlWxuY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywc7EahbbYbdAV/4T3ZXcKgSX3o6qqvncoAxBqlAE1ZAeEV7Fkh Y9oNtDpCGYHiBeu9YFfYlACs4FxEtevQiAo3Jv+hE1L6DcTD9jwymqkPHDTOR+NOby+2k0nOX5f 3bDBN X-Gm-Gg: ATEYQzxyy0p6w2bkCwEwau+BBNswC5hq4H5F4Q1ESxY3E/1duIFT+rJ+/p2j/XdC00Z dxd04ccr8pfeiPLgG0n3uIv/CyFsr5naDT9O20mnv7KsvBa7XvfBpWaDhMobQp9OGO0R3TcrQag HY91e84OEaf/QpvUf+nISvrqQsYcXiJh+9YWVSgTQem8Z9WpeHNUbPBtD9wMHwHMpZ6xjUDxSS8 VnCHnKmfffPUFwTLwV9QrTVs6AH3CegByU+3J6j1J39tv+rxXqpUr/szk4/VUE3AdpBOAro7VkO rqAb85oPqobmt6t/LccwA7Og7ZND76y60BXzFgZo4uTPQejudEfPofOmhWxrBWDBuNxitO31gf1 xgoFErtKUk5Ib2DyJ3uucFTMbN1pu6MKC44N/fnb0YiROZBwcvdOJV7Pjr8OARHpb3KlkknCs3t pseP3WK0+RCeRachkh6BuzhDpkNxLzNq530XfwNwgvTOYm98nxzg== X-Received: by 2002:a17:902:f708:b0:2b2:6cab:313c with SMTP id d9443c01a7336-2b26cab38b2mr12456065ad.20.1775021280346; Tue, 31 Mar 2026 22:28:00 -0700 (PDT) Received: from bms-ytl-d1-app-10-251-178-27 ([147.136.157.1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b24266b92fsm134019025ad.23.2026.03.31.22.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 22:27:59 -0700 (PDT) From: Leon Hwang To: netdev@vger.kernel.org Cc: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Leon Hwang Subject: [PATCH net-next] selftests/net: Add two xdp tests to xdp.py Date: Wed, 1 Apr 2026 13:27:46 +0800 Message-ID: <20260401052746.314667-1-leon.huangfu@shopee.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In "bpf: Disallow freplace on XDP with mismatched xdp_has_frags values" [1], these two XDP tests are suggested to add to xdp.py. 1. Verify the failure of attaching non-frag-capable prog to mtu=3D9k driver. 2. Verify the failure of updating frag-capable prog with non-frag-capable prog, when the frag-capable prog attaches to mtu=3D9k driver. They have been verified against Mellanox CX6 and Intel 82599ES NICs. With dropping other tests, here are the test logs. # ethtool -i eth0 driver: mlx5_core version: 6.19.0-061900-generic # NETIF=3Deth0 python3 xdp.py TAP version 13 1..2 ok 1 xdp.test_xdp_native_attach_sb_to_mb ok 2 xdp.test_xdp_native_update_mb_to_sb # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:0 error:0 # ethtool -i eth0 driver: ixgbe version: 6.19.0-061900-generic # NETIF=3Deth0 python3 xdp.py TAP version 13 1..2 ok 1 xdp.test_xdp_native_attach_sb_to_mb # SKIP RTNETLINK answers: Invalid= argument ok 2 xdp.test_xdp_native_update_mb_to_sb # SKIP RTNETLINK answers: Invalid= argument # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:2 error:0 Links: [1] https://lore.kernel.org/bpf/20260326124205.1a3bb825@kernel.org/ Signed-off-by: Leon Hwang --- tools/testing/selftests/drivers/net/xdp.py | 53 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/xdp.py b/tools/testing/sel= ftests/drivers/net/xdp.py index d86446569f89..fe34b491778b 100755 --- a/tools/testing/selftests/drivers/net/xdp.py +++ b/tools/testing/selftests/drivers/net/xdp.py @@ -13,7 +13,7 @@ from enum import Enum =20 from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ge, ksft_ne, ksft_pr from lib.py import KsftNamedVariant, ksft_variants -from lib.py import KsftFailEx, NetDrvEpEnv +from lib.py import KsftFailEx, KsftSkipEx, NetDrvEpEnv from lib.py import EthtoolFamily, NetdevFamily, NlError from lib.py import bkg, cmd, rand_port, wait_port_listen from lib.py import ip, defer @@ -693,6 +693,55 @@ def test_xdp_native_qstats(cfg, act): ksft_ge(after['tx-packets'], before['tx-packets']) =20 =20 +def _set_jumbo_mtu(cfg, mtu): + ip(f"link set dev {cfg.ifname} mtu {mtu}") + defer(ip, f"link set dev {cfg.ifname} mtu 1500") + + +def _exec_cmd(cfg, obj, sec, ip_opts=3D""): + return cmd(f"ip {ip_opts} link set dev {cfg.ifname} xdpdrv obj {obj} s= ec {sec}", shell=3DTrue, fail=3DFalse) + + +def test_xdp_native_attach_sb_to_mb(cfg): + obj =3D cfg.net_lib_dir / "xdp_dummy.bpf.o" + mtu =3D 9000 + + _set_jumbo_mtu(cfg, mtu) + + probe =3D _exec_cmd(cfg, obj, "xdp.frags") + if probe.ret !=3D 0: + output =3D probe.stderr.strip() or probe.stdout.strip() + raise KsftSkipEx(output or "device does not support multi-buffer X= DP") + + ip(f"link set dev {cfg.ifname} xdpdrv off") + + probe =3D _exec_cmd(cfg, obj, "xdp") + if probe.ret =3D=3D 0: + ip(f"link set dev {cfg.ifname} xdpdrv off") + raise KsftFailEx(f"driver unexpectedly allows non-multi-buffer XDP= at MTU {mtu}") + + +def test_xdp_native_update_mb_to_sb(cfg): + obj =3D cfg.net_lib_dir / "xdp_dummy.bpf.o" + + _set_jumbo_mtu(cfg, 9000) + + attach =3D _exec_cmd(cfg, obj, "xdp.frags") + if attach.ret !=3D 0: + output =3D attach.stderr.strip() or attach.stdout.strip() + raise KsftSkipEx(output or "device does not support multi-buffer X= DP") + + defer(ip, f"link set dev {cfg.ifname} xdpdrv off") + + update1 =3D _exec_cmd(cfg, obj, "xdp.frags", "-force") + if update1.ret !=3D 0: + raise KsftFailEx("device fails to update multi-buffer XDP") + + update2 =3D _exec_cmd(cfg, obj, "xdp", "-force") + if update2.ret =3D=3D 0: + raise KsftFailEx("device unexpectedly updates non-multi-buffer XDP= ") + + def main(): """ Main function to execute the XDP tests. @@ -718,6 +767,8 @@ def main(): test_xdp_native_adjst_head_grow_data, test_xdp_native_adjst_head_shrnk_data, test_xdp_native_qstats, + test_xdp_native_attach_sb_to_mb, + test_xdp_native_update_mb_to_sb, ], args=3D(cfg,)) ksft_exit() --=20 2.53.0