Skip to contentSkip to conversation

iplink: add tx_extra_headroom

PATCH New Tianyi Gao 1 participant 3 messages Nov 7

Subsystems (2)
lore
Share & tools
lore

Tianyi Gao

author
#0 lore raw

cover iplink: add tx_extra_headroom

Add support for IFLA_TX_EXTRA_HEADROOM, which the net-next series "net:
configurable extra TX headroom for local egress" adds:
https://lore.kernel.org/netdev/[email protected]/

Patch 1 updates if_link.h so that the series builds. Please drop it after the headers are synced with the kernel series.
Patch 2 adds the tx_extra_headroom option to ip link.

Tianyi Gao (2):
uapi: add IFLA_TX_EXTRA_HEADROOM
iplink: add tx_extra_headroom attribute

 include/uapi/linux/if_link.h |  1 +
 ip/ipaddress.c               |  6 ++++++
 ip/iplink.c                  | 10 ++++++++++
 man/man8/ip-link.8.in        | 13 +++++++++++++
 4 files changed, 30 insertions(+)

base-commit: 204a721033556114c81c47d00375f2d52e98e463

Signature · 1 line
2.56.0
author
#1 lore raw

PATCH 1/2 uapi: add IFLA_TX_EXTRA_HEADROOM

Add IFLA_TX_EXTRA_HEADROOM from the net-next series "net: configurable extra TX headroom for local egress".

---
 include/uapi/linux/if_link.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/if_link.h +1 -0
index 7ce01d81..21a26dc6 100644
@@ -382,6 +382,7 @@ enum {
 	IFLA_HEADROOM,
 	IFLA_TAILROOM,
 	IFLA_PACING_OFFLOAD,
+	IFLA_TX_EXTRA_HEADROOM,
 	__IFLA_MAX
 };
 
Signature · 1 line
2.56.0
author
#2 lore raw

PATCH 2/2 iplink: add tx_extra_headroom attribute

In reply to Tianyi Gao

Add support for IFLA_TX_EXTRA_HEADROOM, which sets and reports the extra TX headroom of a device.

$ ip link add veth0 tx_extra_headroom 256 type veth peer name veth1 tx_extra_headroom 256
$ ip -details link show veth0
12: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 22:5d:72:d3:f4:43 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    veth addrgenmode eui64 numtxqueues 8 numrxqueues 8 gso_max_size 65536 gso_max_segs 65535 tso_max_size 524280 tso_max_segs 65535 gro_max_size 65536 gso_ipv4_max_size 65536 gro_ipv4_max_size 65536 tx_extra_headroom 256
---
 ip/ipaddress.c        |  6 ++++++
 ip/iplink.c           | 10 ++++++++++
 man/man8/ip-link.8.in | 13 +++++++++++++
 3 files changed, 29 insertions(+)
ip/ipaddress.c +6 -0
index ff85792f..8442e5cb 100644
@@ -1238,6 +1238,12 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
 				   "gro_ipv4_max_size %u ",
 				   rta_getattr_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]));
 
+		if (tb[IFLA_TX_EXTRA_HEADROOM])
+			print_uint(PRINT_ANY,
+				   "tx_extra_headroom",
+				   "tx_extra_headroom %u ",
+				   rta_getattr_u32(tb[IFLA_TX_EXTRA_HEADROOM]));
+
 		if (tb[IFLA_PHYS_PORT_NAME])
 			print_string(PRINT_ANY,
 				     "phys_port_name",
ip/iplink.c +10 -0
index c6aee8b6..079b4a63 100644
@@ -124,6 +124,7 @@ void iplink_usage(void)
 		"		[ protodown_reason PREASON { on | off } ]\n"
 		"		[ gso_max_size BYTES ] [ gso_ipv4_max_size BYTES ] [ gso_max_segs PACKETS ]\n"
 		"		[ gro_max_size BYTES ] [ gro_ipv4_max_size BYTES ]\n"
+		"		[ tx_extra_headroom BYTES ]\n"
 		"\n"
 		"	ip link show [ DEVICE | group GROUP ] [ { up | down } ] [master DEV] [vrf NAME]\n"
 		"		[type TYPE] [nomaster] [ novf ]\n"
@@ -1247,6 +1248,15 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 				       *argv);
 			addattr32(&req->n, sizeof(*req),
 				  IFLA_GRO_IPV4_MAX_SIZE, max_size);
+		} else if (strcmp(*argv, "tx_extra_headroom") == 0) {
+			__u32 headroom;
+
+			NEXT_ARG();
+			if (get_u32(&headroom, *argv, 0))
+				invarg("Invalid \"tx_extra_headroom\" value\n",
+				       *argv);
+			addattr32(&req->n, sizeof(*req),
+				  IFLA_TX_EXTRA_HEADROOM, headroom);
 		} else if (strcmp(*argv, "parentdev") == 0) {
 			NEXT_ARG();
 			addattr_l(&req->n, sizeof(*req), IFLA_PARENT_DEV_NAME,
man/man8/ip-link.8.in +13 -0
index 719781bd..976d546e 100644
@@ -48,6 +48,9 @@ ip-link \- network device configuration
 .RB "[ " gro_ipv4_max_size
 .IR BYTES " ]"
 .br
+.RB "[ " tx_extra_headroom
+.IR BYTES " ]"
+.br
 .RB "[ " netns " {"
 .IR PID " | " NETNSNAME " | " NETNSFILE " } ]"
 .br
@@ -105,6 +108,9 @@ ip-link \- network device configuration
 .RB "[ " gro_ipv4_max_size
 .IR BYTES " ]"
 .br
+.RB "[ " tx_extra_headroom
+.IR BYTES " ]"
+.br
 .RB "[ " name
 .IR NEWNAME " ]"
 .br
@@ -514,6 +520,13 @@ specifies the maximum size of a IPv4 packet built by GRO stack on this
 device. This is especially used for BIG TCP to allow the size of a
 merged IPv4 GSO packet on this device greater than 65536.
 
+.TP
+.BI tx_extra_headroom " BYTES "
+specifies the extra TX headroom that is reserved when a UDP, ping, raw,
+AF_PACKET or AF_XDP (copy mode) socket allocates a packet for this
+device. It avoids a reallocation when a TC egress program adds headers,
+and a copy when generic XDP runs on the peer of a veth device.
+
 .TP
 .BI index " IDX "
 specifies the desired index of the new virtual device. The link
Signature · 1 line
2.56.0