From patchwork Wed Jun 8 12:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873410 X-Patchwork-Delegate: dsahern@gmail.com 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 DE8F8C433EF for ; Wed, 8 Jun 2022 12:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239069AbiFHMan (ORCPT ); Wed, 8 Jun 2022 08:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239037AbiFHMal (ORCPT ); Wed, 8 Jun 2022 08:30:41 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 998E4259F41 for ; Wed, 8 Jun 2022 05:30:37 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id m20so41087630ejj.10 for ; Wed, 08 Jun 2022 05:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=25w7LxQy0AYKz+DVwKAzK720H7bugHWMS4uOX3aKjBA=; b=OXoTr/VP+YOIRo7R8LFjSF62Om1GHYgXwvqV5qtTUWErNsDprw/UI6eKoUot/VVBfC Hmm2m//zw7vHKsCixtUsLIU2I1/pUj2zw0C+Snt6X3Bts3usKp/zVCKUb/kmu6wlaDBe SWzny/NiXpTSdeStejoemCyw1f0KFdjKYrbeNlsoeKhVU/E1E8Hl3U1LDK/3ySHgIRdj Umb7vPl6DsMNZ3ZqU0FfJ1SAKTyCpM/laBC5XpBzKcHUXgT+vhHxlfkz8nLieyiEUrxi TqcEOs0T8e+GmRSjdP0loOzENVS5S2zez0rjls6K6jhMzuWY8ctXC950NK2QKj++Bbqm 1IpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=25w7LxQy0AYKz+DVwKAzK720H7bugHWMS4uOX3aKjBA=; b=0oouALlWfh/WhsJx8q4A02agpj5fvtqIKwjmAcvv3AbCrY7CITOVO06hCgIg+DRhb+ bX0IJMvkO84DpPOnlKy2NhAoYefQfzs9CyOQJ2uu7zK1WR3YWvCgp1w85f0cKFZOXnU1 0McLwc9h29YCKnmSYJjZEQw5NxOdONWcYL9ZBST8/pkejSLp8cJHxR1+Xl3BImFxrwkk HhODSPdydtUGQeSF1aPqtJPW0l1wY0Hoa/xcIAng/uKkgZhqYz15HMSAQ7HTsByVOs9i Bt6lW7VfMi1hRHiodeoQ2r+yaB/YY0P6+XQsQC3PEZChV49DhVqIRYbn6RTwE9/zd8NP hFpw== X-Gm-Message-State: AOAM531KwkAkUOhV0qpCQtDv1yvWuIKj9M8nOXjp3Ux15pAAoWUlqLSa /1GQHEeZ4WeFbIXnz+JvWZQhg769AFJK5EL/ X-Google-Smtp-Source: ABdhPJzIYW/cRQJ+3GMQpqzy8xorV8r4cA6UrqFT1jJPjqEcBmuF+h3clHgnFqD+n0kyKqZs9M2ROQ== X-Received: by 2002:a17:906:3087:b0:6f4:2901:608a with SMTP id 7-20020a170906308700b006f42901608amr31983251ejv.646.1654691435497; Wed, 08 Jun 2022 05:30:35 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:35 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 01/10] bridge: fdb: add new flush command Date: Wed, 8 Jun 2022 15:29:12 +0300 Message-Id: <20220608122921.3962382-2-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add support for fdb bulk delete (aka flush) command. Currently it only supports the self and master flags with the same semantics as fdb add/del. The device is a mandatory argument. Example: $ bridge fdb flush dev br0 This will delete *all* fdb entries in br0's fdb table. $ bridge fdb flush dev swp1 master This will delete all fdb entries pointing to swp1. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- man/man8/bridge.8 | 29 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index 8912f092ca15..ac9f7af64336 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -44,7 +44,8 @@ static void usage(void) " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n" " [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" - " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n"); + " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" + " bridge fdb flush dev DEV [ self ] [ master ]\n"); exit(-1); } @@ -666,6 +667,59 @@ static int fdb_get(int argc, char **argv) return 0; } +static int fdb_flush(int argc, char **argv) +{ + struct { + struct nlmsghdr n; + struct ndmsg ndm; + char buf[256]; + } req = { + .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), + .n.nlmsg_flags = NLM_F_REQUEST | NLM_F_BULK, + .n.nlmsg_type = RTM_DELNEIGH, + .ndm.ndm_family = PF_BRIDGE, + }; + unsigned short ndm_flags = 0; + char *d = NULL; + + while (argc > 0) { + if (strcmp(*argv, "dev") == 0) { + NEXT_ARG(); + d = *argv; + } else if (strcmp(*argv, "master") == 0) { + ndm_flags |= NTF_MASTER; + } else if (strcmp(*argv, "self") == 0) { + ndm_flags |= NTF_SELF; + } else { + if (strcmp(*argv, "help") == 0) + NEXT_ARG(); + } + argc--; argv++; + } + + if (d == NULL) { + fprintf(stderr, "Device is a required argument.\n"); + return -1; + } + + req.ndm.ndm_ifindex = ll_name_to_index(d); + if (req.ndm.ndm_ifindex == 0) { + fprintf(stderr, "Cannot find bridge device \"%s\"\n", d); + return -1; + } + + /* if self and master were not specified assume self */ + if (!(ndm_flags & (NTF_SELF | NTF_MASTER))) + ndm_flags |= NTF_SELF; + + req.ndm.ndm_flags = ndm_flags; + + if (rtnl_talk(&rth, &req.n, NULL) < 0) + return -1; + + return 0; +} + int do_fdb(int argc, char **argv) { ll_init_map(&rth); @@ -685,6 +739,8 @@ int do_fdb(int argc, char **argv) matches(*argv, "lst") == 0 || matches(*argv, "list") == 0) return fdb_show(argc-1, argv+1); + if (strcmp(*argv, "flush") == 0) + return fdb_flush(argc-1, argv+1); if (matches(*argv, "help") == 0) usage(); } else diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index d8923d2eb076..bfda9f7ecd7b 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -112,6 +112,12 @@ bridge \- show / manipulate bridge addresses and devices .IR VNI " ] [" .BR self " ] [ " master " ] [ " dynamic " ]" +.ti -8 +.BR "bridge fdb flush" +.B dev +.IR DEV " [ " +.BR self " ] [ " master " ]" + .ti -8 .BR "bridge mdb" " { " add " | " del " } " .B dev @@ -782,6 +788,29 @@ the bridge to which this address is associated. .TP .B master - the address is associated with master devices fdb. Usually software (default). + +.SS bridge fdb flush - flush bridge forwarding table entries. + +flush the matching bridge forwarding table entries. + +.TP +.BI dev " DEV" +the target device for the operation. If the device is a bridge port and "master" +is set then the operation will be fulfilled by its master device's driver and +all entries pointing to that port will be deleted. + +.TP +.B self +the operation is fulfilled directly by the driver for the specified network +device. If the network device belongs to a master like a bridge, then the +bridge is bypassed and not notified of this operation. The "bridge fdb flush" +command can also be used on the bridge device itself. The flag is set by default if +"master" is not specified. + +.TP +.B master +if the specified network device is a port that belongs to a master device +such as a bridge, the operation is fulfilled by the master device's driver. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873411 X-Patchwork-Delegate: dsahern@gmail.com 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 09AB0CCA47B for ; Wed, 8 Jun 2022 12:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239071AbiFHMap (ORCPT ); Wed, 8 Jun 2022 08:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239039AbiFHMal (ORCPT ); Wed, 8 Jun 2022 08:30:41 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78DD5259F66 for ; Wed, 8 Jun 2022 05:30:38 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id z7so26840039edm.13 for ; Wed, 08 Jun 2022 05:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PFilY46P21Qfg+IkRYFCHPWYKejEm8juXWh14hB/0zc=; b=hIkFM4A37sx1XaVyMDrD3OHHwE0qCBFXY0eH7X1JGxwWNqLsocVAx4z4O6kMUfXPwK qkiIwOTRWu1/4I459DVrhKwsQdmrsjonqi6s11KKRn4SPJOh9XCq+oJBZkrcVXEVu4Gj 8XNaDIfycsoGlatqOApzA4JrS1InDCyrmCJ9SO5hAGBAiDUAXuIA2V0cWs4taXCpf9Dq tnPX0t4NweVJ0TxARgVLexM/T22v/RyOer0dctc3GgCzLdoEgbHzdhM2Mb5Fcz9CBFrh kPUDMBTTXCaeQwk91GRELWjvlcw/xf7/zQ33xcSYjKtUIF8iJZJiAztbqi/IFpIi0UQy A5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PFilY46P21Qfg+IkRYFCHPWYKejEm8juXWh14hB/0zc=; b=PH692SBnNxwf905DuUQxHXuZ41LljD+G6x0RMf1m1ws8Db/vrSyeMUXBEUhQLzzEFj owp/gkiW7ho7NnFxLWTbk6EFjUO855nnUwOy3uEdcla3LcUXedXL2KiBTXw1Md37BQsM La4LBQv5/kBr0f2PdG2fUos200pRH85U7ZAA6SQ8S06lrjT17N4bmfOO+7Gsdnjgmwdl JhvjeDIJu9KGkwyXwQwOdWmcZi3Hx7FDRNp9Ra2OK+FltPAcfxQT7kUJP0u+0ccBqkO0 tMikWkYGOvls8OE5F+OV8mPA3j7EfLOMqyvtRRKGtc/Ldlnn/z9hIE+QV05zGq/Vwfa8 aUqw== X-Gm-Message-State: AOAM533JeBk/8RjE0yQDMCfCEWKPG09F6jMfSdn/eVabxLJ3V0qTQGT0 Uaw78ihh3NH1Hx5fvtsxUXm954BKNcy1Fvm7 X-Google-Smtp-Source: ABdhPJydgtAveUPyCW6d+4e7jsDGhkZ1i7CZp4d92gDx8j+ij8pDNzJLlgO7MjEJnW+BbS5S9HI+wA== X-Received: by 2002:a05:6402:4408:b0:42d:dc8d:a081 with SMTP id y8-20020a056402440800b0042ddc8da081mr39076695eda.69.1654691436675; Wed, 08 Jun 2022 05:30:36 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:36 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 02/10] bridge: fdb: add flush vlan matching Date: Wed, 8 Jun 2022 15:29:13 +0300 Message-Id: <20220608122921.3962382-3-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match fdb entries in a specific vlan. Example: $ bridge fdb flush dev swp1 vlan 10 master This will flush all fdb entries with port swp1 and vlan 10. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 15 ++++++++++++++- man/man8/bridge.8 | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index ac9f7af64336..c2a1fb957f7e 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -45,7 +45,7 @@ static void usage(void) " [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" - " bridge fdb flush dev DEV [ self ] [ master ]\n"); + " bridge fdb flush dev DEV [ vlan VID ] [ self ] [ master ]\n"); exit(-1); } @@ -681,6 +681,7 @@ static int fdb_flush(int argc, char **argv) }; unsigned short ndm_flags = 0; char *d = NULL; + short vid = -1; while (argc > 0) { if (strcmp(*argv, "dev") == 0) { @@ -690,6 +691,11 @@ static int fdb_flush(int argc, char **argv) ndm_flags |= NTF_MASTER; } else if (strcmp(*argv, "self") == 0) { ndm_flags |= NTF_SELF; + } else if (strcmp(*argv, "vlan") == 0) { + if (vid >= 0) + duparg2("vlan", *argv); + NEXT_ARG(); + vid = atoi(*argv); } else { if (strcmp(*argv, "help") == 0) NEXT_ARG(); @@ -708,11 +714,18 @@ static int fdb_flush(int argc, char **argv) return -1; } + if (vid >= 4096) { + fprintf(stderr, "Invalid VLAN ID \"%hu\"\n", vid); + return -1; + } + /* if self and master were not specified assume self */ if (!(ndm_flags & (NTF_SELF | NTF_MASTER))) ndm_flags |= NTF_SELF; req.ndm.ndm_flags = ndm_flags; + if (vid > -1) + addattr16(&req.n, sizeof(req), NDA_VLAN, vid); if (rtnl_talk(&rth, &req.n, NULL) < 0) return -1; diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index bfda9f7ecd7b..d5db85b943bd 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -116,6 +116,8 @@ bridge \- show / manipulate bridge addresses and devices .BR "bridge fdb flush" .B dev .IR DEV " [ " +.B vlan +.IR VID " ] [ " .BR self " ] [ " master " ]" .ti -8 @@ -799,6 +801,11 @@ the target device for the operation. If the device is a bridge port and "master" is set then the operation will be fulfilled by its master device's driver and all entries pointing to that port will be deleted. +.TP +.BI vlan " VID" +the target VLAN ID for the operation. Match forwarding table entries only with the +specified VLAN ID. + .TP .B self the operation is fulfilled directly by the driver for the specified network From patchwork Wed Jun 8 12:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873412 X-Patchwork-Delegate: dsahern@gmail.com 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 B65D7C433EF for ; Wed, 8 Jun 2022 12:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239086AbiFHMau (ORCPT ); Wed, 8 Jun 2022 08:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239052AbiFHMam (ORCPT ); Wed, 8 Jun 2022 08:30:42 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64619BF78 for ; Wed, 8 Jun 2022 05:30:39 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id u12so41167218eja.8 for ; Wed, 08 Jun 2022 05:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ev2+iOJoaKnXpiPEDPTGzN3dyYsPITLJRElMtt1I5ag=; b=q91uMYrLsKkBwUt+e2No6a8xqcMiIj6IguXDMeiPOg0w2ZxPPcS3/4KSeXZlQxh3gV CK82M3m6Fs75A94XZZYd6VVOOWEza4Yd5KQXtgl8UACE5RPmqGFlskWxjVVvIDsuGcCs ah4Yy4zkWZi2lV+8mFw6uft37q8OHDmn3UNysU3UC9QwB7Z0TNKCv0zPHT2IeuwFYrkl tIJl0HnoSMa94gH3+YI5MWQG3bX8kJmmEUKNwSz9tJfwUtuQut3JDSHdRKJ/FZNHOjr8 A3v6MlI7ntUUdgauaVz4QNgaDpr/s4kpsWc6Q3CaeNYXa6px0XRnuoa5jti/QWrg9bS9 ARlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ev2+iOJoaKnXpiPEDPTGzN3dyYsPITLJRElMtt1I5ag=; b=0fKV8cRjJC+7lhb9vLTF4MnfLvzPgW1eTFdHGzhTqA25tHnaLtdg/gU9OdF0YuCrGh o98lxjul+0bSuLOS1/QCpyqBnUAnPb0xHio6zEJaFxcZQGjUkyThooCdeiGaaakUC0QW Jj6wVD/xKLDCdAcwq1eM4rEeypIYZwf06R1AFsIwolCyX2jURz45Ford+IArpSwtlpGP iLzpYatMGaW80qh7uKo7y1OG7cm5kz7UFcSwwkjvSQL46vbMUyVfTaw5AFj2pE1UPWl2 u1LObI8OM0SdBm3ThRYXM7ulBiF39Gogx682a4/vlqLd5YSAc6bc0fVpIYJUYAvikmhN X/bA== X-Gm-Message-State: AOAM533wFe9ZnQdWqZtQlUxkTewOHJddO9B/Kpxkv4Bm6di03j20pO71 A4A/MWZMHbXgV/2y/yuMXFE7QK4IMP6bdLyE X-Google-Smtp-Source: ABdhPJwOaL23IaHgLus6mbeK1Ub6X2gH90jMiVq7SWH3V42QlhwAGkQbCuGrnE4wdyoHSpLMc36HaA== X-Received: by 2002:a17:906:685:b0:6fa:8e17:e9b5 with SMTP id u5-20020a170906068500b006fa8e17e9b5mr32980668ejb.522.1654691437658; Wed, 08 Jun 2022 05:30:37 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:37 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 03/10] bridge: fdb: add flush port matching Date: Wed, 8 Jun 2022 15:29:14 +0300 Message-Id: <20220608122921.3962382-4-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Usually we match on the device specified after "dev" but there are special cases where we need an additional device attribute for matching such as when matching entries specifically pointing to the bridge device itself. We use NDA_IFINDEX for that purpose. Example: $ bridge fdb flush dev br0 brport br0 This will flush only entries pointing to the bridge itself. $ bridge fdb flush dev swp1 brport swp2 master Note this will flush entries pointing to swp2 only. The NDA_IFINDEX attribute overrides the dev argument. This is documented in the man page. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 23 ++++++++++++++++++++--- man/man8/bridge.8 | 8 ++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index c2a1fb957f7e..4af13eb20dc5 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -45,7 +45,8 @@ static void usage(void) " [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" - " bridge fdb flush dev DEV [ vlan VID ] [ self ] [ master ]\n"); + " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" + " [ self ] [ master ]\n"); exit(-1); } @@ -679,9 +680,9 @@ static int fdb_flush(int argc, char **argv) .n.nlmsg_type = RTM_DELNEIGH, .ndm.ndm_family = PF_BRIDGE, }; + short vid = -1, port_ifidx = -1; unsigned short ndm_flags = 0; - char *d = NULL; - short vid = -1; + char *d = NULL, *port = NULL; while (argc > 0) { if (strcmp(*argv, "dev") == 0) { @@ -691,6 +692,11 @@ static int fdb_flush(int argc, char **argv) ndm_flags |= NTF_MASTER; } else if (strcmp(*argv, "self") == 0) { ndm_flags |= NTF_SELF; + } else if (strcmp(*argv, "brport") == 0) { + if (port) + duparg2("brport", *argv); + NEXT_ARG(); + port = *argv; } else if (strcmp(*argv, "vlan") == 0) { if (vid >= 0) duparg2("vlan", *argv); @@ -714,6 +720,15 @@ static int fdb_flush(int argc, char **argv) return -1; } + if (port) { + port_ifidx = ll_name_to_index(port); + if (port_ifidx == 0) { + fprintf(stderr, "Cannot find bridge port device \"%s\"\n", + port); + return -1; + } + } + if (vid >= 4096) { fprintf(stderr, "Invalid VLAN ID \"%hu\"\n", vid); return -1; @@ -724,6 +739,8 @@ static int fdb_flush(int argc, char **argv) ndm_flags |= NTF_SELF; req.ndm.ndm_flags = ndm_flags; + if (port_ifidx > -1) + addattr32(&req.n, sizeof(req), NDA_IFINDEX, port_ifidx); if (vid > -1) addattr16(&req.n, sizeof(req), NDA_VLAN, vid); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index d5db85b943bd..32b81b4bd4fe 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -116,6 +116,8 @@ bridge \- show / manipulate bridge addresses and devices .BR "bridge fdb flush" .B dev .IR DEV " [ " +.B brport +.IR DEV " ] [ " .B vlan .IR VID " ] [ " .BR self " ] [ " master " ]" @@ -801,6 +803,12 @@ the target device for the operation. If the device is a bridge port and "master" is set then the operation will be fulfilled by its master device's driver and all entries pointing to that port will be deleted. +.TP +.BI brport " DEV" +the target bridge port for the operation. If the bridge device is specified then only +entries pointing to the bridge itself will be deleted. Note that the target device +specified by this option will override the one specified by dev above. + .TP .BI vlan " VID" the target VLAN ID for the operation. Match forwarding table entries only with the From patchwork Wed Jun 8 12:29:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873413 X-Patchwork-Delegate: dsahern@gmail.com 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 6A240C433EF for ; Wed, 8 Jun 2022 12:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239075AbiFHMav (ORCPT ); Wed, 8 Jun 2022 08:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239072AbiFHMan (ORCPT ); Wed, 8 Jun 2022 08:30:43 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACDB254449 for ; Wed, 8 Jun 2022 05:30:40 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id h23so30084626ejj.12 for ; Wed, 08 Jun 2022 05:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oQW3yJvWjyhGF3vYcK5DUCFClEZxPALp4KGWMqOk/9M=; b=Rl8IpHNvpwYCaXLvvcGzCZi2qYvPPpJEBKYC+wyqfGgnp/Bi7UyEVNj8imlZ1AZLbI 05/DpWb9Db59cEGmuXT5vaoReFSB76L/3rGr3FRvj2+kdaWhvb/ehqPFnUn6e+zfCHbn dgqa4AiRhdRBDT6UgmP8RxrItY7LZW0anoxfPY6UMxtm8ygULfIUAVbIldkOqNPjirg7 Le5Y+EdOKDArWmeY5zjtnaf35oxuxrNkMEg94Q5exMMNwS1+nJssxBo6SiyJf0d5kSNU FwgzgvPK6aIvaE7MBVjq0UrPNyrzzqlpkEyN8SeGeZr1j5z5fcj/h53qoyoPx3IAv2ig P4vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oQW3yJvWjyhGF3vYcK5DUCFClEZxPALp4KGWMqOk/9M=; b=amZCyYEwJ3Y4if1vR2iVqrSCs7hHUYf13hGnCKsp6tOkWG7sriygVwNu74HJ9vKtoZ SzQ362rS8iQu9itWpi6A6CJpngqs2rY1yAPEMJd4BixfCXpX+s7Q3cLqWKV+5m8nvEHd WLmU4yh2ludcdFbf9FUfvX27/UMMaVuwoiAIG0BeIyycqhqZ2/vrXZ/TRoz+rgLr7Ydt 6OxlpHukJrmIjYhkrvwk+Fyo31U0bOCGGXYAalg1cIQ9LFO8bSFa6pWImBWfdsKwvsb8 /NJ0FJLrWx8NpKqH1Ggy2ysnt54quBis0Kahg0bzEIiSDXDM6q1zNCjcuGyXQbHQ48IH JAgA== X-Gm-Message-State: AOAM532IKDma5II5GuCJ2II5WRB74ArmTHpp/kCgph5TBlfQt3Sjs3Wm rUIyXaIEitPD/A1fOB2eY3obWZL0R2fYVaFp X-Google-Smtp-Source: ABdhPJyI5py/YL20utdfuR7ob/pfrLf9rVaYEgmk2cA9krUxsI4R7P2aXfw3x8JJ3oLhWSbpuZRCPA== X-Received: by 2002:a17:907:7ea9:b0:6fe:d412:ec2c with SMTP id qb41-20020a1709077ea900b006fed412ec2cmr31227363ejc.613.1654691438998; Wed, 08 Jun 2022 05:30:38 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:38 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 04/10] bridge: fdb: add flush [no]permanent entry matching Date: Wed, 8 Jun 2022 15:29:15 +0300 Message-Id: <20220608122921.3962382-5-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match permanent or non-permanent entries if "no" is prepended respectively. Examples: $ bridge fdb flush dev br0 permanent This will delete all permanent entries in br0's fdb table. $ bridge fdb flush dev br0 nopermanent This will delete all entries except the permanent ones in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 14 +++++++++++++- man/man8/bridge.8 | 11 +++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index 4af13eb20dc5..b1c516141750 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -46,7 +46,7 @@ static void usage(void) " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ]\n"); + " [ self ] [ master ] [ [no]permanent ]\n"); exit(-1); } @@ -680,8 +680,10 @@ static int fdb_flush(int argc, char **argv) .n.nlmsg_type = RTM_DELNEIGH, .ndm.ndm_family = PF_BRIDGE, }; + unsigned short ndm_state_mask = 0; short vid = -1, port_ifidx = -1; unsigned short ndm_flags = 0; + unsigned short ndm_state = 0; char *d = NULL, *port = NULL; while (argc > 0) { @@ -692,6 +694,12 @@ static int fdb_flush(int argc, char **argv) ndm_flags |= NTF_MASTER; } else if (strcmp(*argv, "self") == 0) { ndm_flags |= NTF_SELF; + } else if (strcmp(*argv, "permanent") == 0) { + ndm_state |= NUD_PERMANENT; + ndm_state_mask |= NUD_PERMANENT; + } else if (strcmp(*argv, "nopermanent") == 0) { + ndm_state &= ~NUD_PERMANENT; + ndm_state_mask |= NUD_PERMANENT; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); @@ -739,10 +747,14 @@ static int fdb_flush(int argc, char **argv) ndm_flags |= NTF_SELF; req.ndm.ndm_flags = ndm_flags; + req.ndm.ndm_state = ndm_state; if (port_ifidx > -1) addattr32(&req.n, sizeof(req), NDA_IFINDEX, port_ifidx); if (vid > -1) addattr16(&req.n, sizeof(req), NDA_VLAN, vid); + if (ndm_state_mask) + addattr16(&req.n, sizeof(req), NDA_NDM_STATE_MASK, + ndm_state_mask); if (rtnl_talk(&rth, &req.n, NULL) < 0) return -1; diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 32b81b4bd4fe..9dcd1f0a613f 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -120,7 +120,8 @@ bridge \- show / manipulate bridge addresses and devices .IR DEV " ] [ " .B vlan .IR VID " ] [ " -.BR self " ] [ " master " ]" +.BR self " ] [ " master " ] [ " +.BR [no]permanent " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -795,7 +796,8 @@ the bridge to which this address is associated. .SS bridge fdb flush - flush bridge forwarding table entries. -flush the matching bridge forwarding table entries. +flush the matching bridge forwarding table entries. Some options below have a negated +form when "no" is prepended to them (e.g. permanent and nopermanent). .TP .BI dev " DEV" @@ -826,6 +828,11 @@ command can also be used on the bridge device itself. The flag is set by default .B master if the specified network device is a port that belongs to a master device such as a bridge, the operation is fulfilled by the master device's driver. + +.TP +.B [no]permanent +if specified then only permanent entries will be deleted or respectively if "no" +is prepended then only non-permanent entries will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873414 X-Patchwork-Delegate: dsahern@gmail.com 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 863A7C433EF for ; Wed, 8 Jun 2022 12:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239078AbiFHMay (ORCPT ); Wed, 8 Jun 2022 08:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239067AbiFHMao (ORCPT ); Wed, 8 Jun 2022 08:30:44 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABF6258DD9 for ; Wed, 8 Jun 2022 05:30:41 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id u12so41167461eja.8 for ; Wed, 08 Jun 2022 05:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tLTWfIvEZ40lscWkCNUzGvIbWj1VyxcXotbQfRn3JYI=; b=T6b9Wk22xSEVtNx3VxKGw1NVrUhgBSbNOzNTtnpG9TPlKB9RFUR+/H8gvmzMy8UyBZ HP6ZQ4hySBy062r50sOC011NqU0kpa3HwQsUztmxk190I3W3nAn6pBlDsRZc+RwneUgZ LT9VtD6hjTzYlAi6BjnS4By+/Foun1j0CMUD4hofU5PJCjkL+EmfZmfOYQds6vyJMGrq Y3B9scoJ7ybpkpmIflV5tMuG7h34bGU8Bj6+9hoO7k1BKlyax5VVTD3eHMRlP0C4WkT2 5taroJ9S/ODEwRZo+zJaFzZB5xoNxBMv2avQFPc4UcobMwYo4aLMUYizxNm5z1jUhYH4 c2Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tLTWfIvEZ40lscWkCNUzGvIbWj1VyxcXotbQfRn3JYI=; b=50gMpEAkyokSZH749EqFG68V70F8dCwQpVxURd3cTqyb4XODP8wg5X3vhN9ds94UCr 4Sbk5WktAR78XAQiK4J5gzPLi9aefXdGshOMSrBsfS5V86kZq6mk4BDkJdgQ3KNR2sED Ui9UBgc5sGFeETmX8t9QK2fMqW3NQyZEb5r1ylWlc59dn03QYTphx3n4SOG52nYLTs50 gu5drTnbYxlm7Hxc0y5YCjepNwxhJSWRKUYAO1Baiw8Hvqr5STKQMFMzzVKOeLbv8nFe /HJra4z40Qx0BZjfqT0F7fayI2agnZAKDd/4wBgtuBlXDjhebuKqOhrtKAkDqnrY9J2U MPpw== X-Gm-Message-State: AOAM530nADKa/EBB+++pTDdYfJ1aAstoHLHqnbOFPfjD0FDMd3Aq6Pku USHBcMMTv7tfiF3f4/gMQLrjLn0R/OiKxabd X-Google-Smtp-Source: ABdhPJy1JtSmuhG5LIais2gm6a0ulDQ61P3xWODcPSq/4wVX9EV9n+qABquOBst8Y2IRXnXddQFKfg== X-Received: by 2002:a17:906:a186:b0:6fe:8a06:849b with SMTP id s6-20020a170906a18600b006fe8a06849bmr30679479ejy.635.1654691440157; Wed, 08 Jun 2022 05:30:40 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:39 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 05/10] bridge: fdb: add flush [no]static entry matching Date: Wed, 8 Jun 2022 15:29:16 +0300 Message-Id: <20220608122921.3962382-6-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match static or non-static entries if "no" is prepended respectively. Note that static entries are only NUD_NOARP ones without NUD_PERMANENT, also when matching non-static entries exclude permanent entries as well (permanent entries by definition are also static). Examples: $ bridge fdb flush dev br0 static This will delete all static entries in br0's fdb table. $ bridge fdb flush dev br0 nostatic This will delete all entries except the static ones in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index b1c516141750..93806d7d35b5 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -46,7 +46,7 @@ static void usage(void) " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent ]\n"); + " [ self ] [ master ] [ [no]permanent | [no]static ]\n"); exit(-1); } @@ -700,6 +700,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "nopermanent") == 0) { ndm_state &= ~NUD_PERMANENT; ndm_state_mask |= NUD_PERMANENT; + } else if (strcmp(*argv, "static") == 0) { + ndm_state |= NUD_NOARP; + ndm_state_mask |= NUD_NOARP | NUD_PERMANENT; + } else if (strcmp(*argv, "nostatic") == 0) { + ndm_state &= ~NUD_NOARP; + ndm_state_mask |= NUD_NOARP; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 9dcd1f0a613f..9e2952b8c6d6 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -121,7 +121,7 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " ]" +.BR [no]permanent " | " [no]static " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -833,6 +833,11 @@ such as a bridge, the operation is fulfilled by the master device's driver. .B [no]permanent if specified then only permanent entries will be deleted or respectively if "no" is prepended then only non-permanent entries will be deleted. + +.TP +.B [no]static +if specified then only static entries will be deleted or respectively if "no" +is prepended then only non-static entries will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873416 X-Patchwork-Delegate: dsahern@gmail.com 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 8A872C43334 for ; Wed, 8 Jun 2022 12:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239076AbiFHMa4 (ORCPT ); Wed, 8 Jun 2022 08:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239077AbiFHMap (ORCPT ); Wed, 8 Jun 2022 08:30:45 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2163125A09C for ; Wed, 8 Jun 2022 05:30:43 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id c2so26839129edf.5 for ; Wed, 08 Jun 2022 05:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RMIXgENSbS7lfvXaTKmwghh2k71/pRJlrPplAA50aVo=; b=uythQQJkTQYdCUmGkI9ZUAsoeVCyb6og7LH90hUiuxkYMmJXOy8rboqK6o9Na2RA+w PjXOWk+q/tT0oGxPqqsJuzRHLq78LKYJ9u7mBl3T92guUPkmu0cbNjjwpxdSVs3xLLTO 50cxMO3eSTqzIPfCakY5qoeB/jJflYpoM8Jf4qkcUq5fs2Q10W9zKtJ1wFYoluOsUITo 9b8rMbkBk0B2ojN0ptdr0sa+05qkxkMgA/z9OUcv/ya63Xiv5n+uWGY6urhszBXwpnDk G90S2ae5dws+Y+8LfZlOTCgQq4F2TMvliepgd+66XW9Mq34dpF16swgjbk+tb1HQdF51 hzXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RMIXgENSbS7lfvXaTKmwghh2k71/pRJlrPplAA50aVo=; b=SmBKMHfvg4mLsdePjtIoDkeLhTG+1L+RCbRyFL+P1h+8O0PlE/mzWR6MLeP0Jl+4a7 ngZUbMkUnW9PJTAwRWL/WvjFGrQxwpz1QcbUd/f6UKzjyisQBww6iKeqJ4wQzNTwWKp/ S6BXmltJfIdU1tbTDYcAjjfZ5Pxe7jPtOoAoS0+IufxY3ZiKjO2W2hiFxjW7WUPAFwuk T8joFdku1aPz1chRIO7DFP3RM/qtB4/A8zxhoE1QupaqXHaeTu10r6IXEbCMES+d0OaP po7XkZLYpOLtJUy+/PXJ6VA3eGsQDhYLk3tKLVsvFb0KHVwiGyQsBT6MdxyKOoRmn1H2 mkHw== X-Gm-Message-State: AOAM530Aw5Esqz2eQ3/vlkboF4DRuxYSZHcUM5g6MsHh0QmoybOg7M53 cw/c+IPUeB4K6herKsS53w2xQARnb2BfXzuu X-Google-Smtp-Source: ABdhPJz57i+VEi7FawwJYpysEeF8jQW3QA8k0f5PvFHrlNakwUny3POwOqW+Qr1FeR8Pfw4/sz/GRw== X-Received: by 2002:aa7:ca1a:0:b0:42d:e1b0:2dd2 with SMTP id y26-20020aa7ca1a000000b0042de1b02dd2mr39434533eds.157.1654691441142; Wed, 08 Jun 2022 05:30:41 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:40 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 06/10] bridge: fdb: add flush [no]dynamic entry matching Date: Wed, 8 Jun 2022 15:29:17 +0300 Message-Id: <20220608122921.3962382-7-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match dynamic or non-dynamic (static or permanent) entries if "no" is prepended respectively. Note that dynamic entries are defined as fdbs without NUD_NOARP and NUD_PERMANENT set, and non-dynamic entries are fdbs with NUD_NOARP set (that matches both static and permanent entries). Examples: $ bridge fdb flush dev br0 dynamic This will delete all dynamic entries in br0's fdb table. $ bridge fdb flush dev br0 nodynamic This will delete all entries except the dynamic ones in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index 93806d7d35b5..9c1899c167be 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -46,7 +46,7 @@ static void usage(void) " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent | [no]static ]\n"); + " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n"); exit(-1); } @@ -706,6 +706,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "nostatic") == 0) { ndm_state &= ~NUD_NOARP; ndm_state_mask |= NUD_NOARP; + } else if (strcmp(*argv, "dynamic") == 0) { + ndm_state &= ~NUD_NOARP | NUD_PERMANENT; + ndm_state_mask |= NUD_NOARP | NUD_PERMANENT; + } else if (strcmp(*argv, "nodynamic") == 0) { + ndm_state |= NUD_NOARP; + ndm_state_mask |= NUD_NOARP; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 9e2952b8c6d6..f4b3887a9144 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -121,7 +121,7 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " | " [no]static " ]" +.BR [no]permanent " | " [no]static " | " [no]dynamic " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -838,6 +838,11 @@ is prepended then only non-permanent entries will be deleted. .B [no]static if specified then only static entries will be deleted or respectively if "no" is prepended then only non-static entries will be deleted. + +.TP +.B [no]dynamic +if specified then only dynamic entries will be deleted or respectively if "no" +is prepended then only non-dynamic (static or permanent) entries will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873415 X-Patchwork-Delegate: dsahern@gmail.com 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 E4493C433EF for ; Wed, 8 Jun 2022 12:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239160AbiFHMa4 (ORCPT ); Wed, 8 Jun 2022 08:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239076AbiFHMap (ORCPT ); Wed, 8 Jun 2022 08:30:45 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182F325A088 for ; Wed, 8 Jun 2022 05:30:43 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id m20so41087630ejj.10 for ; Wed, 08 Jun 2022 05:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9K5G/9GMMxCCPUr3eiXhjwJ83u/CoHUJ1RwCnFRoxzY=; b=L0Rpvq1RnH7oaAuSGLwlmuEptcJB958RDtG1NEATtP1t2RwqaJpJoT8SvZACDe/nob ZrgckKmm5G3AAeqGyXLwydxRch5TbZQ+NVmZqAYeN+oCRi/QALO3HhEwU01pj3phMiyR 3OuLn8yMOZEG2PWzyzonZUmVDv8gCDCi1hU0Ag+aokLc3NR+iSCRfetLa8bgcHD3b/V4 bh2k+ciPTewA7X1t3lv/1m1z/oNncZFv9/IbYUCwumMLD1l3UvC0yGegPaNSFz0skaDx JWk43Lt2dK/pyUqpOGhGeqI1rJF8X/NWQX+0DKXL5tuosfx7CuWqHCR4sWm2/nVGisvP bysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9K5G/9GMMxCCPUr3eiXhjwJ83u/CoHUJ1RwCnFRoxzY=; b=KPMCioh+qxjvPYWU/lR26qpZYI7hQXgrWb2qt0vnWOS5yppiiQNhcK45/t8oPMuozK 8NPeCkEa78zzEtKMjRphF8KNwYaqO8Ko9XWHXg9Swxm4RDNnCmWiel3cViQD2fbLYWDO KNBPT8edcjRUJ5QS5aU4eg4Cepc84/B9tFBK6OgVPHDJziEIbh5mR7RRzEichm5EMjkL YPqr2bTrmW12x2zBRVL/Brt+lAU6ik45jcu/3+1RGGijU1lfwXyheC9wD2u2RhfN1boi wVx8K47eMhOtiXgBmW7atVmjCDNwI4Rsb6Bx8l8ns1id/Vlcu07JyA1wPzU7fcfH0yRc Cp0g== X-Gm-Message-State: AOAM5330zPxR8y3Tj0vzysZkos3/leika0rc5CxeIKB/UOjJWRjDQL8c P3T6B7ACBYU/bl1C1b/X5j/D4iABXicKv2TT X-Google-Smtp-Source: ABdhPJxWoYkYZ/bK2BpjMbToRjwigIApzIFaGuY777YEGEe8+3+lSOB993XWyqrrGy8lYgc7y3lXbg== X-Received: by 2002:a17:906:51c5:b0:711:f4ee:6574 with SMTP id v5-20020a17090651c500b00711f4ee6574mr2734606ejk.509.1654691442305; Wed, 08 Jun 2022 05:30:42 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:41 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 07/10] bridge: fdb: add flush [no]added_by_user entry matching Date: Wed, 8 Jun 2022 15:29:18 +0300 Message-Id: <20220608122921.3962382-8-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match entries with or without (if "no" is prepended) added_by_user flag. Note that NTF_USE is used internally because there is no NTF_ flag that describes such entries. Examples: $ bridge fdb flush dev br0 added_by_user This will delete all added_by_user entries in br0's fdb table. $ bridge fdb flush dev br0 noadded_by_user This will delete all entries except the ones with added_by_user flag in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 13 ++++++++++++- man/man8/bridge.8 | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index 9c1899c167be..c57ad235b401 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -46,7 +46,8 @@ static void usage(void) " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n"); + " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" + " [ [no]added_by_user ]\n"); exit(-1); } @@ -681,6 +682,7 @@ static int fdb_flush(int argc, char **argv) .ndm.ndm_family = PF_BRIDGE, }; unsigned short ndm_state_mask = 0; + unsigned short ndm_flags_mask = 0; short vid = -1, port_ifidx = -1; unsigned short ndm_flags = 0; unsigned short ndm_state = 0; @@ -712,6 +714,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "nodynamic") == 0) { ndm_state |= NUD_NOARP; ndm_state_mask |= NUD_NOARP; + } else if (strcmp(*argv, "added_by_user") == 0) { + ndm_flags |= NTF_USE; + ndm_flags_mask |= NTF_USE; + } else if (strcmp(*argv, "noadded_by_user") == 0) { + ndm_flags &= ~NTF_USE; + ndm_flags_mask |= NTF_USE; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); @@ -764,6 +772,9 @@ static int fdb_flush(int argc, char **argv) addattr32(&req.n, sizeof(req), NDA_IFINDEX, port_ifidx); if (vid > -1) addattr16(&req.n, sizeof(req), NDA_VLAN, vid); + if (ndm_flags_mask) + addattr8(&req.n, sizeof(req), NDA_NDM_FLAGS_MASK, + ndm_flags_mask); if (ndm_state_mask) addattr16(&req.n, sizeof(req), NDA_NDM_STATE_MASK, ndm_state_mask); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index f4b3887a9144..b39c74823606 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -121,7 +121,8 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " | " [no]static " | " [no]dynamic " ]" +.BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " +.BR [no]added_by_user " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -843,6 +844,11 @@ is prepended then only non-static entries will be deleted. .B [no]dynamic if specified then only dynamic entries will be deleted or respectively if "no" is prepended then only non-dynamic (static or permanent) entries will be deleted. + +.TP +.B [no]added_by_user +if specified then only entries with added_by_user flag will be deleted or respectively +if "no" is prepended then only entries without added_by_user flag will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873419 X-Patchwork-Delegate: dsahern@gmail.com 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 AB3A0C433EF for ; Wed, 8 Jun 2022 12:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239246AbiFHMbE (ORCPT ); Wed, 8 Jun 2022 08:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239091AbiFHMau (ORCPT ); Wed, 8 Jun 2022 08:30:50 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66A65BF78 for ; Wed, 8 Jun 2022 05:30:45 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id o10so26844085edi.1 for ; Wed, 08 Jun 2022 05:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q/5Fri5VxJYpq4TjJbjEAXubPNUfqRwDqbzms152K4s=; b=Bc3OWzx7Q0k91PaWsMLKcAn9fZf6mnlfJQ4lJHI7wKzJ8WfzaC5kzUpghWfJXX2ev5 mX+4KJwSFnetKckKt5SHJRtdYM96AKTvPG1m2jw01ZdR30wdVnAFv8JrxDUeTQhiv1o+ Fla1WJoPcEW6ym35Hp+f9nkxjvbflJw0OuIXa74g4CBCywVq1i0MsTaBw64Q6Fe1QZzf DjBg9EmlfZMTG4pflQ+P42Nt/FE6YUukIi+eNG3WKmJIsM8h7YQ+/+e3yQtnEm/qEJOB qRES5So7Od8RBE44iwj2HLFVNerOSaVjob5Em9oPKa9DYerp1Jy0BAUpRXJIhDpUqUAn Aayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q/5Fri5VxJYpq4TjJbjEAXubPNUfqRwDqbzms152K4s=; b=u8DMmBzAlVrg+Y6V4tRZhh+bpvmjbtn3MxcZJaGjHyi9KKrmgxzerm5hJvpdwD4o7M 1tSyWdNg2BKRkmREPAT3dN0tNdE71or6HGXVIHfMhF2SbZEypUubRR6aJUq8Kn4qELtu ocxDG17ETHyTPPjp2tvMu5WjtVIdulPAmj9rpF3H0W82bppvLrm4Rv9LuWHm8ttOiV7p RQxcdBCiaQ0EWZhXdZ2S0NXesoeILThg/prlvvman5F/q4g0mhark493i0aeItC9istH ZOwhjLDXzck7wESAcYz2EWyYkzjQtDNi6sfZwcTM5ixFBkbgbN3diB4HOVL9kas5yGuc 3aZQ== X-Gm-Message-State: AOAM533Sa6IKXDAAMHkpNn2c8izNHePYjO5qfrod3mpBFHloY6A8EQ/X 50VBLFn02qe1Vji1XcFpCQJFoSjEtp1NtNA9 X-Google-Smtp-Source: ABdhPJxG4JF23OzLcJw48QRrKCTbaVY+Jw13yFFZe3AQnKmb8GIIPLwtiJrr3TkK8TaE1wifJMsIqA== X-Received: by 2002:a05:6402:d:b0:431:98fe:c5fd with SMTP id d13-20020a056402000d00b0043198fec5fdmr6879400edu.170.1654691443440; Wed, 08 Jun 2022 05:30:43 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:43 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 08/10] bridge: fdb: add flush [no]extern_learn entry matching Date: Wed, 8 Jun 2022 15:29:19 +0300 Message-Id: <20220608122921.3962382-9-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match entries with or without (if "no" is prepended) extern_learn flag. Examples: $ bridge fdb flush dev br0 extern_learn This will delete all extern_learn entries in br0's fdb table. $ bridge fdb flush dev br0 noextern_learn This will delete all entries except the ones with extern_learn flag in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index c57ad235b401..e64e21cb0cba 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -47,7 +47,7 @@ static void usage(void) " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ]\n"); + " [ [no]added_by_user ] [ [no]extern_learn ]\n"); exit(-1); } @@ -720,6 +720,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "noadded_by_user") == 0) { ndm_flags &= ~NTF_USE; ndm_flags_mask |= NTF_USE; + } else if (strcmp(*argv, "extern_learn") == 0) { + ndm_flags |= NTF_EXT_LEARNED; + ndm_flags_mask |= NTF_EXT_LEARNED; + } else if (strcmp(*argv, "noextern_learn") == 0) { + ndm_flags &= ~NTF_EXT_LEARNED; + ndm_flags_mask |= NTF_EXT_LEARNED; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index b39c74823606..af343cc1a719 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -122,7 +122,7 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " ] [ " .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " -.BR [no]added_by_user " ]" +.BR [no]added_by_user " ] [ " [no]extern_learn " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -849,6 +849,11 @@ is prepended then only non-dynamic (static or permanent) entries will be deleted .B [no]added_by_user if specified then only entries with added_by_user flag will be deleted or respectively if "no" is prepended then only entries without added_by_user flag will be deleted. + +.TP +.B [no]extern_learn +if specified then only entries with extern_learn flag will be deleted or respectively +if "no" is prepended then only entries without extern_learn flag will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873417 X-Patchwork-Delegate: dsahern@gmail.com 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 AE662C433EF for ; Wed, 8 Jun 2022 12:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239238AbiFHMbB (ORCPT ); Wed, 8 Jun 2022 08:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239172AbiFHMau (ORCPT ); Wed, 8 Jun 2022 08:30:50 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136F525BFA1 for ; Wed, 8 Jun 2022 05:30:46 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id v25so26875635eda.6 for ; Wed, 08 Jun 2022 05:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mw+TeLN00urjm5eSG5gWepTM2y3SQReXF09d+sH2RpI=; b=pF6zGpn0hiNgwNbZmYFIjRtiR+LxGEunDpOS3rjx/K59qsHvLy1EVFnrjw7OGgCIKO S7GyUQvbKsVo9/oDsL77cI+ymN5XcLWXzolZgwEF4h4prsW+P4rr2NqxH0Vitjb2gtMb 6jEVc8pXrEx16ajRW90dsZ3lhjuSFg6Xql3y9v9Swja0K56rjZJFFU+WwwTn/Q/DQW3N tAW6IVm0Io7TGXCeDH1WCgiMl4poZ7JFwrMg7XxmzWLCkgIkrQYLup6bKslQGEmWzIdv MC6ekCg8GRgoUOt2sZltVebWBzAjGwoefYQw8AUBLmvSLoCIrMXfJc2J7sZLf1ADxV5k M4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mw+TeLN00urjm5eSG5gWepTM2y3SQReXF09d+sH2RpI=; b=ExIO9E5N+8rmZF/qZIxAV0IWSD2xhuhdOE6LXKHRFYXv5iCC4iqUNYpWkBzKe8i79Z 6D2Zb16I3942q/9wqjt9pn1TDb25+kMCTBnHNoogGnbjOd8hH5IVKnzyOOQF4J4lQ3Y4 eO4rZ6M05xbTRIT433kRGTZ6IkZdUaXePh/UWTKGZXn/ggI7WxPCQDzu8yBf7745dMEN fpUeoaUei45FhwKt3zIJwS6iNxaUZzh1AHcHrASpd4ITT5EpPsaeMa7PsfeK5ayA7xDZ Qi2Nx0fwjNYeEtD5Mec8NWHPo+dhvsjJK2hD+P/0TBzzwuVnUwz5Aeevq56Khp+04EQJ cyQA== X-Gm-Message-State: AOAM531k4LWc9fDHxcotHx51oVnB8Bvpks0kKzkN80XDHk8NbiGAG+xC Qz8d3SmUV+Fhz9IByH752h1ntv/3Q5IfY5IO X-Google-Smtp-Source: ABdhPJw9Ya7MMGIXglzptt8zufwuQ7Us73YZ1Ih9Y0JZK/Rt7HBgLvGI+VyWywVO208zutU5Ch3KpQ== X-Received: by 2002:a05:6402:4309:b0:42f:9ff8:3f11 with SMTP id m9-20020a056402430900b0042f9ff83f11mr29741084edc.67.1654691445095; Wed, 08 Jun 2022 05:30:45 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:44 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 09/10] bridge: fdb: add flush [no]sticky entry matching Date: Wed, 8 Jun 2022 15:29:20 +0300 Message-Id: <20220608122921.3962382-10-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match entries with or without (if "no" is prepended) sticky flag. Examples: $ bridge fdb flush dev br0 sticky This will delete all sticky entries in br0's fdb table. $ bridge fdb flush dev br0 nosticky This will delete all entries except the ones with sticky flag in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index e64e21cb0cba..d268e702d257 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -47,7 +47,7 @@ static void usage(void) " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ] [ [no]extern_learn ]\n"); + " [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n"); exit(-1); } @@ -726,6 +726,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "noextern_learn") == 0) { ndm_flags &= ~NTF_EXT_LEARNED; ndm_flags_mask |= NTF_EXT_LEARNED; + } else if (strcmp(*argv, "sticky") == 0) { + ndm_flags |= NTF_STICKY; + ndm_flags_mask |= NTF_STICKY; + } else if (strcmp(*argv, "nosticky") == 0) { + ndm_flags &= ~NTF_STICKY; + ndm_flags_mask |= NTF_STICKY; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index af343cc1a719..ad16b4fe0940 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -122,7 +122,8 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " ] [ " .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " -.BR [no]added_by_user " ] [ " [no]extern_learn " ]" +.BR [no]added_by_user " ] [ " [no]extern_learn " ] [ " +.BR [no]sticky " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -854,6 +855,11 @@ if "no" is prepended then only entries without added_by_user flag will be delete .B [no]extern_learn if specified then only entries with extern_learn flag will be deleted or respectively if "no" is prepended then only entries without extern_learn flag will be deleted. + +.TP +.B [no]sticky +if specified then only entries with sticky flag will be deleted or respectively +if "no" is prepended then only entries without sticky flag will be deleted. .sp .SH bridge mdb - multicast group database management From patchwork Wed Jun 8 12:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12873418 X-Patchwork-Delegate: dsahern@gmail.com 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 4D100C43334 for ; Wed, 8 Jun 2022 12:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239240AbiFHMbD (ORCPT ); Wed, 8 Jun 2022 08:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239210AbiFHMau (ORCPT ); Wed, 8 Jun 2022 08:30:50 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7058325B059 for ; Wed, 8 Jun 2022 05:30:48 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id h19so26903538edj.0 for ; Wed, 08 Jun 2022 05:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aufacjr97z0R0RcEiapQwUaRj/Widdv+CgCH2LPXq7I=; b=WaUuER6DMxWTBMltbxpLxppNMQreWxMpy68AArqzUOc5pqN6KvS/KafB4wxKs+g4u5 vjLC4OcxhR90rlzN4PrniIJ1bAiLJ6ccPaAZJcQhkINcciYXS6KnE262rb/vvHBCgai+ eXA0yFq8y+52S1ESnETtSyAEzVJxHeLQKCXtjbtPM0Lh1qWrjyTuc425+j/0JgfNBL/v UVktaIJlYcif4Dm2OuJm0RsDycL2U8XNyiuG4SyzUqsAnErWj4UNjWGp7KGTvBoQKglB 1OQyZV+hhsgkY1mcBAsVen11UlKJbcBlM3M30vH4S2KZlH0sSsMXftmxmq5dIz84hpbI BUqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aufacjr97z0R0RcEiapQwUaRj/Widdv+CgCH2LPXq7I=; b=g41y2JIZvBoX+vBrsotb9Osw6ipVdOm+mCt0Xp7A0ZMNT6nPa0NGmBmyt18hW+OE7J rGK+6nfnyYmBbodOKXe73IxHSufdHlbYV3ZyEgXK2IwGQ6ZWmCxSEVB1Cc5EuuEtOAsW 4DIOMDRePGmwy6AynHAtc8YzBzs0GXrLm6IGQ1VDuu8MPhPR3psnBCd2k0kcKYVcaAFd cCjDMkG+lVXSjCEgKmb7413zqLBxzGcon5iazkWrHclWrWfqYCOYbqFhQLndyUBzPr+Z EamS/oU2508S3rtu5sUN91sF939F3VKbSYlM7D9T20IKSTZCTxICJ0Bdp1tx8UNFgzhr XIkw== X-Gm-Message-State: AOAM532nAl2ooeyy355w7+XPlnnjwpZoKDP+OcbRR9rdJJ2djmUuWraW dIxB/cFxYA99v9fp4OIQaqzSzO6tmhjLTWJv X-Google-Smtp-Source: ABdhPJwgwQSOtB2Y6DN9JLUqPaYS6RpRkg5CTrbJE6PVpmjgD3xxnRhVuZZmQj20YfrCKCZqaXb7oA== X-Received: by 2002:a05:6402:3318:b0:42d:f04b:f50a with SMTP id e24-20020a056402331800b0042df04bf50amr38803401eda.210.1654691446422; Wed, 08 Jun 2022 05:30:46 -0700 (PDT) Received: from debil.. (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id o7-20020a50fd87000000b0042dc25fdf5bsm12161687edt.29.2022.06.08.05.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:30:45 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com, Nikolay Aleksandrov Subject: [PATCH iproute2-next 10/10] bridge: fdb: add flush [no]offloaded entry matching Date: Wed, 8 Jun 2022 15:29:21 +0300 Message-Id: <20220608122921.3962382-11-razor@blackwall.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org> References: <20220608122921.3962382-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Add flush support to match entries with or without (if "no" is prepended) offloaded flag. Examples: $ bridge fdb flush dev br0 offloaded This will delete all offloaded entries in br0's fdb table. $ bridge fdb flush dev br0 nooffloaded This will delete all entries except the ones with offloaded flag in br0's fdb table. Signed-off-by: Nikolay Aleksandrov --- bridge/fdb.c | 9 ++++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index d268e702d257..b71b20c8b6e6 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -47,7 +47,8 @@ static void usage(void) " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n"); + " [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n" + " [ [no]offloaded ]\n"); exit(-1); } @@ -732,6 +733,12 @@ static int fdb_flush(int argc, char **argv) } else if (strcmp(*argv, "nosticky") == 0) { ndm_flags &= ~NTF_STICKY; ndm_flags_mask |= NTF_STICKY; + } else if (strcmp(*argv, "offloaded") == 0) { + ndm_flags |= NTF_OFFLOADED; + ndm_flags_mask |= NTF_OFFLOADED; + } else if (strcmp(*argv, "nooffloaded") == 0) { + ndm_flags &= ~NTF_OFFLOADED; + ndm_flags_mask |= NTF_OFFLOADED; } else if (strcmp(*argv, "brport") == 0) { if (port) duparg2("brport", *argv); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index ad16b4fe0940..d4df772ea3b2 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -123,7 +123,7 @@ bridge \- show / manipulate bridge addresses and devices .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " .BR [no]added_by_user " ] [ " [no]extern_learn " ] [ " -.BR [no]sticky " ]" +.BR [no]sticky " ] [ " [no]offloaded " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } " @@ -860,6 +860,11 @@ if "no" is prepended then only entries without extern_learn flag will be deleted .B [no]sticky if specified then only entries with sticky flag will be deleted or respectively if "no" is prepended then only entries without sticky flag will be deleted. + +.TP +.B [no]offloaded +if specified then only entries with offloaded flag will be deleted or respectively +if "no" is prepended then only entries without offloaded flag will be deleted. .sp .SH bridge mdb - multicast group database management