Skip to content

Commit 9fffc5c

Browse files
qsndavem330
authored andcommitted
tun: set the flags before registering the netdevice
Otherwise, register_netdevice advertises the creation of the device with the default flags, instead of what the user requested. Reported-by: Thomas Haller <[email protected]> Fixes: 1ec010e ("tun: export flags, uid, gid, queue information over netlink") Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 47b9986 commit 9fffc5c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/tun.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
25642564
*/
25652565
return 0;
25662566
}
2567+
2568+
tun->flags = (tun->flags & ~TUN_FEATURES) |
2569+
(ifr->ifr_flags & TUN_FEATURES);
25672570
}
25682571
else {
25692572
char *name;
@@ -2642,6 +2645,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
26422645
~(NETIF_F_HW_VLAN_CTAG_TX |
26432646
NETIF_F_HW_VLAN_STAG_TX);
26442647

2648+
tun->flags = (tun->flags & ~TUN_FEATURES) |
2649+
(ifr->ifr_flags & TUN_FEATURES);
2650+
26452651
INIT_LIST_HEAD(&tun->disabled);
26462652
err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI);
26472653
if (err < 0)
@@ -2656,9 +2662,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
26562662

26572663
tun_debug(KERN_INFO, tun, "tun_set_iff\n");
26582664

2659-
tun->flags = (tun->flags & ~TUN_FEATURES) |
2660-
(ifr->ifr_flags & TUN_FEATURES);
2661-
26622665
/* Make sure persistent devices do not get stuck in
26632666
* xoff state.
26642667
*/

0 commit comments

Comments
 (0)