From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: dsahern@gmail.com, stephen@networkplumber.org,
razor@blackwall.org, mlxsw@nvidia.com,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH iproute2-next 6/6] bridge: mdb: Add replace support
Date: Thu, 15 Dec 2022 19:52:30 +0200 [thread overview]
Message-ID: <20221215175230.1907938-7-idosch@nvidia.com> (raw)
In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com>
Allow user space to replace MDB port group entries by specifying the
'NLM_F_REPLACE' flag in the netlink message header.
Examples:
# bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 permanent source_list 192.0.2.1,192.0.2.2 filter_mode include
# bridge -d -s mdb show
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.2 permanent filter_mode include proto static 0.00
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto static 0.00
dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode include source_list 192.0.2.2/0.00,192.0.2.1/0.00 proto static 0.00
# bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 permanent source_list 192.0.2.1,192.0.2.3 filter_mode exclude proto zebra
# bridge -d -s mdb show
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.3 permanent filter_mode include proto zebra blocked 0.00
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto zebra blocked 0.00
dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude source_list 192.0.2.3/0.00,192.0.2.1/0.00 proto zebra 0.00
# bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 temp source_list 192.0.2.4,192.0.2.3 filter_mode include proto bgp
# bridge -d -s mdb show
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.4 temp filter_mode include proto bgp 0.00
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.3 temp filter_mode include proto bgp 0.00
dev br0 port dummy10 grp 239.1.1.1 temp filter_mode include source_list 192.0.2.4/259.44,192.0.2.3/259.44 proto bgp 0.00
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
bridge/mdb.c | 4 +++-
man/man8/bridge.8 | 13 ++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 195a032c211b..f323cd091fcc 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -31,7 +31,7 @@ static unsigned int filter_index, filter_vlan;
static void usage(void)
{
fprintf(stderr,
- "Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n"
+ "Usage: bridge mdb { add | del | replace } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n"
" [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ]\n"
" bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
exit(-1);
@@ -692,6 +692,8 @@ int do_mdb(int argc, char **argv)
if (argc > 0) {
if (matches(*argv, "add") == 0)
return mdb_modify(RTM_NEWMDB, NLM_F_CREATE|NLM_F_EXCL, argc-1, argv+1);
+ if (strcmp(*argv, "replace") == 0)
+ return mdb_modify(RTM_NEWMDB, NLM_F_CREATE|NLM_F_REPLACE, argc-1, argv+1);
if (matches(*argv, "delete") == 0)
return mdb_modify(RTM_DELMDB, 0, argc-1, argv+1);
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 3e6e928c895f..f73e538a3536 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -127,7 +127,7 @@ bridge \- show / manipulate bridge addresses and devices
.BR [no]sticky " ] [ " [no]offloaded " ]"
.ti -8
-.BR "bridge mdb" " { " add " | " del " } "
+.BR "bridge mdb" " { " add " | " del " | " replace " } "
.B dev
.I DEV
.B port
@@ -898,8 +898,8 @@ if "no" is prepended then only entries without offloaded flag will be deleted.
objects contain known IP or L2 multicast group addresses on a link.
.P
-The corresponding commands display mdb entries, add new entries,
-and delete old ones.
+The corresponding commands display mdb entries, add new entries, replace
+entries and delete old ones.
.SS bridge mdb add - add a new multicast group database entry
@@ -964,6 +964,13 @@ This command removes an existing mdb entry.
The arguments are the same as with
.BR "bridge mdb add" .
+.SS bridge mdb replace - replace a multicast group database entry
+If no matching entry is found, a new one will be created instead.
+
+.PP
+The arguments are the same as with
+.BR "bridge mdb add" .
+
.SS bridge mdb show - list multicast group database entries
This command displays the current multicast group membership table. The table
--
2.37.3
next prev parent reply other threads:[~2022-12-15 17:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 17:52 [PATCH iproute2-next 0/6] bridge: mdb: Add support for new attributes Ido Schimmel
2022-12-15 17:52 ` [PATCH iproute2-next 1/6] bridge: mdb: Use a boolean to indicate nest is required Ido Schimmel
2022-12-16 11:59 ` Nikolay Aleksandrov
2022-12-15 17:52 ` [PATCH iproute2-next 2/6] bridge: mdb: Split source parsing to a separate function Ido Schimmel
2022-12-16 11:59 ` Nikolay Aleksandrov
2022-12-15 17:52 ` [PATCH iproute2-next 3/6] bridge: mdb: Add filter mode support Ido Schimmel
2022-12-16 12:00 ` Nikolay Aleksandrov
2022-12-15 17:52 ` [PATCH iproute2-next 4/6] bridge: mdb: Add source list support Ido Schimmel
2022-12-16 12:05 ` Nikolay Aleksandrov
2022-12-15 17:52 ` [PATCH iproute2-next 5/6] bridge: mdb: Add routing protocol support Ido Schimmel
2022-12-16 12:06 ` Nikolay Aleksandrov
2022-12-15 17:52 ` Ido Schimmel [this message]
2022-12-16 12:06 ` [PATCH iproute2-next 6/6] bridge: mdb: Add replace support Nikolay Aleksandrov
2022-12-19 1:50 ` [PATCH iproute2-next 0/6] bridge: mdb: Add support for new attributes 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=20221215175230.1907938-7-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=dsahern@gmail.com \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--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