Commit 7a4fcfb7 authored by Petr Pavlu's avatar Petr Pavlu Committed by Liu Jian
Browse files

net/ipv6: Fix the RT cache flush via sysctl using a previous delay

stable inclusion
from stable-v4.19.317
commit ebde6e8a52c68dc45b4ae354e279ba74788579e7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAMPH5

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ebde6e8a52c68dc45b4ae354e279ba74788579e7



-------------------------------------------------

[ Upstream commit 14a20e5b4ad998793c5f43b0330d9e1388446cf3 ]

The net.ipv6.route.flush system parameter takes a value which specifies
a delay used during the flush operation for aging exception routes. The
written value is however not used in the currently requested flush and
instead utilized only in the next one.

A problem is that ipv6_sysctl_rtcache_flush() first reads the old value
of net->ipv6.sysctl.flush_delay into a local delay variable and then
calls proc_dointvec() which actually updates the sysctl based on the
provided input.

Fix the problem by switching the order of the two operations.

Fixes: 4990509f ("[NETNS][IPV6]: Make sysctls route per namespace.")
Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240607112828.30285-1-petr.pavlu@suse.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>
parent 73a86ad6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5186,12 +5186,12 @@ int ipv6_sysctl_rtcache_flush(struct ctl_table *ctl, int write,
	if (!write)
		return -EINVAL;

	net = (struct net *)ctl->extra1;
	delay = net->ipv6.sysctl.flush_delay;
	ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
	if (ret)
		return ret;

	net = (struct net *)ctl->extra1;
	delay = net->ipv6.sysctl.flush_delay;
	fib6_run_gc(delay <= 0 ? 0 : (unsigned long)delay, net, delay > 0);
	return 0;
}