Skip to content

Commit 954a2b4

Browse files
q2venkuba-moo
authored andcommitted
rtnetlink: Try the outer netns attribute in rtnl_get_peer_net().
Xiao Liang reported that the cited commit changed netns handling in newlink() of netkit, veth, and vxcan. Before the patch, if we don't find a netns attribute in the peer device attributes, we tried to find another netns attribute in the outer netlink attributes by passing it to rtnl_link_get_net(). Let's restore the original behaviour. Fixes: 4832756 ("rtnetlink: fix double call of rtnl_link_get_net_ifla()") Reported-by: Xiao Liang <[email protected]> Closes: https://lore.kernel.org/netdev/CABAhCORBVVU8P6AHcEkENMj+gD2d3ce9t=A_o48E0yOQp8_wUQ@mail.gmail.com/#t Signed-off-by: Kuniyuki Iwashima <[email protected]> Tested-by: Xiao Liang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b9b8301 commit 954a2b4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/core/rtnetlink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3819,14 +3819,15 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
38193819
}
38203820

38213821
static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
3822+
struct nlattr *tbp[],
38223823
struct nlattr *data[],
38233824
struct netlink_ext_ack *extack)
38243825
{
38253826
struct nlattr *tb[IFLA_MAX + 1];
38263827
int err;
38273828

38283829
if (!data || !data[ops->peer_type])
3829-
return NULL;
3830+
return rtnl_link_get_net_ifla(tbp);
38303831

38313832
err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
38323833
if (err < 0)
@@ -3971,7 +3972,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
39713972
}
39723973

39733974
if (ops->peer_type) {
3974-
peer_net = rtnl_get_peer_net(ops, data, extack);
3975+
peer_net = rtnl_get_peer_net(ops, tb, data, extack);
39753976
if (IS_ERR(peer_net)) {
39763977
ret = PTR_ERR(peer_net);
39773978
goto put_ops;

0 commit comments

Comments
 (0)