rtnetlink: use nlmsg_notify() in rtnetlink_send()
authorYajun Deng <yajun.deng@linux.dev>
Thu, 15 Jul 2021 12:12:57 +0000 (20:12 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Jul 2021 17:46:35 +0000 (10:46 -0700)
The netlink_{broadcast, unicast} don't deal with 'if (err > 0' statement
but nlmsg_{multicast, unicast} do. The nlmsg_notify() contains them.
so use nlmsg_notify() instead. so that the caller wouldn't deal with
'if (err > 0' statement.

v2: use nlmsg_notify() will do well.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index f6af3e7..670d74a 100644 (file)
@@ -710,15 +710,8 @@ out:
 int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo)
 {
        struct sock *rtnl = net->rtnl;
-       int err = 0;
 
-       NETLINK_CB(skb).dst_group = group;
-       if (echo)
-               refcount_inc(&skb->users);
-       netlink_broadcast(rtnl, skb, pid, group, GFP_KERNEL);
-       if (echo)
-               err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
-       return err;
+       return nlmsg_notify(rtnl, skb, pid, group, echo, GFP_KERNEL);
 }
 
 int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)