[PATCH net-next] ipv6: reset all.force_forwarding when disabling all.forwarding
From: Gabriel Goller
Date: Mon Nov 09 2026 - 11:00:36 EST
Disabling all.forwarding resets force_forwarding on every interface, but
leaves all.force_forwarding set:
# sysctl -wq net.ipv6.conf.all.forwarding=1
# sysctl -wq net.ipv6.conf.all.force_forwarding=1
# sysctl -wq net.ipv6.conf.all.forwarding=0
# sysctl net.ipv6.conf.dummy1.force_forwarding
net.ipv6.conf.dummy1.force_forwarding = 0
# sysctl net.ipv6.conf.all.force_forwarding
net.ipv6.conf.all.force_forwarding = 1
Writing 1 to all.force_forwarding afterwards is ignored because the
value did not change, so the interfaces are not re-enabled.
Reset all.force_forwarding too and notify netconf listeners.
Suggested-by: Ido Schimmel <idosch@xxxxxxxxxx>
Signed-off-by: Gabriel Goller <g.goller@xxxxxxxxxxx>
---
net/ipv6/addrconf.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d9d13e78bf13..9007a58039e6 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -905,6 +905,14 @@ static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int
net->ipv6.devconf_dflt);
addrconf_forward_change(net, newf);
+ /* Disabling all.forwarding also resets all.force_forwarding */
+ if (newf == 0 && net->ipv6.devconf_all->force_forwarding) {
+ WRITE_ONCE(net->ipv6.devconf_all->force_forwarding, 0);
+ inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
+ NETCONFA_FORCE_FORWARDING,
+ NETCONFA_IFINDEX_ALL,
+ net->ipv6.devconf_all);
+ }
if ((!newf) ^ (!old))
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
NETCONFA_FORWARDING,
---
base-commit: fa5196392691051963726787944db872420dfa75
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261109-ipv6_reset_all-1452fdf29254
Best regards,
--
Gabriel Goller <g.goller@xxxxxxxxxxx>