netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: dsahern@gmail.com, stephen@networkplumber.org, roopa@nvidia.com,
	Nikolay Aleksandrov <razor@blackwall.org>
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	[thread overview]
Message-ID: <20220608122921.3962382-8-razor@blackwall.org> (raw)
In-Reply-To: <20220608122921.3962382-1-razor@blackwall.org>

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 <razor@blackwall.org>
---
 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
-- 
2.35.1


  parent reply	other threads:[~2022-06-08 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 12:29 [PATCH iproute2-next 00/10] bridge: fdb: add extended flush support Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 01/10] bridge: fdb: add new flush command Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 02/10] bridge: fdb: add flush vlan matching Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 03/10] bridge: fdb: add flush port matching Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 04/10] bridge: fdb: add flush [no]permanent entry matching Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 05/10] bridge: fdb: add flush [no]static " Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 06/10] bridge: fdb: add flush [no]dynamic " Nikolay Aleksandrov
2022-06-08 12:29 ` Nikolay Aleksandrov [this message]
2022-06-08 12:29 ` [PATCH iproute2-next 08/10] bridge: fdb: add flush [no]extern_learn " Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 09/10] bridge: fdb: add flush [no]sticky " Nikolay Aleksandrov
2022-06-08 12:29 ` [PATCH iproute2-next 10/10] bridge: fdb: add flush [no]offloaded " Nikolay Aleksandrov
2022-06-10 15:10 ` [PATCH iproute2-next 00/10] bridge: fdb: add extended flush support patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608122921.3962382-8-razor@blackwall.org \
    --to=razor@blackwall.org \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).