Skip to contentSkip to conversation

rtnetlink: Try the outer netns attribute in rtnl_get_peer_net().

PATCH Applied Kuniyuki Iwashima 3 participants 3 messages Dec 16, 2024 – Dec 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 net/core/rtnetlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +3 -2
index ebcfc2debf1a..d9f959c619d9 100644
@@ -3819,6 +3819,7 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
 }
 
 static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
+				     struct nlattr *tbp[],
 				     struct nlattr *data[],
 				     struct netlink_ext_ack *extack)
 {
@@ -3826,7 +3827,7 @@ static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
 	int err;
 
 	if (!data || !data[ops->peer_type])
-		return NULL;
+		return rtnl_link_get_net_ifla(tbp);
 
 	err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
 	if (err < 0)
@@ -3971,7 +3972,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 		}
 
 		if (ops->peer_type) {
-			peer_net = rtnl_get_peer_net(ops, data, extack);
+			peer_net = rtnl_get_peer_net(ops, tb, data, extack);
 			if (IS_ERR(peer_net)) {
 				ret = PTR_ERR(peer_net);
 				goto put_ops;
Signature · 1 line
2.39.5 (Apple Git-154)
Tested-by on v1 1/1
#1 lore raw
Quoted 49 lines · Kuniyuki Iwashima

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.

---
 net/core/rtnetlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +3 -3
index ebcfc2debf1a..d9f959c619d9 100644
@@ -3819,6 +3819,7 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
 }
 
 static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
+                                    struct nlattr *tbp[],
                                     struct nlattr *data[],
                                     struct netlink_ext_ack *extack)
 {
@@ -3826,7 +3827,7 @@ static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
        int err;
 
        if (!data || !data[ops->peer_type])
-               return NULL;
+               return rtnl_link_get_net_ifla(tbp);
 
        err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
        if (err < 0)
@@ -3971,7 +3972,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
                }
 
                if (ops->peer_type) {
-                       peer_net = rtnl_get_peer_net(ops, data, extack);
+                       peer_net = rtnl_get_peer_net(ops, tb, data, extack);
                        if (IS_ERR(peer_net)) {
                                ret = PTR_ERR(peer_net);
                                goto put_ops;
--
Quoted 2 lines

2.39.5 (Apple Git-154)

Thanks. Tested on my environment, and it's back to the original behavior now.

#2 lore raw
In reply to Kuniyuki Iwashima
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 16 Dec 2024 20:04:32 +0900 you wrote:

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().

[...]

Here is the summary with links:
- [v1,net] rtnetlink: Try the outer netns attribute in rtnl_get_peer_net().

    https://git.kernel.org/netdev/net/c/954a2b40719a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html