diff options
Diffstat (limited to 'libnfnetlink.c')
-rw-r--r-- | libnfnetlink.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libnfnetlink.c b/libnfnetlink.c index 4bb3362..531fd0a 100644 --- a/libnfnetlink.c +++ b/libnfnetlink.c @@ -183,6 +183,7 @@ int nfnl_listen(struct nfnl_handle *nfnlh, struct iovec iov; int remain; struct nlmsghdr *h; + struct nlmsgerr *msgerr; struct msghdr msg = { (void *)&nladdr, sizeof(nladdr), @@ -228,6 +229,17 @@ int nfnl_listen(struct nfnl_handle *nfnlh, return -1; } + /* end of messages reached, let's return */ + if (h->nlmsg_type == NLMSG_DONE) + return -100; + + /* Break the loop if success is explicitely + * reported via NLM_F_ACK flag set */ + if (h->nlmsg_type == NLMSG_ERROR) { + msgerr = NLMSG_DATA(h); + return msgerr->error; + } + err = handler(&nladdr, h, jarg); if (err < 0) return err; |