Commit 7b7e4826 authored by Pavel Emelyanov's avatar Pavel Emelyanov

netlink: Fix NLMSG_ERROR handling

This type of message is also reported for NLM_F_ACK is requested
and no necessarilly indicates an error. The error code is in the
message body.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b0cf603b
......@@ -31,7 +31,17 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *, void *
if (hdr->nlmsg_type == NLMSG_DONE)
return 0;
if (hdr->nlmsg_type == NLMSG_ERROR) {
pr_err("Error getting sockets list\n");
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(hdr);
if (hdr->nlmsg_len - sizeof(*hdr) < sizeof(struct nlmsgerr)) {
pr_err("ERROR truncated\n");
return -1;
}
if (err->error == 0)
return 0;
pr_err("ERROR %d reported by netlink\n", -err->error);
return -1;
}
if (cb(hdr, arg))
......
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