diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-08-15 16:39:57 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-08-15 16:39:57 +0200 |
commit | ff0c3156353830540028400aa20eadc9e86fa55f (patch) | |
tree | b31b29db2905d251831a8e2be0d7b783acc580fc | |
parent | b0e778e4b6c39b50b697d049baea2a074a16b189 (diff) | |
download | pingu-ff0c3156353830540028400aa20eadc9e86fa55f.tar.bz2 pingu-ff0c3156353830540028400aa20eadc9e86fa55f.tar.xz |
pingu_netlink: log error responses
-rw-r--r-- | pingu_netlink.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pingu_netlink.c b/pingu_netlink.c index 709e00c..c6800d4 100644 --- a/pingu_netlink.c +++ b/pingu_netlink.c @@ -118,6 +118,17 @@ static int netlink_add_rtattr_addr_any(struct nlmsghdr *n, int maxlen, return FALSE; } +static int netlink_log_error(struct nlmsghdr *hdr) +{ + struct nlmsgerr *nlerr = (struct nlmsgerr*)NLMSG_DATA(hdr); + if (hdr->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { + log_error("Netlink error message truncated"); + } else { + log_error("Netlink error: %s", strerror(-nlerr->error)); + } + return FALSE; +} + static int netlink_receive(struct netlink_fd *fd, struct nlmsghdr *reply) { struct sockaddr_nl nladdr; @@ -166,6 +177,8 @@ static int netlink_receive(struct netlink_fd *fd, struct nlmsghdr *reply) } else if (h->nlmsg_type <= fd->dispatch_size && fd->dispatch[h->nlmsg_type] != NULL) { fd->dispatch[h->nlmsg_type](h); + } else if (h->nlmsg_type == NLMSG_ERROR) { + return netlink_log_error(h); } else if (h->nlmsg_type != NLMSG_DONE) { log_info("Unknown NLmsg: 0x%08x, len %d", h->nlmsg_type, h->nlmsg_len); |