Commit c237a720 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

libnetlink: Make sure there is no error happened when dumping is done

If the kernel is misconfigured (say UDP diag module is not set)
we should detect such situation and report an error.

This patch adds a test for error code. Note the kernel requires
a patch as well. Without kernel patch this test do not harm
anyway, thus safe to merge.

#2412
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7de96526
...@@ -28,8 +28,17 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *, void * ...@@ -28,8 +28,17 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *, void *
for (hdr = (struct nlmsghdr *)buf; NLMSG_OK(hdr, len); hdr = NLMSG_NEXT(hdr, len)) { for (hdr = (struct nlmsghdr *)buf; NLMSG_OK(hdr, len); hdr = NLMSG_NEXT(hdr, len)) {
if (hdr->nlmsg_seq != CR_NLMSG_SEQ) if (hdr->nlmsg_seq != CR_NLMSG_SEQ)
continue; continue;
if (hdr->nlmsg_type == NLMSG_DONE) if (hdr->nlmsg_type == NLMSG_DONE) {
int *len = (int *)NLMSG_DATA(hdr);
if (*len < 0) {
pr_err("ERROR %d reported by netlink (%s)\n",
*len, strerror(-*len));
return -1;
}
return 0; return 0;
}
if (hdr->nlmsg_type == NLMSG_ERROR) { if (hdr->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(hdr); struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(hdr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment