Re: [PATCHv5 net-next 3/4] rtnetlink: Honour NLM_F_ECHO flag in rtnl_newlink_create

Guillaume Nault
2022-09-30T16:43:06Z

On Fri, Sep 30, 2022 at 05:45:05PM +0800, Hangbin Liu wrote:
> This patch use the new helper rtnl_configure_link_notify() for
> rtnl_newlink_create(), so that the kernel could reply unicast
> when userspace set NLM_F_ECHO flag to request the new created
> interface info.
>
> Suggested-by: Guillaume Nault <gnault@redhat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> net/core/rtnetlink.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 1558921bd4da..da9a6fd156d8 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3318,10 +3318,12 @@ static int rtnl_group_changelink(const struct sk_buff *skb,
> static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
> const struct rtnl_link_ops *ops,
> struct nlattr **tb, struct nlattr **data,
> - struct netlink_ext_ack *extack)
> + struct netlink_ext_ack *extack,
> + struct nlmsghdr *nlh)

'nlh' could be const here too. Also, since we've started being picky
about the order of parameters, let's put 'nlh' right before 'tb' to
follow what other functions generally do.

> {
> unsigned char name_assign_type = NET_NAME_USER;
> struct net *net = sock_net(skb->sk);
> + u32 pid = NETLINK_CB(skb).portid;

s/pid/portid/