Re: [PATCH net-next] ipv6: reset all.force_forwarding when disabling all.forwarding

From: Nicolas Dichtel

Date: Thu Nov 12 2026 - 11:34:48 EST


Le 09/11/2026 à 16:53, Gabriel Goller a écrit :
> 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,

Reviewed-by: Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx>