From: David Keogh <dkeogh@amazon.com>
To: <netdev@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@kernel.org>
Cc: Dragos Tatulea <dtatulea@nvidia.com>,
Nimrod Oren <noren@nvidia.com>, <nh-open-source@amazon.com>,
<linux-kernel@vger.kernel.org>
Subject: [RFC net-next 4/6] selftests: net: add tx_extra_headroom test
Date: Thu, 15 Oct 2026 23:53:33 +0000 [thread overview]
Message-ID: <20261015235335.4162993-5-dkeogh@amazon.com> (raw)
In-Reply-To: <20261015235335.4162993-1-dkeogh@amazon.com>
Exercise the IFLA_TX_EXTRA_HEADROOM attribute through YNL: the default
of zero, setting values up to the maximum and back to zero, rejection
of a value above the maximum, supplying the attribute at link creation,
the change notification, persistence across link down/up and across a
network namespace move, and that a VLAN created on top of a configured
device does not inherit the setting.
Signed-off-by: David Keogh <dkeogh@amazon.com>
---
tools/testing/selftests/net/Makefile | 1 +
| 137 ++++++++++++++++++
2 files changed, 138 insertions(+)
create mode 100755 tools/testing/selftests/net/tx_extra_headroom.py
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 54beea2e3..0eb9a69e9 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -120,6 +120,7 @@ TEST_PROGS := \
test_vxlan_vnifiltering.sh \
tfo_passive.sh \
traceroute.sh \
+ tx_extra_headroom.py \
txtimestamp.sh \
udpgro.sh \
udpgro_bench.sh \
--git a/tools/testing/selftests/net/tx_extra_headroom.py b/tools/testing/selftests/net/tx_extra_headroom.py
new file mode 100755
index 000000000..f6f087e98
--- /dev/null
+++ b/tools/testing/selftests/net/tx_extra_headroom.py
@@ -0,0 +1,137 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Tests for the IFLA_TX_EXTRA_HEADROOM link attribute."""
+
+from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, ksft_true
+from lib.py import ip
+from lib.py import NetNS, NetNSEnter
+from lib.py import Netlink, NlError, RtnlFamily
+
+ATTR = "tx-extra-headroom"
+MAX = 512
+
+
+def ifindex(name):
+ return ip(f"link show dev {name}", json=True)[0]["ifindex"]
+
+
+def get(rtnl, idx):
+ return rtnl.getlink({"ifi-index": idx})[ATTR]
+
+
+def set_(rtnl, idx, val):
+ rtnl.setlink({"ifi-index": idx, ATTR: val})
+
+
+def test_default_and_set() -> None:
+ """Default is 0, values up to the maximum are accepted, 0 resets."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ ip("link add d0 type dummy")
+ rtnl = RtnlFamily()
+ idx = ifindex("d0")
+
+ ksft_eq(get(rtnl, idx), 0)
+ for val in (1, 256, MAX):
+ set_(rtnl, idx, val)
+ ksft_eq(get(rtnl, idx), val)
+ set_(rtnl, idx, 0)
+ ksft_eq(get(rtnl, idx), 0)
+
+
+def test_reject_above_max() -> None:
+ """Values above the maximum are rejected by the policy."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ ip("link add d0 type dummy")
+ rtnl = RtnlFamily()
+ idx = ifindex("d0")
+
+ set_(rtnl, idx, 128)
+ with ksft_raises(NlError):
+ set_(rtnl, idx, MAX + 1)
+ ksft_eq(get(rtnl, idx), 128)
+
+
+def test_newlink() -> None:
+ """The attribute can be supplied when the link is created."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ rtnl = RtnlFamily()
+ rtnl.newlink({"ifname": "d0", "linkinfo": {"kind": "dummy"},
+ ATTR: 64},
+ flags=[Netlink.NLM_F_CREATE, Netlink.NLM_F_EXCL])
+ ksft_eq(get(rtnl, ifindex("d0")), 64)
+
+
+def test_notification() -> None:
+ """A change produces a link notification carrying the new value."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ ip("link add d0 type dummy")
+ ip("link set dev d0 up")
+ rtnl = RtnlFamily()
+ idx = ifindex("d0")
+
+ rtnl.ntf_subscribe("rtnlgrp-link")
+ set_(rtnl, idx, 192)
+
+ seen = None
+ for msg in rtnl.poll_ntf(duration=1):
+ if msg["name"] == "getlink" and msg["msg"]["ifi-index"] == idx:
+ seen = msg["msg"][ATTR]
+ break
+ ksft_eq(seen, 192)
+
+
+def test_survives_down_up() -> None:
+ """Toggling the link does not reset the value."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ ip("link add d0 type dummy")
+ rtnl = RtnlFamily()
+ idx = ifindex("d0")
+
+ set_(rtnl, idx, 96)
+ ip("link set dev d0 up")
+ ksft_eq(get(rtnl, idx), 96)
+ ip("link set dev d0 down")
+ ksft_eq(get(rtnl, idx), 96)
+
+
+def test_survives_netns_move() -> None:
+ """Moving the link to another namespace keeps the value."""
+ with NetNS() as ns1, NetNS() as ns2:
+ with NetNSEnter(str(ns1)):
+ ip("link add d0 type dummy")
+ rtnl = RtnlFamily()
+ set_(rtnl, ifindex("d0"), 160)
+ ip(f"link set dev d0 netns {ns2}")
+
+ with NetNSEnter(str(ns2)):
+ rtnl = RtnlFamily()
+ ksft_eq(get(rtnl, ifindex("d0")), 160)
+
+
+def test_not_inherited() -> None:
+ """Stacked devices do not inherit the value of the device below."""
+ with NetNS() as ns, NetNSEnter(str(ns)):
+ ip("link add d0 type dummy")
+ rtnl = RtnlFamily()
+ set_(rtnl, ifindex("d0"), 224)
+
+ ip("link add link d0 name d0.10 type vlan id 10")
+ ksft_eq(get(rtnl, ifindex("d0.10")), 0)
+ ksft_true(rtnl.getlink({"ifi-index": ifindex("d0.10")})["headroom"]
+ >= 4, "vlan needed_headroom")
+
+
+def main() -> None:
+ ksft_run([test_default_and_set,
+ test_reject_above_max,
+ test_newlink,
+ test_notification,
+ test_survives_down_up,
+ test_survives_netns_move,
+ test_not_inherited])
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.50.1
next prev parent reply other threads:[~2026-10-15 23:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 23:53 [RFC net-next 0/6] net: configurable extra TX headroom for local egress David Keogh
2026-10-15 23:53 ` [RFC net-next 1/6] net: add tx_extra_headroom and LL_ALLOC_SPACE() David Keogh
2026-10-15 23:53 ` [RFC net-next 2/6] net: reserve extra TX headroom for local egress David Keogh
2026-10-15 23:53 ` [RFC net-next 3/6] rtnetlink: add IFLA_TX_EXTRA_HEADROOM David Keogh
2026-10-15 23:53 ` David Keogh [this message]
2026-10-15 23:53 ` [RFC net-next 5/6] selftests/bpf: add tx_extra_headroom data-plane programs David Keogh
2026-10-15 23:53 ` [RFC net-next 6/6] selftests/net: add tx_extra_headroom data-plane test David Keogh
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=20261015235335.4162993-5-dkeogh@amazon.com \
--to=dkeogh@amazon.com \
--cc=dtatulea@nvidia.com \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nh-open-source@amazon.com \
--cc=noren@nvidia.com \
--cc=pabeni@redhat.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