diff options
author | Christian Brauner <christian@brauner.io> | 2019-06-24 09:29:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-06-28 17:34:28 -0400 |
commit | 5cdda5f1d6adde02da591ca2196f20289977dc56 (patch) | |
tree | 4a26a3696905c50e800abcab1cb7d7e3dc14f4c5 /net/ipv4 | |
parent | 65dc5416d4e02d80ce140078c7c1f4e6c8400396 (diff) |
ipv4: enable route flushing in network namespaces
Tools such as vpnc try to flush routes when run inside network
namespaces by writing 1 into /proc/sys/net/ipv4/route/flush. This
currently does not work because flush is not enabled in non-initial
network namespaces.
Since routes are per network namespace it is safe to enable
/proc/sys/net/ipv4/route/flush in there.
Link: https://github.com/lxc/lxd/issues/4257
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/route.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a3e466b6a60c..bbd55c7f6b2e 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -3326,9 +3326,11 @@ static struct ctl_table ipv4_route_table[] = { | |||
3326 | { } | 3326 | { } |
3327 | }; | 3327 | }; |
3328 | 3328 | ||
3329 | static const char ipv4_route_flush_procname[] = "flush"; | ||
3330 | |||
3329 | static struct ctl_table ipv4_route_flush_table[] = { | 3331 | static struct ctl_table ipv4_route_flush_table[] = { |
3330 | { | 3332 | { |
3331 | .procname = "flush", | 3333 | .procname = ipv4_route_flush_procname, |
3332 | .maxlen = sizeof(int), | 3334 | .maxlen = sizeof(int), |
3333 | .mode = 0200, | 3335 | .mode = 0200, |
3334 | .proc_handler = ipv4_sysctl_rtcache_flush, | 3336 | .proc_handler = ipv4_sysctl_rtcache_flush, |
@@ -3346,9 +3348,11 @@ static __net_init int sysctl_route_net_init(struct net *net) | |||
3346 | if (!tbl) | 3348 | if (!tbl) |
3347 | goto err_dup; | 3349 | goto err_dup; |
3348 | 3350 | ||
3349 | /* Don't export sysctls to unprivileged users */ | 3351 | /* Don't export non-whitelisted sysctls to unprivileged users */ |
3350 | if (net->user_ns != &init_user_ns) | 3352 | if (net->user_ns != &init_user_ns) { |
3351 | tbl[0].procname = NULL; | 3353 | if (tbl[0].procname != ipv4_route_flush_procname) |
3354 | tbl[0].procname = NULL; | ||
3355 | } | ||
3352 | } | 3356 | } |
3353 | tbl[0].extra1 = net; | 3357 | tbl[0].extra1 = net; |
3354 | 3358 | ||