Message ID | 20240222105021.1943116-6-edumazet@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 6647b338fc5c6741736fe51a25fc2c0bec6398b8 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | rtnetlink: reduce RTNL pressure for dumps | expand |
Eric Dumazet <edumazet@google.com> writes: > __netlink_diag_dump() returns 1 if the dump is not complete, > zero if no error occurred. > > If err variable is zero, this means the dump is complete: > We should not return skb->len in this case, but 0. > > This allows NLMSG_DONE to be appended to the skb. > User space does not have to call us again only to get NLMSG_DONE. > > Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
diff --git a/net/netlink/diag.c b/net/netlink/diag.c index e12c90d5f6ad29446ea1990c88c19bcb0ee856c3..61981e01fd6ff189dcb46a06a4d265cf6029b840 100644 --- a/net/netlink/diag.c +++ b/net/netlink/diag.c @@ -207,7 +207,7 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) err = __netlink_diag_dump(skb, cb, req->sdiag_protocol, s_num); } - return err < 0 ? err : skb->len; + return err <= 0 ? err : skb->len; } static int netlink_diag_dump_done(struct netlink_callback *cb)
__netlink_diag_dump() returns 1 if the dump is not complete, zero if no error occurred. If err variable is zero, this means the dump is complete: We should not return skb->len in this case, but 0. This allows NLMSG_DONE to be appended to the skb. User space does not have to call us again only to get NLMSG_DONE. Signed-off-by: Eric Dumazet <edumazet@google.com> --- net/netlink/diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)