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 <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Nikolay Aleksandrov <razor@blackwall.org> Link: https://patch.msgid.link/20241108004823.29419-9-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
6b84e558e9
commit
fefd5d0821
1 changed files with 2 additions and 9 deletions
|
@ -351,12 +351,7 @@ static int netkit_new_link(struct net *src_net, struct net_device *dev,
|
||||||
if (data[IFLA_NETKIT_PEER_INFO]) {
|
if (data[IFLA_NETKIT_PEER_INFO]) {
|
||||||
attr = data[IFLA_NETKIT_PEER_INFO];
|
attr = data[IFLA_NETKIT_PEER_INFO];
|
||||||
ifmp = nla_data(attr);
|
ifmp = nla_data(attr);
|
||||||
err = rtnl_nla_parse_ifinfomsg(peer_tb, attr, extack);
|
rtnl_nla_parse_ifinfomsg(peer_tb, attr, extack);
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
err = netkit_validate(peer_tb, NULL, extack);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
tbp = peer_tb;
|
tbp = peer_tb;
|
||||||
}
|
}
|
||||||
if (data[IFLA_NETKIT_SCRUB])
|
if (data[IFLA_NETKIT_SCRUB])
|
||||||
|
@ -391,9 +386,6 @@ static int netkit_new_link(struct net *src_net, struct net_device *dev,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
net = rtnl_link_get_net(src_net, tbp);
|
net = rtnl_link_get_net(src_net, tbp);
|
||||||
if (IS_ERR(net))
|
|
||||||
return PTR_ERR(net);
|
|
||||||
|
|
||||||
peer = rtnl_create_link(net, ifname, ifname_assign_type,
|
peer = rtnl_create_link(net, ifname, ifname_assign_type,
|
||||||
&netkit_link_ops, tbp, extack);
|
&netkit_link_ops, tbp, extack);
|
||||||
if (IS_ERR(peer)) {
|
if (IS_ERR(peer)) {
|
||||||
|
@ -978,6 +970,7 @@ static struct rtnl_link_ops netkit_link_ops = {
|
||||||
.fill_info = netkit_fill_info,
|
.fill_info = netkit_fill_info,
|
||||||
.policy = netkit_policy,
|
.policy = netkit_policy,
|
||||||
.validate = netkit_validate,
|
.validate = netkit_validate,
|
||||||
|
.peer_type = IFLA_NETKIT_PEER_INFO,
|
||||||
.maxtype = IFLA_NETKIT_MAX,
|
.maxtype = IFLA_NETKIT_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue