Skip to contentSkip to conversation

iplink: add support for setting IPv4 devconf parameters

PATCH In review Fernando Fernandez Mancera 3 participants 10 messages Jun 1 – Jun 4

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

PATCH 1/1 iplink: add support for setting IPv4 devconf parameters

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

---
 ip/iplink.c           | 354 ++++++++++++++++++++++++++++++++++++++++++
 man/man8/ip-link.8.in |  81 ++++++++++
 2 files changed, 435 insertions(+)
ip/iplink.c +354 -0
index 2c052d29..38bdc71f 100644
@@ -19,6 +19,7 @@
 #include <arpa/inet.h>
 #include <linux/if.h>
 #include <linux/if_ether.h>
+#include <linux/ip.h>
 
 #include "rt_names.h"
 #include "utils.h"
@@ -102,6 +103,23 @@ void iplink_usage(void)
 		"		[ master DEVICE ][ vrf NAME ]\n"
 		"		[ nomaster ]\n"
 		"		[ addrgenmode { eui64 | none | stable_secret | random } ]\n"
+		"		[ inet [ { forwarding | proxy_arp | accept_redirects |\n"
+		"			   secure_redirects | send_redirects | shared_media |\n"
+		"			   accept_source_route | bootp_relay | log_martians |\n"
+		"			   arp_filter | disable_xfrm | disable_policy |\n"
+		"			   promote_secondaries | arp_notify | accept_local |\n"
+		"			   src_vmark | proxy_arp_pvlan | route_localnet |\n"
+		"			   bc_forwarding | ignore_routes_with_linkdown |\n"
+		"			   drop_unicast_in_l2_multicast |\n"
+		"			   drop_gratuitous_arp | arp_evict_nocarrier } { on | off } ]\n"
+		"		       [ rp_filter { 0 | 1 | 2 } ]\n"
+		"		       [ arp_announce { 0 | 1 | 2 } ]\n"
+		"		       [ arp_ignore { 0 | 1 | ... | 8 } ]\n"
+		"		       [ arp_accept { 0 | 1 | 2 } ]\n"
+		"		       [ force_igmp_version { 0 | 1 | 2 | 3 } ]\n"
+		"		       [ tag TAG ] [ medium_id ID ]\n"
+		"		       [ igmpv2_unsolicited_report_interval INTERVAL ]\n"
+		"		       [ igmpv3_unsolicited_report_interval INTERVAL ] ]\n"
 		"		[ protodown { on | off } ]\n"
 		"		[ protodown_reason PREASON { on | off } ]\n"
 		"		[ gso_max_size BYTES ] [ gso_ipv4_max_size BYTES ] [ gso_max_segs PACKETS ]\n"
@@ -551,6 +569,339 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
 	return 0;
 }
 
+static int iplink_parse_inet(int *argcp, char ***argvp, struct iplink_req *req)
+{
+	struct rtattr *afs, *afinet, *inet_devconf;
+	char **argv = *argvp;
+	int argc = *argcp;
+	int ret;
+
+	afs = addattr_nest(&req->n, sizeof(*req), IFLA_AF_SPEC);
+	afinet = addattr_nest(&req->n, sizeof(*req), AF_INET);
+	inet_devconf = addattr_nest(&req->n, sizeof(*req), IFLA_INET_CONF);
+
+	while (NEXT_ARG_OK()) {
+		NEXT_ARG();
+		if (matches(*argv, "forwarding") == 0) {
+			int forwarding;
+
+			NEXT_ARG();
+			forwarding = parse_on_off("forwarding", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_FORWARDING, forwarding);
+		} else if (matches(*argv, "proxy_arp") == 0) {
+			int proxy_arp;
+
+			NEXT_ARG();
+			proxy_arp = parse_on_off("proxy_arp", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_PROXY_ARP, proxy_arp);
+		} else if (matches(*argv, "accept_redirects") == 0) {
+			int accept_redirects;
+
+			NEXT_ARG();
+			accept_redirects = parse_on_off("accept_redirects", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ACCEPT_REDIRECTS, accept_redirects);
+		} else if (matches(*argv, "secure_redirects") == 0) {
+			int secure_redirects;
+
+			NEXT_ARG();
+			secure_redirects = parse_on_off("secure_redirects", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_SECURE_REDIRECTS, secure_redirects);
+		} else if (matches(*argv, "send_redirects") == 0) {
+			int send_redirects;
+
+			NEXT_ARG();
+			send_redirects = parse_on_off("send_redirects", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_SEND_REDIRECTS, send_redirects);
+		} else if (matches(*argv, "shared_media") == 0) {
+			int shared_media;
+
+			NEXT_ARG();
+			shared_media = parse_on_off("shared_media", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_SHARED_MEDIA, shared_media);
+		} else if (matches(*argv, "rp_filter") == 0) {
+			int rp_filter;
+
+			NEXT_ARG();
+			if (get_integer(&rp_filter, *argv, 0)) {
+				invarg("Invalid \"rp_filter\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_RP_FILTER, rp_filter);
+		} else if (matches(*argv, "accept_source_route") == 0) {
+			int accept_source_route;
+
+			NEXT_ARG();
+			accept_source_route = parse_on_off("accept_source_route", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE, accept_source_route);
+		} else if (matches(*argv, "bootp_relay") == 0) {
+			int bootp_relay;
+
+			NEXT_ARG();
+			bootp_relay = parse_on_off("bootp_relay", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_BOOTP_RELAY, bootp_relay);
+		} else if (matches(*argv, "log_martians") == 0) {
+			int log_martians;
+
+			NEXT_ARG();
+			log_martians = parse_on_off("log_martians", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_LOG_MARTIANS, log_martians);
+		} else if (matches(*argv, "tag") == 0) {
+			int tag;
+
+			NEXT_ARG();
+			if (get_integer(&tag, *argv, 0)) {
+				invarg("Invalid \"tag\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_TAG, tag);
+		} else if (matches(*argv, "arp_filter") == 0) {
+			int arp_filter;
+
+			NEXT_ARG();
+			arp_filter = parse_on_off("arp_filter", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARPFILTER, arp_filter);
+		} else if (matches(*argv, "medium_id") == 0) {
+			int medium_id;
+
+			NEXT_ARG();
+			if (get_integer(&medium_id, *argv, 0)) {
+				invarg("Invalid \"medium_id\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_MEDIUM_ID, medium_id);
+		} else if (matches(*argv, "disable_xfrm") == 0) {
+			int disable_xfrm;
+
+			NEXT_ARG();
+			disable_xfrm = parse_on_off("disable_xfrm", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_NOXFRM, disable_xfrm);
+		} else if (matches(*argv, "disable_policy") == 0) {
+			int disable_policy;
+
+			NEXT_ARG();
+			disable_policy = parse_on_off("disable_policy", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_NOPOLICY, disable_policy);
+		} else if (matches(*argv, "force_igmp_version") == 0) {
+			int force_igmp_version;
+
+			NEXT_ARG();
+			if (get_integer(&force_igmp_version, *argv, 0)) {
+				invarg("Invalid \"force_igmp_version\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_FORCE_IGMP_VERSION, force_igmp_version);
+		} else if (matches(*argv, "arp_announce") == 0) {
+			int arp_announce;
+
+			NEXT_ARG();
+			if (get_integer(&arp_announce, *argv, 0)) {
+				invarg("Invalid \"arp_announce\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARP_ANNOUNCE, arp_announce);
+		} else if (matches(*argv, "arp_ignore") == 0) {
+			int arp_ignore;
+
+			NEXT_ARG();
+			if (get_integer(&arp_ignore, *argv, 0)) {
+				invarg("Invalid \"arp_ignore\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARP_IGNORE, arp_ignore);
+		} else if (matches(*argv, "promote_secondaries") == 0) {
+			int promote_secondaries;
+
+			NEXT_ARG();
+			promote_secondaries = parse_on_off("promote_secondaries", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_PROMOTE_SECONDARIES, promote_secondaries);
+		} else if (matches(*argv, "arp_accept") == 0) {
+			int arp_accept;
+
+			NEXT_ARG();
+			if (get_integer(&arp_accept, *argv, 0)) {
+				invarg("Invalid \"arp_accept\" value\n", *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARP_ACCEPT, arp_accept);
+		} else if (matches(*argv, "arp_notify") == 0) {
+			int arp_notify;
+
+			NEXT_ARG();
+			arp_notify = parse_on_off("arp_notify", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARP_NOTIFY, arp_notify);
+		} else if (matches(*argv, "accept_local") == 0) {
+			int accept_local;
+
+			NEXT_ARG();
+			accept_local = parse_on_off("accept_local", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ACCEPT_LOCAL, accept_local);
+		} else if (matches(*argv, "src_vmark") == 0) {
+			int src_vmark;
+
+			NEXT_ARG();
+			src_vmark = parse_on_off("src_vmark", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_SRC_VMARK, src_vmark);
+		} else if (matches(*argv, "proxy_arp_pvlan") == 0) {
+			int proxy_arp_pvlan;
+
+			NEXT_ARG();
+			proxy_arp_pvlan = parse_on_off("proxy_arp_pvlan", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_PROXY_ARP_PVLAN, proxy_arp_pvlan);
+		} else if (matches(*argv, "route_localnet") == 0) {
+			int route_localnet;
+
+			NEXT_ARG();
+			route_localnet = parse_on_off("route_localnet", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ROUTE_LOCALNET, route_localnet);
+		} else if (matches(*argv, "bc_forwarding") == 0) {
+			int bc_forwarding;
+
+			NEXT_ARG();
+			bc_forwarding = parse_on_off("bc_forwarding", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_BC_FORWARDING, bc_forwarding);
+		} else if (matches(*argv, "igmpv2_unsolicited_report_interval") == 0) {
+			int igmpv2_interval;
+
+			NEXT_ARG();
+			if (get_integer(&igmpv2_interval, *argv, 0)) {
+				invarg("Invalid \"igmpv2_unsolicited_report_interval\" value\n",
+				       *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL, igmpv2_interval);
+		} else if (matches(*argv, "igmpv3_unsolicited_report_interval") == 0) {
+			int igmpv3_interval;
+
+			NEXT_ARG();
+			if (get_integer(&igmpv3_interval, *argv, 0)) {
+				invarg("Invalid \"igmpv3_unsolicited_report_interval\" value\n",
+				       *argv);
+				return -1;
+			}
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL, igmpv3_interval);
+		} else if (matches(*argv, "ignore_routes_with_linkdown") == 0) {
+			int ignore_routes_linkdown;
+
+			NEXT_ARG();
+			ignore_routes_linkdown = parse_on_off("ignore_routes_with_linkdown",
+							      *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN, ignore_routes_linkdown);
+		} else if (matches(*argv, "drop_unicast_in_l2_multicast") == 0) {
+			int drop_unicast_mcast;
+
+			NEXT_ARG();
+			drop_unicast_mcast = parse_on_off("drop_unicast_in_l2_multicast",
+							  *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST, drop_unicast_mcast);
+		} else if (matches(*argv, "drop_gratuitous_arp") == 0) {
+			int drop_gratuitous_arp;
+
+			NEXT_ARG();
+			drop_gratuitous_arp = parse_on_off("drop_gratuitous_arp", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_DROP_GRATUITOUS_ARP, drop_gratuitous_arp);
+		} else if (matches(*argv, "arp_evict_nocarrier") == 0) {
+			int arp_evict_nocarrier;
+
+			NEXT_ARG();
+			arp_evict_nocarrier = parse_on_off("arp_evict_nocarrier", *argv, &ret);
+			if (ret)
+				return ret;
+			addattr32(&req->n, sizeof(*req),
+				  IPV4_DEVCONF_ARP_EVICT_NOCARRIER, arp_evict_nocarrier);
+		} else {
+			/* rewind arg */
+			PREV_ARG();
+			break;
+		}
+	}
+
+	if (argc == *argcp)
+		incomplete_command();
+
+	addattr_nest_end(&req->n, inet_devconf);
+	addattr_nest_end(&req->n, afinet);
+	addattr_nest_end(&req->n, afs);
+
+	*argcp = argc;
+	*argvp = argv;
+	return 0;
+}
+
 int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 {
 	bool move_netns = false;
@@ -634,6 +985,9 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 			if (get_integer(&mtu, *argv, 0))
 				invarg("Invalid \"mtu\" value\n", *argv);
 			addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
+		} else if (strcmp(*argv, "inet") == 0) {
+			if (iplink_parse_inet(&argc, &argv, req) < 0)
+				return -1;
 		} else if (strcmp(*argv, "xdpgeneric") == 0 ||
 			   strcmp(*argv, "xdpdrv") == 0 ||
 			   strcmp(*argv, "xdpoffload") == 0 ||
man/man8/ip-link.8.in +81 -0

93 lines not on this page · raw message

Signature · 1 line
2.54.0
#1 lore raw
Quoted 11 lines · Fernando Fernandez Mancera

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

If an attribute can be set this way, then ip link show needs to show the values. What's the plan on that front?

Quoted 7 lines
---
 ip/iplink.c           | 354 ++++++++++++++++++++++++++++++++++++++++++
 man/man8/ip-link.8.in |  81 ++++++++++
 2 files changed, 435 insertions(+)

...

Quoted 9 lines
ip/iplink.c +4 -0
 		"		[ gso_max_size BYTES ] [ gso_ipv4_max_size BYTES ] [ gso_max_segs PACKETS ]\n"
@@ -551,6 +569,339 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
 	return 0;
 }
 
+static int iplink_parse_inet(int *argcp, char ***argvp, struct iplink_req *req)
+{
+	struct rtattr *afs, *afinet, *inet_devconf;
+	char **argv = *argvp;

ip/iplink.c static int iplink_parse_vf(int vf, int *argcp, char ***argvp, · line 585

Quoted 10 lines
ip/iplink.c +10 -0
+	int argc = *argcp;
+	int ret;
+
+	afs = addattr_nest(&req->n, sizeof(*req), IFLA_AF_SPEC);
+	afinet = addattr_nest(&req->n, sizeof(*req), AF_INET);
+	inet_devconf = addattr_nest(&req->n, sizeof(*req), IFLA_INET_CONF);
+
+	while (NEXT_ARG_OK()) {
+		NEXT_ARG();
+		if (matches(*argv, "forwarding") == 0) {

new uses of matches are not allowed. If s/matches/strcmp/ is the only comment, I can fix up before applying.

#2 lore raw
Quoted 9 lines · David Ahern
Quoted 8 lines · Fernando Fernandez Mancera

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Quoted 7 lines
Quoted 3 lines

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

If an attribute can be set this way, then ip link show needs to show the values. What's the plan on that front?

I could introduce it in a follow-up patch. I guess it makes sense to introduce it for ip -d link show only, right? I am happy to work on it anyway.

Quoted 24 lines
Quoted 7 lines
---
  ip/iplink.c           | 354 ++++++++++++++++++++++++++++++++++++++++++
  man/man8/ip-link.8.in |  81 ++++++++++
  2 files changed, 435 insertions(+)

...

Quoted 14 lines

" [ gso_max_size BYTES ] [ gso_ipv4_max_size BYTES ] [ gso_max_segs PACKETS ]\n"

ip/iplink.c +9 -0
@@ -551,6 +569,339 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
  	return 0;
  }
 
+static int iplink_parse_inet(int *argcp, char ***argvp, struct iplink_req *req)
+{
+	struct rtattr *afs, *afinet, *inet_devconf;
+	char **argv = *argvp;
+	int argc = *argcp;
+	int ret;
+
+	afs = addattr_nest(&req->n, sizeof(*req), IFLA_AF_SPEC);
+	afinet = addattr_nest(&req->n, sizeof(*req), AF_INET);
Quoted 9 lines

ip/iplink.c static int iplink_parse_vf(int vf, int *argcp, char ***argvp, · line 585

Quoted 5 lines
ip/iplink.c +5 -0
+	inet_devconf = addattr_nest(&req->n, sizeof(*req), IFLA_INET_CONF);
+
+	while (NEXT_ARG_OK()) {
+		NEXT_ARG();
+		if (matches(*argv, "forwarding") == 0) {

new uses of matches are not allowed. If s/matches/strcmp/ is the only comment, I can fix up before applying.

Sorry I didn't know this. Thanks.

#3 lore raw
Quoted 14 lines · Fernando Fernandez Mancera
Quoted 13 lines · David Ahern
Quoted 11 lines · Fernando Fernandez Mancera

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

Quoted 7 lines
Quoted 3 lines

If an attribute can be set this way, then ip link show needs to show the values. What's the plan on that front?

I could introduce it in a follow-up patch. I guess it makes sense to introduce it for ip -d link show only, right? I am happy to work on it anyway.

yes, -d only.

Will give Nicolas a chance to review.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Fernando Fernandez Mancera

Le 01/06/2026 à 16:32, Fernando Fernandez Mancera a écrit :

Quoted 5 lines

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

Quoted 8 lines

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

Do you plan to add the ipv6 part also?

#5 lore raw
Quoted 9 lines · Nicolas Dichtel

Le 01/06/2026 à 16:32, Fernando Fernandez Mancera a écrit :

Quoted 8 lines

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Quoted 8 lines
Quoted 5 lines

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

Do you plan to add the ipv6 part also?

Yes, it is cooking but I want to get merged IPv4 first.

Thanks!

#6 lore raw
Quoted 12 lines · Fernando Fernandez Mancera
Quoted 11 lines · Nicolas Dichtel

Le 01/06/2026 à 16:32, Fernando Fernandez Mancera a écrit :

Quoted 10 lines

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

ip link set dev enp8s0 inet forwarding on

Do you plan to add the ipv6 part also?

Yes, it is cooking but I want to get merged IPv4 first.

If I merge the ipv4 patch today that means you are signing up to send patches for ipv6 set and then ipv4 and ipv6 show in detailed device dump. All of that in the next 2 weeks before 7.1 is released. Just want to make sure we are clear on expectations.

With respect to this patch, the usage is getting long and wading through all of the inet and then inet6 options is going to be a challenge.

Stephen: opinions on location and details? Should the list even be in the usage vs only the man page? ie., usage just has [ inet <devconf options> ] (and similar for inet6)? If the all of the options stay listed in the usage they should be in alphabetical order (and added after the existing gro_max_size line?).

#7 lore raw
Quoted 20 lines · David Ahern
Quoted 19 lines · Fernando Fernandez Mancera
Quoted 17 lines · Nicolas Dichtel

Le 01/06/2026 à 16:32, Fernando Fernandez Mancera a écrit :

Quoted 5 lines

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

Quoted 8 lines

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

Do you plan to add the ipv6 part also?

Quoted 8 lines
Quoted 2 lines

Yes, it is cooking but I want to get merged IPv4 first.

If I merge the ipv4 patch today that means you are signing up to send patches for ipv6 set and then ipv4 and ipv6 show in detailed device dump. All of that in the next 2 weeks before 7.1 is released. Just want to make sure we are clear on expectations.

Sounds good to me. I am already working on it.

Thanks.

Quoted 8 lines

With respect to this patch, the usage is getting long and wading through all of the inet and then inet6 options is going to be a challenge.

Stephen: opinions on location and details? Should the list even be in the usage vs only the man page? ie., usage just has [ inet <devconf options> ] (and similar for inet6)? If the all of the options stay listed in the usage they should be in alphabetical order (and added after the existing gro_max_size line?).

#8 lore raw
Quoted 24 lines · Fernando Fernandez Mancera
Quoted 23 lines · David Ahern
Quoted 21 lines · Fernando Fernandez Mancera
Quoted 9 lines · Nicolas Dichtel

Le 01/06/2026 à 16:32, Fernando Fernandez Mancera a écrit :

Quoted 8 lines

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Quoted 8 lines
Quoted 5 lines

Example to enable forwarding on an interface:

ip link set dev enp8s0 inet forwarding on

Do you plan to add the ipv6 part also?

Yes, it is cooking but I want to get merged IPv4 first.

Quoted 8 lines
Quoted 5 lines

If I merge the ipv4 patch today that means you are signing up to send patches for ipv6 set and then ipv4 and ipv6 show in detailed device dump. All of that in the next 2 weeks before 7.1 is released. Just want to make sure we are clear on expectations.

Sounds good to me. I am already working on it.

Just to clarify, the IPv6 support depends on a series I am testing for kernel as the current support is quite poor. The "get" operation is rather simple and works fine without any kernel patch.

#9 lore raw
In reply to Fernando Fernandez Mancera
Quoted 10 lines · Fernando Fernandez Mancera

Currently, modifying IPv4 interface configuration parameters requires interacting with sysctl (/proc/sys/net/ipv4/conf/*). While ip-netconf exists for monitoring these values, there has been no native way to set them directly through iproute2.

This patch introduces the support for that via 'inet' at the 'ip link set'. It uses IFLA_INET_CONF netlink attribute to set the parameter.

Example to enable forwarding on an interface:

Quoted 8 lines

ip link set dev enp8s0 inet forwarding on

---
 ip/iplink.c           | 354 ++++++++++++++++++++++++++++++++++++++++++
 man/man8/ip-link.8.in |  81 ++++++++++
 2 files changed, 435 insertions(+)

applied to iproute2-next after s/matches/strcmp/ and fixed up the code to keep lines of reasonable length. iproute2 follows netdev with coding standards and those need to be followed as long as humans are in the loop. Please make sure follow on patches adhere to roughly 80 columns with a little extra if it improves readability (and of course strings are not broken across lines).

claude had one quibble with the man page update - please send a fixup:

1. Man page indent imbalance (visible bug) — man/man8/ip-link.8.in synopsis opens the inet block with .in +8 but closes with .in -10. Confirmed by rendering with groff: the [ macaddr ... ] line and everything after it is indented 2 columns to the left of the baseline. Should be .in -8. The detailed-description section (~lines 2661/2699) is already correctly paired.