summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Yasevich <vyasevic@redhat.com>2017-06-01 11:01:16 -0400
committerStephen Hemminger <stephen@networkplumber.org>2017-06-05 12:38:19 -0700
commit735a52ceda9384bfcaf4285cc4308d9d3aeb942b (patch)
treef6b2d58b325c60e4fe05057590e9cb49698c3a88
parentaa883d86c093126cf4d1404e54b40bf6e620fb11 (diff)
downloadiproute2-735a52ceda9384bfcaf4285cc4308d9d3aeb942b.tar.gz
ip: Add IFLA_EVENT output to ip monitor
Add IFLA_EVENT output so that event types can be viewed with 'monitor' command. This gives a little more information for why a given message was received. Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
-rw-r--r--ip/ipaddress.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4900dce0..f06f5829 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -737,6 +737,26 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
return 0;
}
+static const char *link_events[] = {
+ [IFLA_EVENT_NONE] = "NONE",
+ [IFLA_EVENT_REBOOT] = "REBOOT",
+ [IFLA_EVENT_FEATURES] = "FEATURE CHANGE",
+ [IFLA_EVENT_BONDING_FAILOVER] = "BONDING FAILOVER",
+ [IFLA_EVENT_NOTIFY_PEERS] = "NOTIFY PEERS",
+ [IFLA_EVENT_IGMP_RESEND] = "RESEND IGMP",
+ [IFLA_EVENT_BONDING_OPTIONS] = "BONDING OPTION"
+};
+
+static void print_link_event(FILE *f, __u32 event)
+{
+ if (event >= ARRAY_SIZE(link_events))
+ fprintf(f, "event %d ", event);
+ else {
+ if (event)
+ fprintf(f, "event %s ", link_events[event]);
+ }
+}
+
int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
@@ -842,6 +862,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (filter.showqueue)
print_queuelen(fp, tb);
+ if (tb[IFLA_EVENT])
+ print_link_event(fp, rta_getattr_u32(tb[IFLA_EVENT]));
+
if (!filter.family || filter.family == AF_PACKET || show_details) {
SPRINT_BUF(b1);
fprintf(fp, "%s", _SL_);