netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Hangbin Liu <liuhangbin@gmail.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
	Florent Fourcot <florent.fourcot@wifirst.fr>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Guillaume Nault <gnault@redhat.com>
Subject: Re: [PATCH net-next] rtnetlink: Honour NLM_F_ECHO flag in rtnl_{new, set}link
Date: Wed, 21 Sep 2022 11:11:19 +0200	[thread overview]
Message-ID: <1ff2e97e-003f-e6b4-d724-c42449fde221@6wind.com> (raw)
In-Reply-To: <20220921030721.280528-1-liuhangbin@gmail.com>


Le 21/09/2022 à 05:07, Hangbin Liu a écrit :
> Netlink messages are used for communicating between user and kernel space.
> When user space configures the kernel with netlink messages, it can set the
> NLM_F_ECHO flag to request the kernel to send the applied configuration back
> to the caller. This allows user space to retrieve configuration information
> that are filled by the kernel (either because these parameters can only be
> set by the kernel or because user space let the kernel choose a default
> value).
> 
> This patch handles NLM_F_ECHO flag and send link info back after
> rtnl_{new, set}link.
> 
> Suggested-by: Guillaume Nault <gnault@redhat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---

[snip]

> @@ -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.

Regards,
Nicolas

  reply	other threads:[~2022-09-21  9:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21  3:07 [PATCH net-next] rtnetlink: Honour NLM_F_ECHO flag in rtnl_{new, set}link Hangbin Liu
2022-09-21  9:11 ` Nicolas Dichtel [this message]
2022-09-21 10:31   ` Hangbin Liu
2022-09-21 13:01 ` Jakub Kicinski
2022-09-21 13:13   ` Nikolay Aleksandrov
2022-09-21 16:14   ` Guillaume Nault
2022-09-21 22:56     ` Jakub Kicinski
2022-09-22 10:13       ` Hangbin Liu
2022-09-22 12:58         ` Jakub Kicinski
2022-09-22 10:52       ` Florent Fourcot
2022-09-22 11:09       ` Guillaume Nault
2022-09-22 13:03         ` Jakub Kicinski
2022-09-22 14:51           ` Guillaume Nault
2022-09-23  8:43             ` Nicolas Dichtel
2022-09-23 13:48               ` Jakub Kicinski
2022-09-23 15:42                 ` Nicolas Dichtel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ff2e97e-003f-e6b4-d724-c42449fde221@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florent.fourcot@wifirst.fr \
    --cc=gnault@redhat.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).