nl: Fix return value of nl_recvmsgs()
Apparently the change to have nl_recvmsgs() return the number of parsed messages broke nl_wait_for_ack() among other applications. This patch reverts to the old behaviour and provides a new function nl_recvmsgs_report() which provides the additional information for use by the cache manager and possibly other applications. Reported-by: Scott Bonar <sbonar@cradlepoint.com> Signed-off-by: Thomas Graf <tgraf@redhat.com>
This commit is contained in:
parent
d726ecd2d7
commit
6f156a7b58
|
@ -71,6 +71,7 @@ extern int nl_recv(struct nl_sock *,
|
||||||
struct ucred **);
|
struct ucred **);
|
||||||
|
|
||||||
extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
|
extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
|
||||||
|
extern int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *);
|
||||||
|
|
||||||
extern int nl_recvmsgs_default(struct nl_sock *);
|
extern int nl_recvmsgs_default(struct nl_sock *);
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ int nl_cache_mngr_data_ready(struct nl_cache_mngr *mngr)
|
||||||
|
|
||||||
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_input, mngr);
|
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_input, mngr);
|
||||||
|
|
||||||
while ((err = nl_recvmsgs(mngr->cm_sock, cb)) > 0) {
|
while ((err = nl_recvmsgs_report(mngr->cm_sock, cb)) > 0) {
|
||||||
NL_DBG(2, "Cache manager %p, recvmsgs read %d messages\n",
|
NL_DBG(2, "Cache manager %p, recvmsgs read %d messages\n",
|
||||||
mngr, err);
|
mngr, err);
|
||||||
nread += err;
|
nread += err;
|
||||||
|
|
34
lib/nl.c
34
lib/nl.c
|
@ -762,6 +762,26 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive a set of messages from a netlink socket and report parsed messages
|
||||||
|
* @arg sk Netlink socket.
|
||||||
|
* @arg cb set of callbacks to control behaviour.
|
||||||
|
*
|
||||||
|
* This function is identical to nl_recvmsgs() to the point that it will
|
||||||
|
* return the number of parsed messages instead of 0 on success.
|
||||||
|
*
|
||||||
|
* @see nl_recvmsgs()
|
||||||
|
*
|
||||||
|
* @return Number of received messages or a negative error code from nl_recv().
|
||||||
|
*/
|
||||||
|
int nl_recvmsgs_report(struct nl_sock *sk, struct nl_cb *cb)
|
||||||
|
{
|
||||||
|
if (cb->cb_recvmsgs_ow)
|
||||||
|
return cb->cb_recvmsgs_ow(sk, cb);
|
||||||
|
else
|
||||||
|
return recvmsgs(sk, cb);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive a set of messages from a netlink socket.
|
* Receive a set of messages from a netlink socket.
|
||||||
* @arg sk Netlink socket.
|
* @arg sk Netlink socket.
|
||||||
|
@ -775,14 +795,18 @@ out:
|
||||||
* A non-blocking sockets causes the function to return immediately if
|
* A non-blocking sockets causes the function to return immediately if
|
||||||
* no data is available.
|
* no data is available.
|
||||||
*
|
*
|
||||||
* @return Number of received messages or a negative error code from nl_recv().
|
* @see nl_recvmsgs_report()
|
||||||
|
*
|
||||||
|
* @return 0 on success or a negative error code from nl_recv().
|
||||||
*/
|
*/
|
||||||
int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
|
int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
|
||||||
{
|
{
|
||||||
if (cb->cb_recvmsgs_ow)
|
int err;
|
||||||
return cb->cb_recvmsgs_ow(sk, cb);
|
|
||||||
else
|
if ((err = nl_recvmsgs_report(sk, cb)) > 0)
|
||||||
return recvmsgs(sk, cb);
|
err = 0;
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in New Issue