From patchwork Sat Apr 1 02:50:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 745879 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vw2t50nxtz9s7j for ; Sat, 1 Apr 2017 13:50:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751050AbdDACub (ORCPT ); Fri, 31 Mar 2017 22:50:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60254 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbdDACua (ORCPT ); Fri, 31 Mar 2017 22:50:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C428787E3; Sat, 1 Apr 2017 02:50:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C428787E3 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1C428787E3 Received: from flash.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 326398472F; Sat, 1 Apr 2017 02:50:29 +0000 (UTC) From: Vladislav Yasevich To: netdev@vger.kernel.org Cc: roopa@cumulusnetworks.com, dsa@cumulusnetworks.com, davem@davemloft.net, Vladislav Yasevich Subject: [PATCH v2] ip: Add support for netdev events to monitor Date: Fri, 31 Mar 2017 22:50:27 -0400 Message-Id: <1491015027-1141-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 01 Apr 2017 02:50:30 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add IFLA_EVENT handling so that event types can be viewed with 'moniotr' command. This gives a little more information for why a given message was recevied. V2: Adds all events recently proposed. This way all currently supported events can be viewed. Signed-off-by: Vladislav Yasevich --- include/linux/if_link.h | 19 +++++++++++++++++++ ip/ipaddress.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/linux/if_link.h b/include/linux/if_link.h index b0bdbd6..6cc0b36 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -157,6 +157,7 @@ enum { IFLA_GSO_MAX_SIZE, IFLA_PAD, IFLA_XDP, + IFLA_EVENT, __IFLA_MAX }; @@ -890,4 +891,22 @@ enum { #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1) +enum { + IFLA_EVENT_UNSPEC, + IFLA_EVENT_REBOOT, + IFLA_EVENT_CHANGE_MTU, + IFLA_EVENT_CHANGE_NAME, + IFLA_EVENT_FEAT_CHANGE, + IFLA_EVENT_BONDING_FAILOVER, + IFLA_EVENT_NOTIFY_PEERS, + IFLA_EVENT_CHANGE_UPPER, + IFLA_EVENT_RESEND_IGMP, + IFLA_EVENT_PRE_CHANGE_MTU, + IFLA_EVENT_CHANGE_INFO_DATA, + IFLA_EVENT_PRE_CHANGE_UPPER, + IFLA_EVENT_CHANGE_LOWER_STATE, + IFLA_EVENT_UDP_TUNNEL_PUSH_INFO, + IFLA_EVENT_CHANGE_TX_QUEUE_LEN, +}; + #endif /* _LINUX_IF_LINK_H */ diff --git a/ip/ipaddress.c b/ip/ipaddress.c index b8d9c7d..dfe93f3 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -753,6 +753,32 @@ int print_linkinfo_brief(const struct sockaddr_nl *who, return 0; } +static const char *netdev_events[] = {"UNKNONWN", + "REBOOT", + "CHANGE_MTU", + "CHANGE_NAME", + "FEATURE_CHANGE", + "BONDING_FAILOVER", + "NOTIFY_PEERS", + "CHANGE_UPPER", + "RESEND_IGMP", + "PRE_CHANGE_MTU", + "CHANGE_INFO_DATA", + "PRE_CHANGE_UPPER", + "CHANGE_LOWER_STATE", + "UDP_TUNNEL_PUSH_INFO", + "CHANGE_TXQUEUE_LEN"}; + +static void print_dev_event(FILE *f, __u32 event) +{ + if (event >= ARRAY_SIZE(netdev_events)) + fprintf(f, "event %d ", event); + else { + if (event) + fprintf(f, "event %s ", netdev_events[event]); + } +} + int print_linkinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { @@ -858,6 +884,9 @@ int print_linkinfo(const struct sockaddr_nl *who, if (filter.showqueue) print_queuelen(fp, tb); + if (tb[IFLA_EVENT]) + print_dev_event(fp, rta_getattr_u32(tb[IFLA_EVENT])); + if (!filter.family || filter.family == AF_PACKET || show_details) { SPRINT_BUF(b1); fprintf(fp, "%s", _SL_);