diff options
author | Thomas Graf <tgraf@suug.ch> | 2011-07-14 10:51:49 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2011-07-14 10:51:49 +0200 |
commit | 21d52eabba00089e3319575616a429fb75309cb7 (patch) | |
tree | 90a89e99e2d631d2e6ad3ada665d9f16cd6d5361 /lib/nl.c | |
parent | dba0e91a09dcd928ebc4e8ce4db8cc6cd471d8f9 (diff) | |
download | libnl-21d52eabba00089e3319575616a429fb75309cb7.tar.gz |
Support for NLM_F_INTR
Check if a dump was interrupted and needs to be redone
Diffstat (limited to 'lib/nl.c')
-rw-r--r-- | lib/nl.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -559,7 +559,7 @@ do { \ static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb) { - int n, err = 0, multipart = 0; + int n, err = 0, multipart = 0, interrupted = 0; unsigned char *buf = NULL; struct nlmsghdr *hdr; struct sockaddr_nl nla = {0}; @@ -631,6 +631,19 @@ continue_reading: if (hdr->nlmsg_flags & NLM_F_MULTI) multipart = 1; + + if (hdr->nlmsg_flags & NLM_F_DUMP_INTR) { + if (cb->cb_set[NL_CB_DUMP_INTR]) + NL_CB_CALL(cb, NL_CB_DUMP_INTR, msg); + else { + /* + * We have to continue reading to clear + * all messages until a NLMSG_DONE is + * received and report the inconsistency. + */ + interrupted = 1; + } + } /* Other side wishes to see an ack for this message */ if (hdr->nlmsg_flags & NLM_F_ACK) { @@ -738,6 +751,9 @@ out: free(buf); free(creds); + if (interrupted) + err = -NLE_DUMP_INTR; + return err; } |