thom311 / libnl

Netlink Library Suite
GNU Lesser General Public License v2.1
426 stars 313 forks source link

NFQUEUE: ENOBUF is reported as ENOMEM #81

Open socketpair opened 9 years ago

socketpair commented 9 years ago

https://github.com/thom311/libnl/blob/48182486341d1de7892494f272e892c0b18ebef5/lib/error.c#L102 :

int nl_syserr2nlerr(int error)
...
    case ENOBUFS:       return NLE_NOMEM;
    case ENOMEM:        return NLE_NOMEM;
...

This is a bug, as I think. ENOBUFS - is not the same as "Out of memory". Example -- receiving NFQEUEUE messages. When queue is overflowed, nl_recvmsgs_default() returns -5 (i.e. NLE_NOMEM) due to recvmsg() returns -1 and set errno to ENOBUFS. Is it indistinguishable from real out of memory situation.

Can you add NLE_ENOBUFS or something like that ?

thom311 commented 9 years ago

I agree that this was wrong. We should have kept the errno values separate from our internal error codes. And we should not map different errno to the same nlerror.

But the error codes are also part of the API, changing them now can possibly break existing users.

Yes, we should do improve that, but we should try not to change existing behavior. Or at least try to be careful