[PATCH net-next v2] ipv6: Add NETCONFA_FORCE_FORWARDING to netconf messages

From: Gabriel Goller

Date: Wed Nov 04 2026 - 04:48:01 EST


Since force_forwarding was added, changing the sysctl sends an
RTM_NEWNETCONF notification of type NETCONFA_FORCE_FORWARDING, but
inet6_netconf_fill_devconf() never emits the attribute. Listeners only
receive NETCONFA_IFINDEX without the new value, and RTM_GETNETCONF
replies and dumps omit it as well.

Also send a notification when disabling all.forwarding resets
force_forwarding on an interface, which previously happened silently.

Fixes: f24987ef6959 ("ipv6: add `force_forwarding` sysctl to enable per-interface forwarding")
Signed-off-by: Gabriel Goller <g.goller@xxxxxxxxxxx>
---
iproute2 patch here:
https://lore.kernel.org/netdev/20261028-ip_netconf_show-v1-1-a20fc6b20025@xxxxxxxxxxx/

Changes in v2:
- Emit when net.ipv6.conf.all.forwarding is disabled (thanks @Ido Schimmel)
- Rebase onto net-next
- Link to v1: https://lore.kernel.org/20261023-ipv6_add_netconfa-v1-1-94d14b07d621@xxxxxxxxxxx
---
net/ipv6/addrconf.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c8c0dd04982d..1df6c1db472f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -529,6 +529,9 @@ static int inet6_netconf_msgsize_devconf(int type)
if (all || type == NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN)
size += nla_total_size(4);

+ if (all || type == NETCONFA_FORCE_FORWARDING)
+ size += nla_total_size(4);
+
return size;
}

@@ -578,6 +581,11 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
READ_ONCE(devconf->ignore_routes_with_linkdown)) < 0)
goto nla_put_failure;

+ if ((all || type == NETCONFA_FORCE_FORWARDING) &&
+ nla_put_s32(skb, NETCONFA_FORCE_FORWARDING,
+ READ_ONCE(devconf->force_forwarding)) < 0)
+ goto nla_put_failure;
+
out:
nlmsg_end(skb, nlh);
return 0;
@@ -863,8 +871,12 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
if (idev) {
int changed = (!idev->cnf.forwarding) ^ (!newf);
/* Disabling all.forwarding sets 0 to force_forwarding for all interfaces */
- if (newf == 0)
+ if (newf == 0 && idev->cnf.force_forwarding) {
WRITE_ONCE(idev->cnf.force_forwarding, 0);
+ inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
+ NETCONFA_FORCE_FORWARDING,
+ dev->ifindex, &idev->cnf);
+ }

WRITE_ONCE(idev->cnf.forwarding, newf);
if (changed)

---
base-commit: 7b6ab4dbc156e2f96419715130b3d5738a306c93
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261023-ipv6_add_netconfa-b87b66b35272

Best regards,
--
Gabriel Goller <g.goller@xxxxxxxxxxx>