From e0482794a8b70ae23361bfbe3701d4c2c96c66a6 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Sat, 21 Apr 2012 12:46:01 +0200 Subject: [PATCH] nl: Make nl_recvmsgs() return the number of netlink messages processed --- lib/nl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/nl.c b/lib/nl.c index bcf89da..c41a3b9 100644 --- a/lib/nl.c +++ b/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) {