]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tun: set the flags before registering the netdevice
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 10 Apr 2018 14:28:55 +0000 (16:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Apr 2018 18:48:05 +0000 (14:48 -0400)
Otherwise, register_netdevice advertises the creation of the device with
the default flags, instead of what the user requested.

Reported-by: Thomas Haller <thaller@redhat.com>
Fixes: 631b92c16587 ("tun: export flags, uid, gid, queue information over netlink")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c

index a1ba262f40ad0755d2cea34867851bb7acd8e2de..c9e68fd76a372515ac02ed0c2816bdbeeaaaa4b0 100644 (file)
@@ -2564,6 +2564,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
                         */
                        return 0;
                }
+
+               tun->flags = (tun->flags & ~TUN_FEATURES) |
+                             (ifr->ifr_flags & TUN_FEATURES);
        }
        else {
                char *name;
@@ -2642,6 +2645,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
                                     ~(NETIF_F_HW_VLAN_CTAG_TX |
                                       NETIF_F_HW_VLAN_STAG_TX);
 
+               tun->flags = (tun->flags & ~TUN_FEATURES) |
+                             (ifr->ifr_flags & TUN_FEATURES);
+
                INIT_LIST_HEAD(&tun->disabled);
                err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI);
                if (err < 0)
@@ -2656,9 +2662,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 
        tun_debug(KERN_INFO, tun, "tun_set_iff\n");
 
-       tun->flags = (tun->flags & ~TUN_FEATURES) |
-               (ifr->ifr_flags & TUN_FEATURES);
-
        /* Make sure persistent devices do not get stuck in
         * xoff state.
         */