Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tun: Consistently configure generic netdev params via rtnetlink

Configuring generic network device parameters on tun will fail in
presence of IFLA_INFO_KIND attribute in IFLA_LINKINFO nested attribute
since tun_validate() always return failure.

This can be visualized with following ip-link(8) command sequences:

# ip link set dev tun0 group 100
# ip link set dev tun0 group 100 type tun
RTNETLINK answers: Invalid argument

with contrast to dummy and veth drivers:

# ip link set dev dummy0 group 100
# ip link set dev dummy0 type dummy

# ip link set dev veth0 group 100
# ip link set dev veth0 group 100 type veth

Fix by returning zero in tun_validate() when @data is NULL that is
always in case since rtnl_link_ops->maxtype is zero in tun driver.

Fixes: f019a7a594d9 ("tun: Implement ip link del tunXXX")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Serhey Popovych and committed by
David S. Miller
df52eab2 921060cc

+2
+2
drivers/net/tun.c
··· 2289 2289 static int tun_validate(struct nlattr *tb[], struct nlattr *data[], 2290 2290 struct netlink_ext_ack *extack) 2291 2291 { 2292 + if (!data) 2293 + return 0; 2292 2294 return -EINVAL; 2293 2295 } 2294 2296