Skip to contentSkip to conversation

rtnetlink: add needed_{head,tail}room attributes

PATCH In review Alasdair McWilliam 2 participants 3 messages Sep 17, 2025 – Sep 20, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 rtnetlink: add needed_{head,tail}room attributes

Various network interface types make use of needed_{head,tail}room values to efficiently reserve buffer space for additional encapsulation headers, such as VXLAN, Geneve, IPSec, etc. However, it is not currently possible to query these values in a generic way.

Introduce ability to query the needed_{head,tail}room values of a network device via rtnetlink, such that applications that may wish to use these values can do so.

For example, Cilium agent iterates over present devices based on user config (direct routing, vxlan, geneve, wireguard etc.) and in future will configure netkit in order to expose the needed_{head,tail}room into K8s pods. See b9ed315d3c4c ("netkit: Allow for configuring needed_{head,tail}room").

---
v1 -> v2:
- Corrected attribute types to IFA_REJECT in validation policy.
- Added additional context in commit log.

 include/uapi/linux/if_link.h |  2 ++
 net/core/rtnetlink.c         | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
include/uapi/linux/if_link.h +2 -0
index 45f56c9f95d9..3b491d96e52e 100644
@@ -379,6 +379,8 @@ enum {
 	IFLA_DPLL_PIN,
 	IFLA_MAX_PACING_OFFLOAD_HORIZON,
 	IFLA_NETNS_IMMUTABLE,
+	IFLA_HEADROOM,
+	IFLA_TAILROOM,
 	__IFLA_MAX
 };
 
net/core/rtnetlink.c +9 -1
index 094b085cff20..d9e68ca84926 100644
@@ -1326,6 +1326,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + rtnl_devlink_port_size(dev)
 	       + rtnl_dpll_pin_size(dev)
 	       + nla_total_size(8)  /* IFLA_MAX_PACING_OFFLOAD_HORIZON */
+	       + nla_total_size(2)  /* IFLA_HEADROOM */
+	       + nla_total_size(2)  /* IFLA_TAILROOM */
 	       + 0;
 }
 
@@ -2091,7 +2093,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 	    nla_put_u32(skb, IFLA_CARRIER_UP_COUNT,
 			atomic_read(&dev->carrier_up_count)) ||
 	    nla_put_u32(skb, IFLA_CARRIER_DOWN_COUNT,
-			atomic_read(&dev->carrier_down_count)))
+			atomic_read(&dev->carrier_down_count)) ||
+	    nla_put_u16(skb, IFLA_HEADROOM,
+			READ_ONCE(dev->needed_headroom)) ||
+	    nla_put_u16(skb, IFLA_TAILROOM,
+			READ_ONCE(dev->needed_tailroom)))
 		goto nla_put_failure;
 
 	if (rtnl_fill_proto_down(skb, dev))
@@ -2243,6 +2249,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_GSO_IPV4_MAX_SIZE]	= NLA_POLICY_MIN(NLA_U32, MAX_TCP_HEADER + 1),
 	[IFLA_GRO_IPV4_MAX_SIZE]	= { .type = NLA_U32 },
 	[IFLA_NETNS_IMMUTABLE]	= { .type = NLA_REJECT },
+	[IFLA_HEADROOM]		= { .type = NLA_REJECT },
+	[IFLA_TAILROOM]		= { .type = NLA_REJECT },
 };
 
 static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 2/2 rtnetlink: specs: Add {head,tail}room to rt-link.yaml

Add {head,tail}room attributes to rt-link.yaml spec file.

Example:

$ tools/net/ynl/pyynl/cli.py \
  --spec Documentation/netlink/specs/rt-link.yaml \
  --do getlink --json '{"ifname":"enp0s1"}' --output-json \
  | jq -r '{ifname,mtu,headroom,tailroom}'
{
  "ifname": "enp0s1",
  "mtu": 1500,
  "headroom": 12,
  "tailroom": 0
}
---
 Documentation/netlink/specs/rt-link.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/netlink/specs/rt-link.yaml +6 -0
index 6ab31f86854d..2a23e9699c0b 100644
@@ -1057,6 +1057,12 @@ attribute-sets:
       -
         name: netns-immutable
         type: u8
+      -
+        name: headroom
+        type: u16
+      -
+        name: tailroom
+        type: u16
   -
     name: prop-list-link-attrs
     subset-of: link-attrs
Signature · 1 line
2.47.3
maintainer
#2 lore raw

Re: [PATCH net-next v2 2/2] rtnetlink: specs: Add {head,tail}room to rt-link.yaml

Quoted 1 line · On Wed, 17 Sep 2025 10:55:43 +0100 Alasdair McWilliam wrote:

Add {head,tail}room attributes to rt-link.yaml spec file.

Not sure this makes sense as a separate commit.

Squashed and applied, thanks!