[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YzFuPRceyLwXLUyo@Laptop-X1>
Date: Mon, 26 Sep 2022 17:17:49 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Ido Schimmel <idosch@...dia.com>,
Petr Machata <petrm@...dia.com>,
Florent Fourcot <florent.fourcot@...irst.fr>,
Nikolay Aleksandrov <razor@...ckwall.org>,
Nicolas Dichtel <nicolas.dichtel@...nd.com>,
Guillaume Nault <gnault@...hat.com>
Subject: Re: [PATCHv2 net-next] rtnetlink: Honour NLM_F_ECHO flag in
rtnl_{new, set, del}link
On Mon, Sep 26, 2022 at 03:12:46PM +0800, Hangbin Liu wrote:
> +static void rtnl_link_notify(struct net_device *dev, u32 pid,
> + struct nlmsghdr *nlh)
> +{
> + struct sk_buff *skb;
> + int err = -ENOBUFS;
> +
> + skb = nlmsg_new(if_nlmsg_size(dev, 0), GFP_KERNEL);
> + if (!skb)
> + goto errout;
> +
> + err = rtnl_fill_ifinfo(skb, dev, dev_net(dev), RTM_NEWLINK, pid,
> + nlh->nlmsg_seq, 0, 0, 0, 0, NULL, 0, 0,
> + GFP_KERNEL);
> + if (err < 0) {
> + /* -EMSGSIZE implies BUG in if_nlmsg_size */
> + WARN_ON(err == -EMSGSIZE);
> + kfree_skb(skb);
> + goto errout;
> + }
> +
> + rtnl_notify(skb, dev_net(dev), pid, RTM_NEWLINK, nlh, GFP_KERNEL);
> +
> +errout:
> + if (err < 0)
> + rtnl_set_sk_err(dev_net(dev), RTM_NEWLINK, err);
> +}
> +
Oh, I just find there is a similar helper function rtmsg_ifinfo_build_skb().
I will check if I can just update and re-use this helper.
Thanks
Hangbin
Powered by blists - more mailing lists