[PATCH v2 0/2] net: Deal with if statement in rtnetlink_send()

STALE1877d

3 messages, 2 authors, 2021-07-16 · open the first message on its own page

[PATCH v2 0/2] net: Deal with if statement in rtnetlink_send()

From: Yajun Deng <hidden>
Date: 2021-07-15 12:13:26

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(-)

-- 
2.32.0

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

From: Yajun Deng <hidden>
Date: 2021-07-15 12:13:41

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 <redacted>
---
 net/core/rtnetlink.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f6af3e74fc44..670d74ab91ae 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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)
-- 
2.32.0

Re: [PATCH v2 0/2] net: Deal with if statement in rtnetlink_send()

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-07-16 17:50:15

Hello:

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

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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help