tun: Consistently configure generic netdev params via rtnetlink
Subsystems (3)
PATCH 1/1 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.
--- drivers/net/tun.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/tun.c +2 -0
@@ -2298,6 +2298,8 @@ static void tun_setup(struct net_device *dev)static int tun_validate (struct nlattr *tb[],struct nlattr *data[],struct netlink_ext_ack *extack) { +if (!data) +return 0 ;return -EINVAL ; }
Signature · 1 line
1.8.3.1
From: Serhey Popovych <[email protected]>
Date: Tue, 9 Oct 2018 21:21:01 +0300
Quoted 15 lines
Configuring generic network device parameters on tun will fail in presence of
IFLA_INFO_KINDattribute inIFLA_LINKINFOnested attribute sincetun_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 argumentwith contrast to dummy and veth drivers:
# ip link set dev dummy0 group 100 # ip link set dev dummy0 type dummy
Quoted 8 lines
# ip link set dev veth0 group 100 # ip link set dev veth0 group 100 type vethFix by returning zero in
tun_validate()when @data is NULL that is always in case sincertnl_link_ops->maxtypeis zero in tun driver.Fixes f019a7a594d9 ("tun: Implement ip link del tunXXX")Signed-off-by Serhey Popovych <[email protected]>
Applied, thank you.