All of lore.kernel.org
 help / color / mirror / Atom feed
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 5/6] bridge: mdb: Add routing protocol support
Date: Thu, 15 Dec 2022 19:52:29 +0200	[thread overview]
Message-ID: <20221215175230.1907938-6-idosch@nvidia.com> (raw)
In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com>

Allow user space to specify the routing protocol of the MDB port group
entry by adding the 'MDBE_ATTR_RTPROT' attribute to the
'MDBA_SET_ENTRY_ATTRS' nest.

Examples:

 # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto zebra

 # bridge mdb add dev br0 port dummy10 grp 239.1.1.2 permanent

 # bridge -d mdb show
 dev br0 port dummy10 grp 239.1.1.2 permanent filter_mode exclude proto static
 dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude proto zebra

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 bridge/mdb.c      | 28 ++++++++++++++++++++++++++--
 man/man8/bridge.8 | 12 +++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/bridge/mdb.c b/bridge/mdb.c
index 58adf424bdcd..195a032c211b 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -32,7 +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 } ] [ source_list SOURCE_LIST ]\n"
+		"              [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ]\n"
 		"       bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
 	exit(-1);
 }
@@ -556,6 +556,20 @@ static int mdb_parse_src_list(struct nlmsghdr *n, int maxlen, char *src_list)
 	return 0;
 }
 
+static int mdb_parse_proto(struct nlmsghdr *n, int maxlen, const char *proto)
+{
+	__u32 proto_id;
+	int err;
+
+	err = rtnl_rtprot_a2n(&proto_id, proto);
+	if (err)
+		return err;
+
+	addattr8(n, maxlen, MDBE_ATTR_RTPROT, proto_id);
+
+	return 0;
+}
+
 static int mdb_modify(int cmd, int flags, int argc, char **argv)
 {
 	struct {
@@ -569,9 +583,9 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
 		.bpm.family = PF_BRIDGE,
 	};
 	char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL;
+	char *src_list = NULL, *proto = NULL;
 	struct br_mdb_entry entry = {};
 	bool set_attrs = false;
-	char *src_list = NULL;
 	short vid = 0;
 
 	while (argc > 0) {
@@ -604,6 +618,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
 			NEXT_ARG();
 			src_list = *argv;
 			set_attrs = true;
+		} else if (strcmp(*argv, "proto") == 0) {
+			NEXT_ARG();
+			proto = *argv;
+			set_attrs = true;
 		} else {
 			if (matches(*argv, "help") == 0)
 				usage();
@@ -651,6 +669,12 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
 						   src_list))
 			return -1;
 
+		if (proto && mdb_parse_proto(&req.n, sizeof(req), proto)) {
+			fprintf(stderr, "Invalid protocol value \"%s\"\n",
+				proto);
+			return -1;
+		}
+
 		addattr_nest_end(&req.n, nest);
 	}
 
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 801bf70c0e43..3e6e928c895f 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -141,7 +141,9 @@ bridge \- show / manipulate bridge addresses and devices
 .IR VID " ] [ "
 .BR filter_mode " { " include " | " exclude " } ] [ "
 .B source_list
-.IR SOURCE_LIST " ]
+.IR SOURCE_LIST " ] [ "
+.B proto
+.IR PROTO " ]
 
 .ti -8
 .BR "bridge mdb show" " [ "
@@ -946,6 +948,14 @@ separated by a ','.  Whether the entry forwards packets from these senders or
 not is determined by the entry's filter mode, which becomes a mandatory
 argument. Can only be set for (*, G) entries.
 
+.TP
+.BI proto " PROTO"
+the routing protocol identifier of this mdb entry. Can be a number or a string
+from the file /etc/iproute2/rt_protos. If the routing protocol is not given,
+then
+.B static
+is assumed.
+
 .in -8
 .SS bridge mdb delete - delete a multicast group database entry
 This command removes an existing mdb entry.
-- 
2.37.3


  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 ` Ido Schimmel [this message]
2022-12-16 12:06   ` [PATCH iproute2-next 5/6] bridge: mdb: Add routing protocol support 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-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.