diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-05-07 11:26:41 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-05-07 11:26:41 +0200 |
commit | cbded627a15baf792465c0cbe960b36cb9408fe2 (patch) | |
tree | 6fbd344a2225335a345f07288933baf216a26d0a /src | |
parent | d2adc46f2748099316df910d0ecc14e4218590a0 (diff) | |
download | libmnl-cbded627a15baf792465c0cbe960b36cb9408fe2.tar.gz libmnl-cbded627a15baf792465c0cbe960b36cb9408fe2.zip |
change errno values for mnl_cb_run[2]()
This patch changes the errno value of mnl_cb_run[2]() in the
following two cases:
* Invalid expected portID: ESRCH.
* Invalid sequence number: EPROTO.
I didn't find any better generic errno value. EINVAL is reserved
for malformed messages, to avoid confusions.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/callback.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/callback.c b/src/callback.c index 4a73857..ded22aa 100644 --- a/src/callback.c +++ b/src/callback.c @@ -64,7 +64,10 @@ static mnl_cb_t default_cb_array[NLMSG_MIN_TYPE] = { * - MNL_CB_STOP (=0): stop callback runqueue. * - MNL_CB_OK (>=1): no problems has occurred. * - * This function propagates the callback return value. + * This function propagates the callback return value. On error, it returns + * -1 and errno is explicitly set. If the portID is not the expected, errno + * is set to ESRCH. If the sequence number is not the expected, errno is set + * to EPROTO. */ int mnl_cb_run2(const char *buf, size_t numbytes, unsigned int seq, unsigned int portid, mnl_cb_t cb_data, void *data, @@ -76,12 +79,12 @@ int mnl_cb_run2(const char *buf, size_t numbytes, unsigned int seq, while (mnl_nlmsg_ok(nlh, len)) { /* check message source */ if (!mnl_nlmsg_portid_ok(nlh, portid)) { - errno = EINVAL; + errno = ESRCH; return -1; } /* perform sequence tracking */ if (!mnl_nlmsg_seq_ok(nlh, seq)) { - errno = EILSEQ; + errno = EPROTO; return -1; } |