nl: Make nl_recvmsgs() return the number of netlink messages processed
This commit is contained in:
parent
adbc568735
commit
e0482794a8
1 changed files with 7 additions and 2 deletions
9
lib/nl.c
9
lib/nl.c
|
@ -559,7 +559,7 @@ do { \
|
|||
|
||||
static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
|
||||
{
|
||||
int n, err = 0, multipart = 0, interrupted = 0;
|
||||
int n, err = 0, multipart = 0, interrupted = 0, nrecv = 0;
|
||||
unsigned char *buf = NULL;
|
||||
struct nlmsghdr *hdr;
|
||||
struct sockaddr_nl nla = {0};
|
||||
|
@ -594,6 +594,8 @@ continue_reading:
|
|||
if (creds)
|
||||
nlmsg_set_creds(msg, creds);
|
||||
|
||||
nrecv++;
|
||||
|
||||
/* Raw callback is the first, it gives the most control
|
||||
* to the user and he can do his very own parsing. */
|
||||
if (cb->cb_set[NL_CB_MSG_IN])
|
||||
|
@ -754,6 +756,9 @@ out:
|
|||
if (interrupted)
|
||||
err = -NLE_DUMP_INTR;
|
||||
|
||||
if (!err)
|
||||
err = nrecv;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -770,7 +775,7 @@ out:
|
|||
* A non-blocking sockets causes the function to return immediately if
|
||||
* no data is available.
|
||||
*
|
||||
* @return 0 on success or a negative error code from nl_recv().
|
||||
* @return Number of received messages or a negative error code from nl_recv().
|
||||
*/
|
||||
int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue