Thread (16 messages) 16 messages, 6 authors, 2022-09-23

Re: [PATCH net-next] rtnetlink: Honour NLM_F_ECHO flag in rtnl_{new, set}link

From: Hangbin Liu <hidden>
Date: 2022-09-21 10:31:30

On Wed, Sep 21, 2022 at 11:11:19AM +0200, Nicolas Dichtel wrote:
quoted
@@ -3336,9 +3381,9 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
 		return PTR_ERR(dest_net);
 
 	if (tb[IFLA_LINK_NETNSID]) {
-		int id = nla_get_s32(tb[IFLA_LINK_NETNSID]);
+		netnsid = nla_get_s32(tb[IFLA_LINK_NETNSID]);
 
-		link_net = get_net_ns_by_id(dest_net, id);
+		link_net = get_net_ns_by_id(dest_net, netnsid);
 		if (!link_net) {
 			NL_SET_ERR_MSG(extack, "Unknown network namespace id");
 			err =  -EINVAL;
@@ -3382,6 +3427,17 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
 		if (err)
 			goto out_unregister;
 	}
+
+	if (nlmsg_flags & NLM_F_ECHO) {
+		u32 ext_filter_mask = 0;
+
+		if (tb[IFLA_EXT_MASK])
+			ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
+
+		rtnl_echo_link_info(dev, NETLINK_CB(skb).portid, nlmsg_seq,
+				    ext_filter_mask, netnsid);
=> netnsid, ie IFLA_LINK_NETNSID has nothing to do with IFLA_TARGET_NETNSID.
Link netns is used for x-netns interface like vlan for example. The vlan iface
could be in a netns while its lower iface could be in another netns.

The target netns is used when a netlink message is sent in a netns but should
act in another netns.
Oh, thanks for the explanation. Then we can remove the netnsid parameter
from rtnl_echo_link_info().

Thanks
Hangbin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help