Skip to contentSkip to conversation

net: Deal with if statement in rtnetlink_send()

PATCH Applied Yajun Deng 2 participants 3 messages Jul 15, 2021 – Jul 16, 2021

Subsystems (2)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

v2 cover net: Deal with if statement in rtnetlink_send()

Patch1: use nlmsg_notify() in rtnetlink_send(), so that the caller wouldn't deal with if statement.
Patch2: Remove unnecessary if statement.

Yajun Deng (2):
rtnetlink: use nlmsg_notify() in rtnetlink_send() net/sched: Remove unnecessary if statement

 net/core/rtnetlink.c |  9 +--------
 net/sched/act_api.c  | 12 ++----------
 net/sched/cls_api.c  | 15 ++++-----------
 net/sched/sch_api.c  | 10 ++--------
 4 files changed, 9 insertions(+), 37 deletions(-)
Signature · 1 line
2.32.0
author
#1 lore raw

PATCH v2 1/2 rtnetlink: use nlmsg_notify() in rtnetlink_send()

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.

---
 net/core/rtnetlink.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
net/core/rtnetlink.c +1 -8
index f6af3e74fc44..670d74ab91ae 100644
@@ -710,15 +710,8 @@ static int rtnl_link_fill(struct sk_buff *skb, const struct net_device *dev)
 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)
Signature · 1 line
2.32.0
#2 lore raw
In reply to Yajun Deng
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 10 lines · On Thu, 15 Jul 2021 20:12:56 +0800 you wrote:

Patch1: use nlmsg_notify() in rtnetlink_send(), so that the caller wouldn't deal with if statement.
Patch2: Remove unnecessary if statement.

Yajun Deng (2):
rtnetlink: use nlmsg_notify() in rtnetlink_send() net/sched: Remove unnecessary if statement

[...]

Here is the summary with links:
- [v2,1/2] rtnetlink: use nlmsg_notify() in rtnetlink_send()

    https://git.kernel.org/netdev/net-next/c/cfdf0d9ae75b
  - [v2,2/2] net/sched: Remove unnecessary if statement
    https://git.kernel.org/netdev/net-next/c/f79a3bcb1a50

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html