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 3/6] bridge: mdb: Add filter mode support
Date: Thu, 15 Dec 2022 19:52:27 +0200 [thread overview]
Message-ID: <20221215175230.1907938-4-idosch@nvidia.com> (raw)
In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com>
Allow user space to specify the filter mode of (*, G) entries by adding
the 'MDBE_ATTR_GROUP_MODE' attribute to the 'MDBA_SET_ENTRY_ATTRS' nest.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
bridge/mdb.c | 27 ++++++++++++++++++++++++++-
man/man8/bridge.8 | 8 +++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 64db2ee03c42..ceb8b25b37a5 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -32,6 +32,7 @@ static void usage(void)
{
fprintf(stderr,
"Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n"
+ " [ filter_mode { include | exclude } ]\n"
" bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
exit(-1);
}
@@ -493,6 +494,21 @@ static int mdb_parse_src(struct nlmsghdr *n, int maxlen, const char *src)
return -1;
}
+static int mdb_parse_mode(struct nlmsghdr *n, int maxlen, const char *mode)
+{
+ if (strcmp(mode, "include") == 0) {
+ addattr8(n, maxlen, MDBE_ATTR_GROUP_MODE, MCAST_INCLUDE);
+ return 0;
+ }
+
+ if (strcmp(mode, "exclude") == 0) {
+ addattr8(n, maxlen, MDBE_ATTR_GROUP_MODE, MCAST_EXCLUDE);
+ return 0;
+ }
+
+ return -1;
+}
+
static int mdb_modify(int cmd, int flags, int argc, char **argv)
{
struct {
@@ -505,7 +521,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
.n.nlmsg_type = cmd,
.bpm.family = PF_BRIDGE,
};
- char *d = NULL, *p = NULL, *grp = NULL, *src = NULL;
+ char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL;
struct br_mdb_entry entry = {};
bool set_attrs = false;
short vid = 0;
@@ -532,6 +548,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
NEXT_ARG();
src = *argv;
set_attrs = true;
+ } else if (strcmp(*argv, "filter_mode") == 0) {
+ NEXT_ARG();
+ mode = *argv;
+ set_attrs = true;
} else {
if (matches(*argv, "help") == 0)
usage();
@@ -570,6 +590,11 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
return -1;
}
+ if (mode && mdb_parse_mode(&req.n, sizeof(req), mode)) {
+ fprintf(stderr, "Invalid filter mode \"%s\"\n", mode);
+ return -1;
+ }
+
addattr_nest_end(&req.n, nest);
}
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index e72826d750ca..e829b9cb592a 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -138,7 +138,8 @@ bridge \- show / manipulate bridge addresses and devices
.IR SOURCE " ] [ "
.BR permanent " | " temp " ] [ "
.B vid
-.IR VID " ] "
+.IR VID " ] [ "
+.BR filter_mode " { " include " | " exclude " } ] "
.ti -8
.BR "bridge mdb show" " [ "
@@ -931,6 +932,11 @@ forwarding multicast traffic.
.BI vid " VID"
the VLAN ID which is known to have members of this multicast group.
+.TP
+.BR "filter_mode include " or " filter_mode exclude "
+controls whether the sources in the entry's source list are in INCLUDE or
+EXCLUDE mode. Can only be set for (*, G) entries.
+
.in -8
.SS bridge mdb delete - delete a multicast group database entry
This command removes an existing mdb entry.
--
2.37.3
next prev parent reply other threads:[~2022-12-15 17:54 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 ` Ido Schimmel [this message]
2022-12-16 12:00 ` [PATCH iproute2-next 3/6] bridge: mdb: Add filter mode support 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 ` [PATCH iproute2-next 6/6] bridge: mdb: Add replace support Ido Schimmel
2022-12-16 12:06 ` 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-4-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