]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ip6_vti: fix creating fallback tunnel device for vti6
authorHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Sun, 19 Aug 2018 07:05:05 +0000 (15:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Sep 2018 07:46:44 +0000 (09:46 +0200)
[ Upstream commit e2948e5af8eeb6c945000772b7613b0323a0a203 ]

When set fb_tunnels_only_for_init_net to 1, don't create fallback tunnel
device for vti6 when a new namespace is created.

Tested:
[root@builder2 ~]# modprobe ip6_tunnel
[root@builder2 ~]# modprobe ip6_vti
[root@builder2 ~]# echo 1 > /proc/sys/net/core/fb_tunnels_only_for_init_net
[root@builder2 ~]# unshare -n
[root@builder2 ~]# ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group
default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/ip6_vti.c

index fbd3752ea587f47048f71d0496b824e7f980e308..71b2fccd14844660255e130e9392922b898ddace 100644 (file)
@@ -1114,6 +1114,8 @@ static int __net_init vti6_init_net(struct net *net)
        ip6n->tnls[0] = ip6n->tnls_wc;
        ip6n->tnls[1] = ip6n->tnls_r_l;
 
+       if (!net_has_fallback_tunnels(net))
+               return 0;
        err = -ENOMEM;
        ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6_vti0",
                                        NET_NAME_UNKNOWN, vti6_dev_setup);