Message ID | 20221215175230.1907938-7-idosch@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 9edecafda31e703ccc2adad6a0c90a76c60aedc7 |
Delegated to: | David Ahern |
Headers | show |
Series | bridge: mdb: Add support for new attributes | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 15/12/2022 19:52, Ido Schimmel wrote: > 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(-) > Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
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
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(-)