From patchwork Thu Sep 22 06:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12984617 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB8F5C6FA8B for ; Thu, 22 Sep 2022 06:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiIVGWX (ORCPT ); Thu, 22 Sep 2022 02:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbiIVGWU (ORCPT ); Thu, 22 Sep 2022 02:22:20 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF622B5A4C for ; Wed, 21 Sep 2022 23:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ha/TLZDwdkhiw1CReL3QF4VHANJZYOcwlimlWjA3rK6t3CWdzqklvUNVbNJ2c5i4QYkRFz4uhC4YRvaGbeJAG5J7HdJ6KaZvImS1B9szLTNSCye+kGq6kJ5hUDiTaqkTu7WgJiMc4rpkD+Z6x7VmtOi2gGScS9XPzDJkmjwlamwsopeE6SCqmubAQrBOXsSXqI3SWjIAxtA2qG5b0TJ0J2Juj/bCSyQB6IzIdKa96S/BCI7tonzy12adaTJ7AG6cvkZTHc6GGIDHJkh/2KaZyDU46geI4ESxGd2Zx1POhl1/xjDo+RLWus/12FwrD1jvdYVGs9O8ePeYgeYbu73u5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9xE7gh7AzNDz8r8hlym+M2agT/nnW/ntN9rB5cXYhxE=; b=etm6+79IfnKS3VhmQhEf7FMLlgYgOnRdiUjsaFbhQQS6QPOPiR8esYPcVjLozOkfu2CC1S/3a33dpuyaG582VyJsHOzhhHvWnFDKGQrgAPFBepx+xYScgSsEULsH0pYhGPQllZkHQqLSCiEmPCfM0PnKFpKLzad9omJohWUBpv+X6cdfadlpUbynlaRNa3pWCKIyEslATk/iNsKnfacl3vJaE5lxCPQ2uMHGRJ1BapL5bZtNcZcLtZE9PaGd9EdQmmoLJGWpGTADORXVaDC/WGBFoXldpl3Fbu6RMcQdk9U9v/UGMnRwo1bV7rgBIuPXLjnsUz7EEFglwZOhBI6GAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9xE7gh7AzNDz8r8hlym+M2agT/nnW/ntN9rB5cXYhxE=; b=Z7A8MZ6YGbGUzN8Ds37KdCRYLS8w6s6Zw4sr4upLMxSCZUbPeV3gCjX/8kRN1Lge8Aw7NXmHV88QsOJ4+oluc9z7GKn5ufYswP48Pk+2X4vSO+tqaGxwtVpQeiRdaW08veGGnEn0I9QKWrcHJ4aTPtEHiooe7EVzFIpS1iN+eRU8MVmhMG+ol9iLzOD4Ro5RTFZcfqg9yOJopvFOQ+3n7KP97uch6ousn6cuIMHI00d0kBd9mfsdrBxcLv+e2Y2nk+YQEUfDqiY4c7yMJyBkJl0XFz7SBi0oldueLStxxa05FHPCfXI4OucWhCfCzySsCaFshxj0KMf0fLeDYWzAeg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by DS7PR12MB6237.namprd12.prod.outlook.com (2603:10b6:8:97::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16; Thu, 22 Sep 2022 06:22:18 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f%4]) with mapi id 15.20.5654.014; Thu, 22 Sep 2022 06:22:18 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Ido Schimmel Subject: [PATCH iproute2 1/4] bridge: Do not print stray prefixes in monitor mode Date: Thu, 22 Sep 2022 15:19:35 +0900 Message-Id: <20220922061938.202705-2-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220922061938.202705-1-bpoirier@nvidia.com> References: <20220922061938.202705-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYCPR01CA0081.jpnprd01.prod.outlook.com (2603:1096:405:3::21) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|DS7PR12MB6237:EE_ X-MS-Office365-Filtering-Correlation-Id: 75aa328c-65ca-4f9e-e8a2-08da9c62cc85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UZ0mTHFMQkjKVXibpCIrN850SruQrxwNeYWgDN7+uwHjsG5lpiKwg89eHffQP2x0bktkwPTvl4Kldp6Wi5W6YmJqSzaoxyVOi4sMnqV9PW1/VUWSXEKPhlleQA3B8HcFWi4Df3COY1nODfOaLuXszvPClvPteNjK7T7SdpLR78KGEK7uq1OcYUQ0e7SzyYVy8Y+8ab5Rhy/jszGUpATOPaL/el+yaJDZ8ETAqslRke/SZMRKMH7sQW89oNdDuHdK+3rPRJEj+OXkYrBdAuWPPHl2v0foLToOrdk2EfNBu2vKidG/r1OmOI2QSnAiGt0X8Y9fsToPrSUWwioIgBfKK63Q35e9X5JsDYpVU9oZUPJ3u5ysla2asLPclz4PjZCYFyzUagig2o4oK8Q19akfeM6DgrRsadjcmoYKAEyoJwcN6LubWBhBXTVUDtpJBwEjq2ptoaLfVW+gLEDMB+/qsLcGIGwn+tl0M3kWL4AS7qt6gCCTo5OrVOgBIXhS0RsNorUVB+AmjfOaO7hpiFdQQxt3GYZJs+kpMh2O0RvRG6iVTPxp0i7t1KQDr5LfTO7avA4RTsERgD50TMUC1ExnEwujg5O0+51/S1spYCk4YRp0ShI7tDSVeYF0sZnz/QrpGh4PrQelqmADyULYUZJ4fu2GWLWtwKtol93B0k9CL0kJOuEcFJLqsGCSymGVWMvku8dih4DxFRbfnjV3OoE7oQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199015)(6916009)(54906003)(4326008)(478600001)(316002)(6486002)(86362001)(8676002)(66946007)(66556008)(41300700001)(66476007)(8936002)(66574015)(83380400001)(26005)(6506007)(186003)(6512007)(6666004)(5660300002)(107886003)(38100700002)(2616005)(1076003)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CG3tJZRiV0hvcP3mx2MDxaU4bRBy0+KpSD9Ozno2dbzz2pL7L7mcqxcqLKm/I6/ikXyGTaSBLU+/fmS1qXIH5VlYTY2AymZLCWhv+EweUWpruH8dDNSecI4SzJp7rBW7RCF2P9DOEo7Qn11XrbMsboTgvaZhjt/Ni78MZeUyu/Ji3oYR8h9l1mAi0TIRmRBk3vwe6qrMrYYFwM83QrxhLK+oeOGafBH8uEpkYEH1Z69gBAucoaICgUb9KV1cAxqu4tnGLpVoCp2eOeOJ7tdiE6/3sbGhOdl78PRFk8614Vdtg/Jv7yUv6s7aXjLNQfFn71bkPCPEOT/rqcgyZ8WazPMEUx14/SRNxtnV7idHPs4VOYEKBY9OmkyKUNI5h7o7iFFcJ3crPErBvJKaRKlAj1kgIe1vxNw7dbkjzqH8M0B4DlJ1g1nwOptOEZo7kkJLdft7Us41AQCLZMGGBaCwNplh3aNNBTOYwpkJxP9d+AZ8DCiGD9DM7cisSmhGpbhagH3JVMDUnoQRLEEpJkYzW0qZSjgHkauI9/qr8ICiLnf+K/Lh39bO/PFq1yzLh8SaLhL3lPNQ2J4yLdWP26zoWU099WhGkmWMrhs8i1r3ZPs1+vuY9PiEQ+spkRmjO0NRQlNzLbxTc/HmG/AbnLzEkPNnJKfduCRPZTi1xiJQmBE7/0IA8m8qAK6aOJYRfS9a80kGkvpCOWMcLV04JChgsgs502s/Kiqq3mmxmre+TZcwj8E7MXexBKxM+ZkDpyYe8oBcSikqbDQUv+xHTiZJZpY3QF5OKQhgeknNUeyyHpu2dfo/R/uZHz6to1mvbg43+GG7kQS0hPCQ7xHp4K8PoQ1gpGCZP8Auhthku9ZqGKhRsE6vlEq+NsI5/XMj3ZJRX8+khAY6UBosZ5g2EgfrUjorBt7r2SP0NI2LLaIYYtid70Mpz8t59wisJQ+cv90yiXe5pVDoF3Ro2Wr37nSoTiAnPF8pL/vYmcPV6SMRXHAiiAo0e1IPXU8L8Z2cYibbTlSPrtiGzS+J93ofWYkJ8Sej7tc2EW1FZY1eudiqaR4IHavSkC7GP8vox4wfkX+FyT73GjdEt9pDz5QDOfpg2v5tjh4+QhxPDPtUC1Y1LcFiVAQswW1r90lcFVa67PHaqZmUqz6J3rHMM6D2LOCj2cjEiAlYdTFUbBi1nXIjephj8G8Mv9bVtAkQxu6SlIAg/1hc/WX4pi+Ihcror1Zy/DnMZZeEzo7Lgga3WCrCvgCegdn7Ec+ASOhvL7BZv/but15HseY9lDqIzcCkMVkGspBh54pUlPCWE/Vjn+Acq044dTXXAHStkcjTp6lBbpExSuHMNc9RdOnTrPoKfNQJBNfKHVp1FelwZNlN/o8lfMZeLwB6HRIQLPPTA9HNc7u/YcL+WyWXlgmXgh6PuiMEv2M5qD9OF8CG1ckDCrBR4hYcHWsiG/Nztsu7PvMGJbuvPVsuMozk54XxnQQsr21ubMLDr21JQFxbkALEi6q8Z2p1ANlWD6atUxhF+9xV3d2gaunReuiQaCYj386AHqk5AbHm6flUbogthUbknq56RSYUaWAXmkDe55S864tsqkZt X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75aa328c-65ca-4f9e-e8a2-08da9c62cc85 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 06:22:18.1213 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2dhMpx2yB2BGbVvIAsEOP4d27RudO/0n/nYY8T4EDNCvOVDb0fn3WsDsBkyLtaz2bRJ6GbTj1NtOlsiCPZGxzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6237 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com When using `bridge monitor` with the '-timestamp' option or the "all" parameter, prefixes are printed before the actual event descriptions. Currently, those prefixes are printed for each netlink message that's received. However, some netlink messages do not lead to an event description being printed. That's usually because a message is not related to AF_BRIDGE. This results in stray prefixes being printed. Restructure accept_msg() and its callees such that prefixes are only printed after a message has been checked for eligibility. The issue can be witnessed using the following commands: ip link add dummy0 type dummy # Start `bridge monitor all` now in another terminal. # Cause a stray "[LINK]" to be printed (family 10). # It does not appear yet because the output is line buffered. ip link set dev dummy0 up # Cause a stray "[NEIGH]" to be printed (family 2). ip neigh add 10.0.0.1 lladdr 02:00:00:00:00:01 dev dummy0 # Cause a genuine entry to be printed, which flushes the previous # output. bridge fdb add 02:00:00:00:00:01 dev dummy0 # We now see: # [LINK][NEIGH][NEIGH]02:00:00:00:00:01 dev dummy0 self permanent Fixes: d04bc300c3e3 ("Add bridge command") Signed-off-by: Benjamin Poirier --- bridge/br_common.h | 1 + bridge/fdb.c | 3 +++ bridge/link.c | 4 ++++ bridge/mdb.c | 3 +++ bridge/monitor.c | 35 ++++++++++------------------------- bridge/vlan.c | 4 ++++ bridge/vni.c | 4 ++++ 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/bridge/br_common.h b/bridge/br_common.h index 841f0594..da677df8 100644 --- a/bridge/br_common.h +++ b/bridge/br_common.h @@ -16,6 +16,7 @@ int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor, bool global_only); int print_vnifilter_rtm(struct nlmsghdr *n, void *arg, bool monitor); void br_print_router_port_stats(struct rtattr *pattr); +void print_headers(FILE *fp, const char *label); int do_fdb(int argc, char **argv); int do_mdb(int argc, char **argv); diff --git a/bridge/fdb.c b/bridge/fdb.c index 5f71bde0..775feb12 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -179,6 +179,8 @@ int print_fdb(struct nlmsghdr *n, void *arg) if (filter_dynamic && (r->ndm_state & NUD_PERMANENT)) return 0; + print_headers(fp, "[NEIGH]"); + open_json_object(NULL); if (n->nlmsg_type == RTM_DELNEIGH) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -810,6 +812,7 @@ static int fdb_flush(int argc, char **argv) int do_fdb(int argc, char **argv) { ll_init_map(&rth); + timestamp = 0; if (argc > 0) { if (matches(*argv, "add") == 0) diff --git a/bridge/link.c b/bridge/link.c index 3810fa04..fef3a9ef 100644 --- a/bridge/link.c +++ b/bridge/link.c @@ -230,6 +230,8 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) if (!name) return -1; + print_headers(fp, "[LINK]"); + open_json_object(NULL); if (n->nlmsg_type == RTM_DELLINK) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -588,6 +590,8 @@ static int brlink_show(int argc, char **argv) int do_link(int argc, char **argv) { ll_init_map(&rth); + timestamp = 0; + if (argc > 0) { if (matches(*argv, "set") == 0 || matches(*argv, "change") == 0) diff --git a/bridge/mdb.c b/bridge/mdb.c index 7b5863d3..d3afc900 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -380,6 +380,8 @@ int print_mdb_mon(struct nlmsghdr *n, void *arg) if (ret != 1) return ret; + print_headers(fp, "[MDB]"); + if (n->nlmsg_type == RTM_DELMDB) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -564,6 +566,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) int do_mdb(int argc, char **argv) { ll_init_map(&rth); + timestamp = 0; if (argc > 0) { if (matches(*argv, "add") == 0) diff --git a/bridge/monitor.c b/bridge/monitor.c index f17c1906..e321516a 100644 --- a/bridge/monitor.c +++ b/bridge/monitor.c @@ -35,42 +35,22 @@ static void usage(void) exit(-1); } -static int print_tunnel_rtm(struct nlmsghdr *n, void *arg, bool monitor) -{ - struct tunnel_msg *tmsg = NLMSG_DATA(n); - - if (tmsg->family == PF_BRIDGE) - return print_vnifilter_rtm(n, arg, monitor); - - return 0; -} - static int accept_msg(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg) { FILE *fp = arg; - if (timestamp) - print_timestamp(fp); - switch (n->nlmsg_type) { case RTM_NEWLINK: case RTM_DELLINK: - if (prefix_banner) - fprintf(fp, "[LINK]"); - return print_linkinfo(n, arg); case RTM_NEWNEIGH: case RTM_DELNEIGH: - if (prefix_banner) - fprintf(fp, "[NEIGH]"); return print_fdb(n, arg); case RTM_NEWMDB: case RTM_DELMDB: - if (prefix_banner) - fprintf(fp, "[MDB]"); return print_mdb_mon(n, arg); case NLMSG_TSTAMP: @@ -79,21 +59,26 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl, case RTM_NEWVLAN: case RTM_DELVLAN: - if (prefix_banner) - fprintf(fp, "[VLAN]"); return print_vlan_rtm(n, arg, true, false); case RTM_NEWTUNNEL: case RTM_DELTUNNEL: - if (prefix_banner) - fprintf(fp, "[TUNNEL]"); - return print_tunnel_rtm(n, arg, true); + return print_vnifilter_rtm(n, arg, true); default: return 0; } } +void print_headers(FILE *fp, const char *label) +{ + if (timestamp) + print_timestamp(fp); + + if (prefix_banner) + fprintf(fp, "%s", label); +} + int do_monitor(int argc, char **argv) { char *file = NULL; diff --git a/bridge/vlan.c b/bridge/vlan.c index 390a2037..13df1e84 100644 --- a/bridge/vlan.c +++ b/bridge/vlan.c @@ -1032,6 +1032,7 @@ int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor, bool global_only struct br_vlan_msg *bvm = NLMSG_DATA(n); int len = n->nlmsg_len; struct rtattr *a; + FILE *fp = arg; int rem; if (n->nlmsg_type != RTM_NEWVLAN && n->nlmsg_type != RTM_DELVLAN && @@ -1053,6 +1054,8 @@ int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor, bool global_only if (filter_index && filter_index != bvm->ifindex) return 0; + print_headers(fp, "[VLAN]"); + if (n->nlmsg_type == RTM_DELVLAN) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -1333,6 +1336,7 @@ static int vlan_global(int argc, char **argv) int do_vlan(int argc, char **argv) { ll_init_map(&rth); + timestamp = 0; if (argc > 0) { if (matches(*argv, "add") == 0) diff --git a/bridge/vni.c b/bridge/vni.c index a0c2792c..e776797a 100644 --- a/bridge/vni.c +++ b/bridge/vni.c @@ -309,6 +309,7 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg, bool monitor) int len = n->nlmsg_len; bool first = true; struct rtattr *t; + FILE *fp = arg; int rem; if (n->nlmsg_type != RTM_NEWTUNNEL && @@ -331,6 +332,8 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg, bool monitor) if (filter_index && filter_index != tmsg->ifindex) return 0; + print_headers(fp, "[TUNNEL]"); + if (n->nlmsg_type == RTM_DELTUNNEL) print_bool(PRINT_ANY, "deleted", "Deleted ", true); @@ -418,6 +421,7 @@ static int vni_show(int argc, char **argv) int do_vni(int argc, char **argv) { ll_init_map(&rth); + timestamp = 0; if (argc > 0) { if (strcmp(*argv, "add") == 0) From patchwork Thu Sep 22 06:19:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12984618 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39F10C6FA8B for ; Thu, 22 Sep 2022 06:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbiIVGW3 (ORCPT ); Thu, 22 Sep 2022 02:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiIVGWZ (ORCPT ); Thu, 22 Sep 2022 02:22:25 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D48E0B56F4 for ; Wed, 21 Sep 2022 23:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=akn+qrVKC7ZRou0otxtEPo+0lC7Erw8FOXLl9RPNpBFqJ9GYr+jZoAEHhj1DCRusTaoYULyMFN/aBjnNv5jvksJdfVJtPYb8VE52Gqz+e1M6hYH09aKLY7DkTJe5RarfLUSIeqDNyQCoOuEEOimRpAaQT1mPbBZOec5xM117kI5iO1dlWkIstBkjTJeByIJofpw+pOmNuUisePLsBRB5DV7AYxWChLaEPhwZ2VCoLe+fcpeMvegrgBkVn7hr2e6ceL4fILicvbH9DwvOM4dnqulVpltFTlkfGaRmRg0Kx7OY89K+s3DNZ6A+A93zduQTgomqx50EsqJ1i9SFGgL2ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3hX2bhBRYAKjUQcf55Y7gdFLiKJIeB3CJ/sBsv77iwo=; b=DyF8CZWCFWzlsM34HlOyIxGwb2a4bNRRLmulOOlT9FrM/6NfMl+vniJzQxB5lGPU+a3cqI1BTM2dUlzEaHd0qWoE15kHXj4U9yAI3bmiV66yPSLFEm1dhZvToA7hp5A0lP0QPOMc81knTf7J2W5+ctyLaDKaYBUfCc0HCqdvQwsHuHuIg+L3GpZD0dHW8pcpGsZt3pfbb/AYt1L5uLFlXeIZkROddoWkU+Yjd2Dt+RbJ2d8EBUAuSYO74aWOF+z9FxcmcRHuyvUU0IXpAElWrw2+VJee/QwVSvClpDNfjk5nu6F4qBI9ZJNEqvlz+zsp9KWqM7R1PehHnztdQ0GD9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3hX2bhBRYAKjUQcf55Y7gdFLiKJIeB3CJ/sBsv77iwo=; b=RASUCRv8WXPJ0Lq4sRgCiZVJObMr1kYerqaS9HTKWDqtns5apXhu2+vT8tnezWwV1nKxI5k7LPFLaWDRwOi3hZ52nBaqWvAywI6Z/vLxgIvwWVCZqvGk54nVy97h93gQQbe7gcgoKi5URXRFFqaUwnWXovKreZMkE9QrX/ndUQuIX6URdxIKFFWvuQz5eI1G/tpSjObqay0D7IIO2vw6zFJeCyj3n2ft1ytasrhxP30lq5UKtLrCJdFcLRtRUsDYLemW9HTxQLi1RvmcQem411P6llKoPsoSAyaMG30y1bzx4iJoz2b4ses0CJ4Qjm1FvnFDRaBuBIOeSq/LqYqLGQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by DS7PR12MB6237.namprd12.prod.outlook.com (2603:10b6:8:97::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16; Thu, 22 Sep 2022 06:22:22 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f%4]) with mapi id 15.20.5654.014; Thu, 22 Sep 2022 06:22:22 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Ido Schimmel Subject: [PATCH iproute2 2/4] ip-monitor: Do not listen for nexthops by default when specifying stats Date: Thu, 22 Sep 2022 15:19:36 +0900 Message-Id: <20220922061938.202705-3-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220922061938.202705-1-bpoirier@nvidia.com> References: <20220922061938.202705-1-bpoirier@nvidia.com> X-ClientProxiedBy: TY2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:404:a6::19) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|DS7PR12MB6237:EE_ X-MS-Office365-Filtering-Correlation-Id: 312896e4-d9bf-453e-d972-08da9c62cf36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JlsKTti2MijWO7KsfUMR+FWkimA1K2C02SZtBRpXjn7FV8Hdgg0MjLWIoWhqR5qqeBYxQViVR5K83kr2lCOaqKkeal3DzRBTVRYNvZmQH1II49PxiKz4FdATWCfmoP9oxwAaltOhq//fI7UdtFwA0pjY9veF0gB5UnyI3RzfKRE47z/5Z06IqaFetaMx6l1igIsCKXOcu/MH2StXNLLnxNIydLc0z9V8lCQEOQ8hBNbWbBNJgNkG4KAr7Gz4YcRCCgRgkmtVTpC22r27Ta/SxJf1Y6KE/OpQNQyNJaCOHukmYRqDZwJofQ+n8grZN6fSLZ3pTv56TToElhITeNA+I4cWOchSfet6/R6a9PUqw/p5qSki0CNolqgWYN6kD8s8/7O8ixAaLCuG+cQ/fIonCD5RTtnoEsvar78t0sCnhTt7f2bNKwSdgLgtGGsLBX5GA7vBSoH5dVc6uGGMAXJ+TU0kjHKurvJNLLVgKIWzr7qu+QV4TAc0bdZpRFzan+kmEuS9MMQr3NWSsAZYOQb/y1n55IKKRJWAQ4xa225bV9I2Lz9mvXtgiuF56gJEnhwonMAePALRpHLoL6sxoNObuGTip42OCyrsUs//m+4pJxScjBV2RfZwOn7fcPUgT3/iA3Eveza85mYMAHroq++c2EbpEpthijpo8sf36IiTSSlj/pzmzsNwE8UCP8pL6rcDHWlsx8n8h821A2zDihjWug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199015)(6916009)(54906003)(4326008)(478600001)(4744005)(316002)(6486002)(86362001)(8676002)(66946007)(66556008)(41300700001)(66476007)(8936002)(26005)(6506007)(186003)(6512007)(6666004)(5660300002)(107886003)(38100700002)(2616005)(1076003)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5mQLk1EXV/9paAw5i7zDXmLGDbHrBSrFTCq8YeYPhYRrhAjfhVKct2MBLdlMWG1aqc7uiapElVEClHoSdVllf9+rgrqStnHBegvaWGGpKCrzN6W2mJva0dXc077Y7wBiVAuFwW8pWuH8oCEwGHtVdmSmpJe412YlmOBN5eaNnSeb49hcYfUU/Zekxm5no+UDpVHVjb/o0xZROqRhXCSvvG3WtfmsQJ4tlDIMqE5uJnb+0fm2Ze+D2CKr2ER9iz4gsIBMhZUP5Ku4iPw3e9Rhw37ltkYNwAMhKbswzmTzzXACg7rkrotlS0OUJy49OfsF72+VT29VCl4coe2lp6UOGD5j75hozQDh2SbKciiTd27dbAClw02deirFkU3mZH/8uU/fmALXoxRfhah7GiveeX3xRYmJvcU7uffpbllYIbuCAoI20mXG0kaigiSgIOd8xSahF5is8DogSJIkO428ViGIEoxlSmFhb+LU7kX69Dqige0kAOUueOcbkRgA+YRn4uv+700UTYuZ1YdwVXtU8VdUy1NX2kOrSXJmg83Cd3JrEGF+9XyntgbYpYNVD5QhSdA/uTfCSUBgf1tu4kcHLQ2PnhgaRPlUtnluLQ2uSep0wDXn2lWocZdjXcy1SuseAu2SLHwQoNOXKlb5i7Q3ULbT+KqoJiPQanGg/m++BwRzhWA2b8tsgQ1PnRZGIc/+dt0v8FnlO2SV91R27uUhdyvspQzTBCJekBSlZoaZl0fAlbms2HFr0LyOa0EAKKm21u09iXhNVj3E01RExKTTtW6lWwW5TeybEcHImyA1I/vn/H7JHje+HJBVl/kSLIEDjzc9VKJOZmV2JbuIF0v2pPqMAkQdGrP1C8soI46LMZV/WKEREBys+fJO6PZT6Qw37bePMJrgVriBim3Ot4OIa//D181iA8ZL7QdZMQJ3aY0Mq4nLZL6eIgJ9X8qyJZ+tZhUxBffxGiYE0/4PiOTPGvP2xi4FUuZAGDhLBgW1SMAO6koqM3wl0SIsQ3U8W6n8wnmsI7HEa9ohsLXtcdtRbi0qB+Gk940yPfVqIblN8bfBkwu6e5oQAMLTSURFk+65730lA16M+GJ61Le1xUcHmJSrf/fO6KxJQkH6H2hjB7Fi2BcPJvEONFfSOAYDFXd2OeF8yb2HF0yuYYcuOwJFL5EXRo4vds/uhSe91GEkUur7RwgpCulIefFTtJTVrLzG73VHpR2ba9wat3XBGooBb2OFFAO3jvZ+Q3cWXKnE1uCLcXTbiEXtQkbQhjkyDzCBCID1raqsyk7O9iGWjOwZAq0nH5Zw1Wt6N7Ji3YNWWrozqdkrl3qMdHl6TERXd2MlHiqs4zTaC/S5yhKUZsTiJ7VmIOU+Y3RkwjQG7+s7PGa+G1dVWf4ZeTTmdx/V0gU9yzfUWTzdsg5njxnCF7YSac0o30rtRDzvSb47AHveEJ6qro6HOsnebYhYMnW2Wp5Qkna82RvFiJT3prj6Z/7AvaI1Sx8cOqp5ADXhRZGxB0KkzaaE/IzJ/cLuZdDgrCmGAL9q4ckNG6lOehLXqq8f1wBmCNnfZSMT5HgiviARQK156Nq4UT0LvHPjfCuvNeVl X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 312896e4-d9bf-453e-d972-08da9c62cf36 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 06:22:22.4334 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0w5KBBtbUW4cBJyDrJS37jvhl9vK0N3Zc6PWxfApg480sdUp1xErqF4XcIi2xKO0fvDMOeGbEoB/z1UnN1JBcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6237 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com `ip monitor stats` listens for changes to nexthops and stats. It should listen for stats only. Fixes: a05a27c07cbf ("ipmonitor: Add monitoring support for stats events") Reviewed-by: Ido Schimmel Signed-off-by: Benjamin Poirier --- ip/ipmonitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c index a4326d2a..380ab526 100644 --- a/ip/ipmonitor.c +++ b/ip/ipmonitor.c @@ -262,6 +262,7 @@ int do_ipmonitor(int argc, char **argv) } else if (strcmp(*argv, "stats") == 0) { lstats = 1; groups = 0; + nh_set = 0; } else if (strcmp(*argv, "all") == 0) { prefix_banner = 1; } else if (matches(*argv, "all-nsid") == 0) { From patchwork Thu Sep 22 06:19:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12984619 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66B7FC6FA8B for ; Thu, 22 Sep 2022 06:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiIVGWc (ORCPT ); Thu, 22 Sep 2022 02:22:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiIVGW3 (ORCPT ); Thu, 22 Sep 2022 02:22:29 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC2251420 for ; Wed, 21 Sep 2022 23:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lj9dJ3X+zQFxYhrbo+MyNbNViZKo2gUUVnwqJjkm84HPtO8FqGONo8lqm0SOrXYsF4ni7oesrn2fnxJOYWwJ4u8m2RJ1r8x4/WFA+9BYb1HMYE+TxCrwnF3cuNXuqkhlzh+qqXG18T+NZtxZAJ4WZSTcvJ5pnAq9xhS67Ab9t1Loclzs+F49wkg0DqT9muutxHpA+ycG5h3k+R6fNPn2JbWLidHkW3pF9JLO5T/mATfAuu2JlwkLO7TxPAHStTd0kSKbLY5mx5QqUfIJ4PGZp3nt31Bu+ILeAAP6kQ0n6NMSgmh9gP0zhkbVlsbY0zL6GHcLBxttIvM0tvInjcrr6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tL9nHvc5yi7J70zYfUCPVaK6yHXGHw4A+LR/ewfN8ls=; b=LWMi+X3MrU4ek0zPHc6+CVgoePruyrWDxUH2vq7ftzqcOE4Xztm+4EhQ43cHio2HgDtiaSt+pdbIMLVHslB/dBTYEyy3+IocYeRxesHYnSKsLAeIWNRmy+l0W0z9fDvc3042p9Xii+pXXjLbLgVqp/DD2PkpWQfXwuNSSIMbbJSdKArKbHnae9WphgceY7z1DwizfnlzkKTXrCttQbOgpYf1rXpp6V/aYSPsfdYmn+XARETK3tdu4rnImUyO5QXj6brVmayrLE3SEFXgT1I39jK3qfXiWehDIJZe7JVCHpYdNLvjV0DXpTU/yXwJHHTNgjobFK2V6H1SN3+tiNd2NA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tL9nHvc5yi7J70zYfUCPVaK6yHXGHw4A+LR/ewfN8ls=; b=ittXIJcedPztfaXlpn4LGAuUaj+gEFHJJw03QMYYQdQxvv1XA6SvhvArhCC8vWroWBDMZi1jU8oQ2Gu5TU9cXl19qf8TirzlbTZXUB8YcGHgMIqY4izG8L4dBUkm2+WmY2qB2qHKrpMdZmnx37C8OJng+H78bp81/sXyuWbKY7oIi3uW9DfyfV/mFj8W28VtUK/aojA6ApG8u9tlaP+vHTzQh9hWH83IMA3v69SF2a8ezIc1I0S7iwz0E4aczKL6/+bqpNGENfmypIlwBqOpMfG8r0a8Ug7AB/XFt1P8NVjBvu4ohu3tocyvAkMs/BxD5RUxU+3PCLP8dMCU2CdDgA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by DS7PR12MB6237.namprd12.prod.outlook.com (2603:10b6:8:97::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16; Thu, 22 Sep 2022 06:22:27 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f%4]) with mapi id 15.20.5654.014; Thu, 22 Sep 2022 06:22:27 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Ido Schimmel Subject: [PATCH iproute2 3/4] ip-monitor: Include stats events in default and "all" cases Date: Thu, 22 Sep 2022 15:19:37 +0900 Message-Id: <20220922061938.202705-4-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220922061938.202705-1-bpoirier@nvidia.com> References: <20220922061938.202705-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYAPR01CA0234.jpnprd01.prod.outlook.com (2603:1096:404:11e::30) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|DS7PR12MB6237:EE_ X-MS-Office365-Filtering-Correlation-Id: dc70fc35-77a5-4028-95da-08da9c62d210 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +QKeX1sR9AagB54IMEjXUYOiKASnwWTnuTNDYKeRKZshl69Vlt9iQHgnvrAUoc5ppd9k2m060W0faPnf0oaUl6CqUoq1mmoJxxkAuxALf0zkbsLPt128yfCjSpiH6g4UGtfE/rQkjq0jSmCPj8bMq0MJLTwAktra9qDkev0tlV3D8LGUGxk85syUse+OB2vSC1c3AwW8NAND6oEnmI5DopuTTR2U4zCHQRGWxZ9Hee76lvSKyeWwTjDpzyXf54zwcf5KbKrvo0UDWak65TQ3EnGGYgKI2PGAJVOlj6TR7hEDTR+7TQk01uGMS0zzcizgJGLLMPen/JwCrtGJBr7nqaGE41+hEOb/NUax2cGxuUoGPZZoCwgmvgnU04uH4uNiV9h6TRinSHCrvlzYRaYJ+fBW3y7IPYjzWxpVlYp1qn64ftSaY5jtT0Z2rrVhTF/d2vlP5ZT9rpQhEilQkSTWbKO5jfla0PxZlQYwWCbTm/ZltDwyoXOE3MIZXId/0Fz0ytFK2Jkpx+QR0mEUZKFrBo+aD1ulQX2KZVRE3Ht715vFYSM3IEjriMO/TAECGDI+qlW4lfGP78lpgxkGz+/Mu/LkBnyV9I7JbdLsES9HHL9Re6u+ofuYiMwLlWCUWJ8bek2qNC9DfsB4hPF1R0JtPumNSsNUpcVyBHYu63iGPSKCXa2m3NXIIOI/rYUItotcc2lN+FuIA6JhugCMhNInbQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199015)(6916009)(54906003)(4326008)(478600001)(316002)(6486002)(86362001)(8676002)(66946007)(66556008)(41300700001)(66476007)(8936002)(83380400001)(26005)(6506007)(186003)(6512007)(6666004)(5660300002)(107886003)(38100700002)(2616005)(1076003)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f8Of75NrE7nVlyfbtRU08204k+fNFulP1l+d0Y+9g0D2OQE0lVpqSAERN1LvBV3T1PHWl/Prxxqbhgk8gogyBfgJecQhM7B/IouDc/aKkoEDRpzpbgQB+la1cnEleg79XhgsdyeNR/FZjLgEDqQOedAud7GyqFd1MG5rVDxK5W3w9WUJPzdEfIpqclwxtDk3O90eGL7viv2Ie5YkKfjvQrWE+6f1Ey3LJebamWdfKqefypapwj+Fu6oRAE1XbHQrZjiEb4QtpZr7KHIVHOei8uztTWossq1o8wsxXv2ZOUUbCruCe9888A0wn/YFRwXXejO/vPJsjCRRGIfUcG+vLDXUSIA1wb+SQqPoDLegRYnqFapqw/vjv6c9WG9eDIHh7nYeVar7fyqDNzb/ARs2P6Go1vEFYRV6SIhuqr29FP4QSm3zZ8O5o5TPX3PG59aIeGEcN6+l7KYvYbKubkl4jFKb1BpM0m6k0gZ0iY+hBCaZMsRzTFOBt0diZ3uU+PRtvPwLOWx4ohJqngQfwPy5s7RfXyDenClmQVbrVKRf/JvkwZijvJ+VX0S+yWtwcRtvQP1vZZW2BlVDvVMxyuJAaJjNsofHl8no3syOmpOnWx+FzxNshKFLnglTYUoj76wBudCaki1STC2lpwfO3OvKPwLIOaJ4eXrpC9E3Jfwd/KEdwCfA3B4dYfSSPuovwrIo/8fHmjhIgKsqvQ8ITt7QofiSwz3nIyUsIqqQJ0OaowKJP2k4kHulpv4fFCWlxw9cnDAzm0M20MYgnbCS6GoqMS0ZA/M0vUqbqu5EqswRv8BzkBfWbG9B+6jdQrQwXxaJqB2wQh/sF7L6aN85eN/riB8h70ZAbYI+9BPWkJbeP/Y2ugPHX82Blw97JJ5uIGTkW/UneXMJfW9c7gwPTWWtOiLIFKrihoJMfTSqLDmOE9FtYY2Yw0eO6eZncEqv+vWQq8spAvG10JJLBhnsLHVFQYa6PzBOvc4f4WpHoHUWe6mrfjoeG2A6YYI7SAofE0Mu/OZp3UY0Fn/K6DsS9wQlva0+S8orVt0TIzj6ypxIgI64vSU1MYGyrzcjfftuqw86D3OCNoVb66c1aIDLJrrCp43aaUJaCxDf1O98RJiCsr/v1uE3puPsXQLu7BU08Jn/EOVpkxxq1hpc4Yi4UyktS+kgrmhB7DQiVTXWcdR0TG2SnBFg/gsCWKHT0SOmyc9LcdtNN6InbzIC6thrJgRpdnx372GeDytlMkiMRbvHlpDF1TA7wnT7C7PYdF8/RjMu3ShJ+/6hRfx12tnuk5FWGeJhdMaqWi1bl9lwWNm1gD7jVm8rfdWVu3oIsrc/zR7T0KRE7tps0d6iJKqlsTAYGz83Z7/wRbmIE25uET546IaDWqrDWqCFHFzKZodIcrjdK7LwaHPQsnt9L8Qm7x6yjeeVU7nb5FBpMFH/J6OylcCBRj15XdoWXE54VnoHpcNT8gTY/K/genTcpqv3BKXg4XfZh3wTXUcjEB2VOpIf8+3VyhZ4UB+A15d2WWN0eyfVJPZ+s/Xlu3kNavYVBl0gm1Su2Wxd1TF4/z2DfNFPD0YkQYJJ+IBno99aqbNJwyn3 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc70fc35-77a5-4028-95da-08da9c62d210 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 06:22:27.2954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IIFBrRYGTnvvzgQjJVispitl9DW2jAxs6/4UiWKm3TZesyWpVKoAi5Q3nWBtNTZmUhDepNMQJxhXv+auLUi38w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6237 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com It seems that stats were omitted from `ip monitor` and `ip monitor all`. Since all other event types are included, include stats as well. Use the same logic as for nexthops. Fixes: a05a27c07cbf ("ipmonitor: Add monitoring support for stats events") Reviewed-by: Ido Schimmel Signed-off-by: Benjamin Poirier --- ip/ipmonitor.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c index 380ab526..cb2195d1 100644 --- a/ip/ipmonitor.c +++ b/ip/ipmonitor.c @@ -180,6 +180,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl, int do_ipmonitor(int argc, char **argv) { + int lstats = 0, stats_set = 1; int lnexthop = 0, nh_set = 1; char *file = NULL; unsigned int groups = 0; @@ -190,7 +191,6 @@ int do_ipmonitor(int argc, char **argv) int lprefix = 0; int lneigh = 0; int lnetconf = 0; - int lstats = 0; int lrule = 0; int lnsid = 0; int ifindex = 0; @@ -224,41 +224,51 @@ int do_ipmonitor(int argc, char **argv) llink = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "address") == 0) { laddr = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "route") == 0) { lroute = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "mroute") == 0) { lmroute = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "prefix") == 0) { lprefix = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "neigh") == 0) { lneigh = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "netconf") == 0) { lnetconf = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "rule") == 0) { lrule = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "nsid") == 0) { lnsid = 1; groups = 0; nh_set = 0; + stats_set = 0; } else if (matches(*argv, "nexthop") == 0) { lnexthop = 1; groups = 0; + stats_set = 0; } else if (strcmp(*argv, "stats") == 0) { lstats = 1; groups = 0; @@ -336,6 +346,8 @@ int do_ipmonitor(int argc, char **argv) } if (nh_set) lnexthop = 1; + if (stats_set) + lstats = 1; if (file) { FILE *fp; From patchwork Thu Sep 22 06:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12984620 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1430C6FA82 for ; Thu, 22 Sep 2022 06:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbiIVGWk (ORCPT ); Thu, 22 Sep 2022 02:22:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbiIVGWi (ORCPT ); Thu, 22 Sep 2022 02:22:38 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2079.outbound.protection.outlook.com [40.107.92.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA08FB5A7A for ; Wed, 21 Sep 2022 23:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Okn3hIUwdJXrY17zUYSO+3A0Rto9GgjRTx8XbxogHZLS0NbZOaFGiUckrjVy/JAjtZun1NLk6csV2AbcnTevSbIbbx0PBZ0JOjhix7zUiD37WX7lp/+TkfGAt3j5js4wmVDeGDWeOVdN5GZ0ZXRW4za13CzpyKHg7YMdQ3jeRw1mk/5IfggQm7DrBOqr0iJm0YdQsD/sQqLOyAJt9qmoMF7OajeDqV8OFA3nZOwViPu32HG24fd/9HofBBS4E6xJ9tWpvwCsACDsgtHlRT/k+vhXZrnMtaVCUnwQ1Ag8Fwo6yw8y/zFtaio9pMmFEnaIJmv3nCQrtqedKjn/mG/gbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wd0Kj+R7UdldQ6sDd/n8+z1wyFi6Zae1fJQV93rinJw=; b=JMTsssNvVNG7KEGo7f/zajs61N1sdUHifeRz4mJQ3C2QviE+RTI5mlsglvsoAK1dGxpR6mTJNG7EmbXFgnG+FI6CVsvbccZMgrqsI86LgmGWRdFNZaT85H07MSrhw/MwX3KbN2rVU2EiVGl9nJTKX49WkpG4ycMwfzpgI/qZhkJF0z8W9GkzZxa0OtP7UO+9hMzP+6HS88xUE9BmoogzUy/X6qQwp6aYxQBfOW2lusUW92aNNgrGuQk7O+Pw1jLw+NpiFXR5dMeSPP1ClnKQM62CIBOcXQMfe1gQtvRP6Xx21EB5D/2SIRikBYXmaB5YSxki7lfnB5BbUffubYsZuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wd0Kj+R7UdldQ6sDd/n8+z1wyFi6Zae1fJQV93rinJw=; b=CnK0YujzC4IBmelzDuT260JxwvThxx64jjIBdhSQ86pAtiqcQVrR29U5rye417BKdS2lJ2yel3QFlf2XxO/UXpzT8Ef38OHZdHI8m6oBcAR8578kQIapGy1LzQ4Y7bR40OdqK+siF/9mFcTph/jva+B5N4BOcJXl1RKRa/H1RlteLy6Ipeb2vetW0U15yrSjPl4FWR0eCdxf3rJ6QXDk15X0+7p0n4xYYCbCvhINF/kwH6CIwoARQi+0y4Mcfnyt0dJ2zv464Th9hOqR7sWtHGaVzLeyM6hZfrKOvX084H4sUChtKQhBt17V9Q+FxutOZHuZMfz73uEoSozQJGsAng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by DS7PR12MB6237.namprd12.prod.outlook.com (2603:10b6:8:97::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16; Thu, 22 Sep 2022 06:22:32 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::4842:360d:be7:d2f%4]) with mapi id 15.20.5654.014; Thu, 22 Sep 2022 06:22:32 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: David Ahern , Stephen Hemminger , Ido Schimmel Subject: [PATCH iproute2 4/4] ip-monitor: Fix the selection of rtnl groups when listening for all object types Date: Thu, 22 Sep 2022 15:19:38 +0900 Message-Id: <20220922061938.202705-5-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220922061938.202705-1-bpoirier@nvidia.com> References: <20220922061938.202705-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYAPR01CA0185.jpnprd01.prod.outlook.com (2603:1096:404:ba::29) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|DS7PR12MB6237:EE_ X-MS-Office365-Filtering-Correlation-Id: 788def3b-a500-4ff1-f4a7-08da9c62d544 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PPGrj9kSl0FnbxgACnpiADbbxbZdH64vughhOYr/QjEKqIJo2GCjLjw36ZqHlkuUCs0DERTrryj3gOTFw0Lt8odSaQkNc9Q2hGG4Om45C5hLaJ0ny7R0LC7bt7r/D/POk96y88Iro99/Ted93lG5sa3cv7wQpbu2XB9t8vKH5O+2T7WyfbzOgM11TeQCll2zD/8dFr89xqzHvyilJWz7WTRfxBLJ8H6qPufZnvDsT93yW0lYbpRBjQX3hkqhxoSVxYNT14V4s/PY0k/sDpwMR3XxEWae9bF/v2MJ6rz02z9AoA8acWGfPI/XfQgcsX3LEczD15IeQKix/xPbgOYivV8qDcGFxEfaJq814V08aXj5ij691kKR26GwqPLYxl2BXySefHgsp9hBQr/hdxD7z0WFZsW8/wQAqB3gCyp9FB0sUjMp2Brb64FPXqH6dCkwZrcyF4mjWYMeCBnMygK3JyaoceYIiOsOgBL4RPgk9JvfDAXdhNanlOqfzyeifTg2GkLoc6YQhiGdXvfiOPR1H6s9HsvzWPIchEdactOt+xqy8uiUjIwPmKmJV2e2X9ybLY38sA1lAfJXXUznqacm9i0df5s5zCim9vOzQw9TR1BH4PhzpttSwOANG81tyheQsAEDStqPeIPb2qGM4FHqUsjZQmtPY5lxzrf6lYfd9hOOy2VG+U9dBJyS3cZrP+9+bYPjS0VsWK/KZtoOF5Mx0A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199015)(6916009)(54906003)(4326008)(478600001)(316002)(6486002)(86362001)(8676002)(66946007)(66556008)(41300700001)(66476007)(8936002)(83380400001)(26005)(6506007)(186003)(6512007)(5660300002)(107886003)(38100700002)(2616005)(1076003)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6kqE+Ta8rBsRajxwL26HH6e17pXh52B7eJJWuoo/IEQoSdNbShxSCMlLA9cn42G2EYt8d7WQgTn4DBXtggCm+umtbDdqhk60vFN5gHD6UlCz7oshEIjAUzXmrYYy3bpIqAP2jneOkB/grEhPXzbFgd126Pgq/oVWcoPTn1mgmqWHrNqNcPDMA2XYPpmfENBX+XOGwKHb+uR7YrXCUymlVpXhwyer8IWxVlMSz5smVqNv4HFnnZdIj4JKFrpvWfXWnnitNFLtQhC6yQUvVzBVcTrDjRm4GhxrD4+lxqLG7IXNWjv+y+WDiWtUQZCxSThg/eJLBuQlFgFUtf2eeENPtP1SlTjbS0/PG4ypucJK6to0bTix/NBOuTivKUDHTYClLuZ0jKV3Rd8LUv4YiUtzK+RoqtHd5+4JHICSOOonpD+ij6DTGd+Fvz5zqoCgPZTELQ1Fb0p6FZHlsG7gTLHwYgdoJqQvwsA7UScZkB06OT96QWhvH/jmGbGhfgKFJazI73I9HTjeTS2M2FB3TAdheV9FQUjEs/scPY0Rp0GLO550G4WInTjsGVFcn3DTvsdT44Df59nMmkY7vofgqf9w729+sDCVtI8mAe1cajVdDjs5XB2OfHGipB85pfHyXNkRUHhs72peabM52VSa37zLygGKpjnFHS0M9BeVEUJ5VzAnKhFSGWCF6wb8boGUgFsaa4ycRrtAku2L/bCsq81ffF3Qd6N59XWaoaeWMUBe/KdKvTPwezonO4NkWJwYmfYNBPVqxkR50nmE+awt6UZ+TvgtktltCEK2iBxVYy3LAR3iERTebmZkf+4lseaBxbcGFb8JkGWwt26ihrEQ9N6bsCputkWwZ1Je+qpUNnhdxZIHi2SwxOf5cCWZHsS8Y3GVI661qqblkrpjKWI48vX8UX5AgdDLYlGkWrjvOiVYbfPBimQ4VqbSk66qSkJmUKgm3dDRHNkNQPTII/F0zvNQ/1Rtx6X0FFV7XWyH6Xto7a6eOjiwhDVO3agl8pajNJ1o9KjnleEyvdf7Hlsy1zyQRSTLP7XA+P/5fXJ/wZ6xiE1uQ97s0z8iWLbx/Gy6cJ79HFKF30j3dlKLG+M9/xW5rD6SqU8QYYcj1RVyJTMSfgQJNRT8IvPaVyZO9Gk+M8LnuUejRuTI5ei4D8lb6spQ1ntgGP+goGQg/VNySymCjzVhws48DYKrIPY4vfSVTi8/wQZcXbcclcpbFxL9vgXwvrO8lh09Hoktj/8NXgqHGxFDQCWXBWoxUWMwmoXnHu8YjMtdOPaDpIlhIwxMD8kpYVJtqFe/wuquTojfSHCKwQfm8qUDzWvuIUXVYpVUyI5yFqKFkgT14Ksq+b0K7q3u92EDoMrP8TY2V2rMczRTmNiJCje1aqlRHgxfNM2HgSEJeDA6JZ8SunGBJKZadAmyWansJbTjF2SAVO2uyiyZpWupxqsbwzelq1IcCgVLBkLTy2gyw5KmtYYi12josMJKTVnS4w09n/Y8E2oNuNzHIOHed5u4aO0pxjbA2WSUcjjnkvggUpKbMzaOp/OcBQAUrQ6UWIOzZD5T/Gcf9ZLv9//+eK9K4JBIc7aQhyw4k9gQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 788def3b-a500-4ff1-f4a7-08da9c62d544 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 06:22:32.7639 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BE545xnkwnUD19Ng3nQtCg3tfnUgp13K1f6RsNDh82tn9Mn0YdBoWiIBwR0bvvSXtnEzQ4gk6T32iSfyA3z91w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6237 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Currently, when using `ip monitor`, family-specific rtnl multicast groups (ex. RTNLGRP_IPV4_IFADDR) are used when specifying the '-family' option (or one of its short forms) and an object type is specified (ex. `ip -4 monitor addr`) but not when listening for changes to all object types (ex. `ip -4 monitor`). In that case, multicast groups for all families, regardless of the '-family' option, are used. Depending on the object type, this leads to ignoring the '-family' selection (MROUTE, ADDR, NETCONF), or printing stray prefix headers with no event (ROUTE, RULE). Rewrite the parameter parsing code so that per-family rtnl multicast groups are selected in all cases. The issue can be witnessed while running `ip -4 monitor label` at the same time as the following command: ip link add dummy0 address 02:00:00:00:00:01 up type dummy The output includes: [ROUTE][ROUTE][ADDR]9: dummy0 inet6 fe80::ff:fe00:1/64 scope link valid_lft forever preferred_lft forever Notice the stray "[ROUTE]" labels (related to filtered out ipv6 routes) and the ipv6 ADDR entry. Those do not appear if using `ip -4 monitor label route address`. Fixes: aba5acdfdb34 ("(Logical change 1.3)") Reviewed-by: Ido Schimmel Signed-off-by: Benjamin Poirier --- ip/ipmonitor.c | 128 ++++++++++++++++--------------------------------- 1 file changed, 42 insertions(+), 86 deletions(-) diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c index cb2195d1..8a72ea42 100644 --- a/ip/ipmonitor.c +++ b/ip/ipmonitor.c @@ -178,40 +178,26 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl, return 0; } +#define IPMON_LLINK BIT(0) +#define IPMON_LADDR BIT(1) +#define IPMON_LROUTE BIT(2) +#define IPMON_LMROUTE BIT(3) +#define IPMON_LPREFIX BIT(4) +#define IPMON_LNEIGH BIT(5) +#define IPMON_LNETCONF BIT(6) +#define IPMON_LSTATS BIT(7) +#define IPMON_LRULE BIT(8) +#define IPMON_LNSID BIT(9) +#define IPMON_LNEXTHOP BIT(10) + +#define IPMON_L_ALL (~0) + int do_ipmonitor(int argc, char **argv) { - int lstats = 0, stats_set = 1; - int lnexthop = 0, nh_set = 1; + unsigned int groups = 0, lmask = 0; char *file = NULL; - unsigned int groups = 0; - int llink = 0; - int laddr = 0; - int lroute = 0; - int lmroute = 0; - int lprefix = 0; - int lneigh = 0; - int lnetconf = 0; - int lrule = 0; - int lnsid = 0; int ifindex = 0; - groups |= nl_mgrp(RTNLGRP_LINK); - groups |= nl_mgrp(RTNLGRP_IPV4_IFADDR); - groups |= nl_mgrp(RTNLGRP_IPV6_IFADDR); - groups |= nl_mgrp(RTNLGRP_IPV4_ROUTE); - groups |= nl_mgrp(RTNLGRP_IPV6_ROUTE); - groups |= nl_mgrp(RTNLGRP_MPLS_ROUTE); - groups |= nl_mgrp(RTNLGRP_IPV4_MROUTE); - groups |= nl_mgrp(RTNLGRP_IPV6_MROUTE); - groups |= nl_mgrp(RTNLGRP_IPV6_PREFIX); - groups |= nl_mgrp(RTNLGRP_NEIGH); - groups |= nl_mgrp(RTNLGRP_IPV4_NETCONF); - groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF); - groups |= nl_mgrp(RTNLGRP_IPV4_RULE); - groups |= nl_mgrp(RTNLGRP_IPV6_RULE); - groups |= nl_mgrp(RTNLGRP_NSID); - groups |= nl_mgrp(RTNLGRP_MPLS_NETCONF); - rtnl_close(&rth); while (argc > 0) { @@ -221,58 +207,27 @@ int do_ipmonitor(int argc, char **argv) } else if (matches(*argv, "label") == 0) { prefix_banner = 1; } else if (matches(*argv, "link") == 0) { - llink = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LLINK; } else if (matches(*argv, "address") == 0) { - laddr = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LADDR; } else if (matches(*argv, "route") == 0) { - lroute = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LROUTE; } else if (matches(*argv, "mroute") == 0) { - lmroute = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LMROUTE; } else if (matches(*argv, "prefix") == 0) { - lprefix = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LPREFIX; } else if (matches(*argv, "neigh") == 0) { - lneigh = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LNEIGH; } else if (matches(*argv, "netconf") == 0) { - lnetconf = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LNETCONF; } else if (matches(*argv, "rule") == 0) { - lrule = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LRULE; } else if (matches(*argv, "nsid") == 0) { - lnsid = 1; - groups = 0; - nh_set = 0; - stats_set = 0; + lmask |= IPMON_LNSID; } else if (matches(*argv, "nexthop") == 0) { - lnexthop = 1; - groups = 0; - stats_set = 0; + lmask |= IPMON_LNEXTHOP; } else if (strcmp(*argv, "stats") == 0) { - lstats = 1; - groups = 0; - nh_set = 0; + lmask |= IPMON_LSTATS; } else if (strcmp(*argv, "all") == 0) { prefix_banner = 1; } else if (matches(*argv, "all-nsid") == 0) { @@ -298,15 +253,18 @@ int do_ipmonitor(int argc, char **argv) ipneigh_reset_filter(ifindex); ipnetconf_reset_filter(ifindex); - if (llink) + if (!lmask) + lmask = IPMON_L_ALL; + + if (lmask & IPMON_LLINK) groups |= nl_mgrp(RTNLGRP_LINK); - if (laddr) { + if (lmask & IPMON_LADDR) { if (!preferred_family || preferred_family == AF_INET) groups |= nl_mgrp(RTNLGRP_IPV4_IFADDR); if (!preferred_family || preferred_family == AF_INET6) groups |= nl_mgrp(RTNLGRP_IPV6_IFADDR); } - if (lroute) { + if (lmask & IPMON_LROUTE) { if (!preferred_family || preferred_family == AF_INET) groups |= nl_mgrp(RTNLGRP_IPV4_ROUTE); if (!preferred_family || preferred_family == AF_INET6) @@ -314,20 +272,20 @@ int do_ipmonitor(int argc, char **argv) if (!preferred_family || preferred_family == AF_MPLS) groups |= nl_mgrp(RTNLGRP_MPLS_ROUTE); } - if (lmroute) { + if (lmask & IPMON_LMROUTE) { if (!preferred_family || preferred_family == AF_INET) groups |= nl_mgrp(RTNLGRP_IPV4_MROUTE); if (!preferred_family || preferred_family == AF_INET6) groups |= nl_mgrp(RTNLGRP_IPV6_MROUTE); } - if (lprefix) { + if (lmask & IPMON_LPREFIX) { if (!preferred_family || preferred_family == AF_INET6) groups |= nl_mgrp(RTNLGRP_IPV6_PREFIX); } - if (lneigh) { + if (lmask & IPMON_LNEIGH) { groups |= nl_mgrp(RTNLGRP_NEIGH); } - if (lnetconf) { + if (lmask & IPMON_LNETCONF) { if (!preferred_family || preferred_family == AF_INET) groups |= nl_mgrp(RTNLGRP_IPV4_NETCONF); if (!preferred_family || preferred_family == AF_INET6) @@ -335,19 +293,15 @@ int do_ipmonitor(int argc, char **argv) if (!preferred_family || preferred_family == AF_MPLS) groups |= nl_mgrp(RTNLGRP_MPLS_NETCONF); } - if (lrule) { + if (lmask & IPMON_LRULE) { if (!preferred_family || preferred_family == AF_INET) groups |= nl_mgrp(RTNLGRP_IPV4_RULE); if (!preferred_family || preferred_family == AF_INET6) groups |= nl_mgrp(RTNLGRP_IPV6_RULE); } - if (lnsid) { + if (lmask & IPMON_LNSID) { groups |= nl_mgrp(RTNLGRP_NSID); } - if (nh_set) - lnexthop = 1; - if (stats_set) - lstats = 1; if (file) { FILE *fp; @@ -366,12 +320,14 @@ int do_ipmonitor(int argc, char **argv) if (rtnl_open(&rth, groups) < 0) exit(1); - if (lnexthop && rtnl_add_nl_group(&rth, RTNLGRP_NEXTHOP) < 0) { + if (lmask & IPMON_LNEXTHOP && + rtnl_add_nl_group(&rth, RTNLGRP_NEXTHOP) < 0) { fprintf(stderr, "Failed to add nexthop group to list\n"); exit(1); } - if (lstats && rtnl_add_nl_group(&rth, RTNLGRP_STATS) < 0) { + if (lmask & IPMON_LSTATS && + rtnl_add_nl_group(&rth, RTNLGRP_STATS) < 0) { fprintf(stderr, "Failed to add stats group to list\n"); exit(1); }