From fa40340d680494547b54fb850a1de96fe33c0d04 Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Mon, 19 Jan 2015 13:55:20 +0200 Subject: [PATCH] monitor: Print netlink core control messages Decode core control messages (NLMSG_ERROR and NLMSG_DONE). --- monitor/nlmon.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 14630830..ed36c8f6 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -1997,6 +1997,8 @@ void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv, char extra_str[32]; const char *str; bool out; + int status; + struct nlmsgerr *err; str = nlmsg_type_to_str(nlmsg->nlmsg_type); out = !!(nlmsg->nlmsg_flags & NLM_F_REQUEST); @@ -2020,6 +2022,26 @@ void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv, NLMSG_ALIGN(sizeof(*ifi)), NLMSG_PAYLOAD(nlmsg, sizeof(*ifi))); break; + + case NLMSG_NOOP: + case NLMSG_OVERRUN: + break; + + case NLMSG_ERROR: + err = NLMSG_DATA(nlmsg); + status = -err->error; + if (status < 0) + print_field("Error: %d (%s)", status, + strerror(status)); + else + print_field("ACK: %d", status); + + break; + + case NLMSG_DONE: + status = *((int *) NLMSG_DATA(nlmsg)); + print_field("Status: %d", status); + break; } } }