Skip to content

Commit fefd5d0

Browse files
q2venkuba-moo
authored andcommitted
netkit: Set IFLA_NETKIT_PEER_INFO to netkit_link_ops.peer_type.
For per-netns RTNL, we need to prefetch the peer device's netns. Let's set rtnl_link_ops.peer_type and accordingly remove duplicated validation in ->newlink(). Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6b84e55 commit fefd5d0

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/net/netkit.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,7 @@ static int netkit_new_link(struct net *src_net, struct net_device *dev,
351351
if (data[IFLA_NETKIT_PEER_INFO]) {
352352
attr = data[IFLA_NETKIT_PEER_INFO];
353353
ifmp = nla_data(attr);
354-
err = rtnl_nla_parse_ifinfomsg(peer_tb, attr, extack);
355-
if (err < 0)
356-
return err;
357-
err = netkit_validate(peer_tb, NULL, extack);
358-
if (err < 0)
359-
return err;
354+
rtnl_nla_parse_ifinfomsg(peer_tb, attr, extack);
360355
tbp = peer_tb;
361356
}
362357
if (data[IFLA_NETKIT_SCRUB])
@@ -391,9 +386,6 @@ static int netkit_new_link(struct net *src_net, struct net_device *dev,
391386
return -EOPNOTSUPP;
392387

393388
net = rtnl_link_get_net(src_net, tbp);
394-
if (IS_ERR(net))
395-
return PTR_ERR(net);
396-
397389
peer = rtnl_create_link(net, ifname, ifname_assign_type,
398390
&netkit_link_ops, tbp, extack);
399391
if (IS_ERR(peer)) {
@@ -978,6 +970,7 @@ static struct rtnl_link_ops netkit_link_ops = {
978970
.fill_info = netkit_fill_info,
979971
.policy = netkit_policy,
980972
.validate = netkit_validate,
973+
.peer_type = IFLA_NETKIT_PEER_INFO,
981974
.maxtype = IFLA_NETKIT_MAX,
982975
};
983976

0 commit comments

Comments
 (0)