net: Use nlmsg_unicast() instead of netlink_unicast()
Subsystems (7)
PATCH v2 1/1 net: Use nlmsg_unicast() instead of netlink_unicast()
It has 'if (err >0 )' statement in nlmsg_unicast(), so use nlmsg_unicast() instead of netlink_unicast(), this looks more concise.
v2: remove the change in netfilter.
--- net/ipv4/fib_frontend.c | 2 +- net/ipv4/inet_diag.c | 5 +---- net/ipv4/raw_diag.c | 7 ++----- net/ipv4/udp_diag.c | 6 ++---- net/mptcp/mptcp_diag.c | 6 ++---- net/netlink/af_netlink.c | 2 +- net/sctp/diag.c | 6 ++---- net/unix/diag.c | 6 ++---- 8 files changed, 13 insertions(+), 27 deletions(-)
net/ipv4/fib_frontend.c +1 -1
@@ -1376,7 +1376,7 @@ static void nl_fib_input(struct sk_buff *skb) portid =NETLINK_CB (skb).portid;/* netlink portid */ NETLINK_CB (skb).portid =0 ;/* from kernel */ NETLINK_CB (skb).dst_group =0 ;/* unicast */ -netlink_unicast (net->ipv4.fibnl, skb, portid,MSG_DONTWAIT ); +nlmsg_unicast (net->ipv4.fibnl, skb, portid); }static int __net_init nl_fib_lookup_init (struct net *net)
net/ipv4/inet_diag.c +1 -4
@@ -580,10 +580,7 @@ int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,nlmsg_free (rep); goto out; } - err =netlink_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); out:if (sk)
net/ipv4/raw_diag.c +2 -5
@@ -119,11 +119,8 @@ static int raw_diag_dump_one(struct netlink_callback *cb,return err; } - err =netlink_unicast (net->diag_nlsk, rep, -NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); +return err; }
net/ipv4/udp_diag.c +2 -4
@@ -77,10 +77,8 @@ static int udp_dump_one(struct udp_table *tbl,kfree_skb (rep); goto out; } - err =netlink_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); + out:if (sk)sock_put (sk);
net/mptcp/mptcp_diag.c +2 -4
@@ -57,10 +57,8 @@ static int mptcp_diag_dump_one(struct netlink_callback *cb,kfree_skb (rep); goto out; } - err =netlink_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); + out:sock_put (sk);
net/netlink/af_netlink.c +1 -1
@@ -2471,7 +2471,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,nlmsg_end (skb, rep); -netlink_unicast (in_skb->sk, skb,NETLINK_CB (in_skb).portid,MSG_DONTWAIT ); +nlmsg_unicast (in_skb->sk, skb,NETLINK_CB (in_skb).portid); }EXPORT_SYMBOL (netlink_ack);
net/sctp/diag.c +2 -4
@@ -284,10 +284,8 @@ static int sctp_tsp_dump_one(struct sctp_transport *tsp, void *p) goto out; } - err =netlink_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); + out:return err; }
net/unix/diag.c +2 -4
@@ -295,10 +295,8 @@ static int unix_diag_get_exact(struct sk_buff *in_skb, goto again; } - err =netlink_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); + out:if (sk)sock_put (sk);
Signature · 1 line
2.32.0
Quoted 6 lines · Yajun Deng
net/ipv4/raw_diag.c +0
-0@@ -119,11 +119,8 @@ static int raw_diag_dump_one(struct netlink_callback *cb,return err;
net/ipv4/raw_diag.c static int raw_diag_dump_one(struct netlink_callback *cb, · line 124
Quoted 10 lines
net/ipv4/raw_diag.c +2
-5} - err =netlink_unicast (net->diag_nlsk, rep, -NETLINK_CB (in_skb).portid, -MSG_DONTWAIT ); -if (err >0 ) - err =0 ; + err =nlmsg_unicast (net->diag_nlsk, rep,NETLINK_CB (in_skb).portid); +return err;
can be shortened to:
return nlmsg_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid);
other than that it's a good cleanup:
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Tue, 13 Jul 2021 10:48:24 +0800 you wrote:
It has 'if (err >0 )' statement in
nlmsg_unicast(), so usenlmsg_unicast()instead ofnetlink_unicast(), this looks more concise.v2: remove the change in netfilter.
Signed-off-by Yajun Deng <[email protected]>[...]
Here is the summary with links:
- [v2] net: Use nlmsg_unicast() instead of netlink_unicast()
https://git.kernel.org/netdev/net/c/01757f536ac8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html