From patchwork Tue Mar 28 14:13:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 744323 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 3vstQH15g8z9s1h for ; Wed, 29 Mar 2017 01:22:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbdC1OW3 (ORCPT ); Tue, 28 Mar 2017 10:22:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60422 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbdC1OW2 (ORCPT ); Tue, 28 Mar 2017 10:22:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02D6C3DBD4 for ; Tue, 28 Mar 2017 14:13:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 02D6C3DBD4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 02D6C3DBD4 Received: from flash.redhat.com (ovpn-121-189.rdu2.redhat.com [10.10.121.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3565B179C0; Tue, 28 Mar 2017 14:13:19 +0000 (UTC) From: Vladislav Yasevich To: netdev@vger.kernel.org Cc: Vladislav Yasevich Subject: [PATCH iproute] ip: Add support for netdev events to monitor Date: Tue, 28 Mar 2017 10:13:16 -0400 Message-Id: <1490710396-2086-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 28 Mar 2017 14:13:20 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add MTU_CHANGED and NOTIFY_PEER events that can be viewed with 'moniotr' command. This gives a little more information for why a given notification was recevied. More events can be be added later. Signed-off-by: Vladislav Yasevich --- include/linux/if_link.h | 7 +++++++ ip/ipaddress.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/if_link.h b/include/linux/if_link.h index b0bdbd6..6b232a1 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,10 @@ enum { #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1) +enum { + IFLA_EVENT_UNSPEC, + IFLA_EVENT_CHANGE_MTU, + IFLA_EVENT_NOTIFY_PEERS, +}; + #endif /* _LINUX_IF_LINK_H */ diff --git a/ip/ipaddress.c b/ip/ipaddress.c index b8d9c7d..ac6b182 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -753,6 +753,18 @@ int print_linkinfo_brief(const struct sockaddr_nl *who, return 0; } +static const char *netdev_events[] = {"UNKNONWN", "MTU_CHANGE", "NOTIFY_PEERS"}; + +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 +870,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_);