Skip to content

Commit

Permalink
net: Use nlmsg_unicast() instead of netlink_unicast()
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Yajun Deng <[email protected]>
Reviewed-by: David Ahern <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Yajun Deng authored and davem330 committed Jul 13, 2021
1 parent 71ce9d9 commit 01757f5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 27 deletions.
2 changes: 1 addition & 1 deletion net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions net/ipv4/raw_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 2 additions & 4 deletions net/ipv4/udp_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions net/mptcp/mptcp_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions net/sctp/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions net/unix/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 01757f5

Please sign in to comment.