From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org
Cc: mlxsw@nvidia.com, razor@blackwall.org,
Ido Schimmel <idosch@nvidia.com>,
edumazet@google.com, roopa@nvidia.com, kuba@kernel.org,
pabeni@redhat.com, davem@davemloft.net
Subject: [Bridge] [PATCH net-next 11/14] bridge: mcast: Allow user space to specify MDB entry routing protocol
Date: Thu, 8 Dec 2022 17:28:36 +0200 [thread overview]
Message-ID: <20221208152839.1016350-12-idosch@nvidia.com> (raw)
In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com>
Add the 'MDBE_ATTR_RTPORT' attribute to allow user space to specify the
routing protocol of the MDB port group entry. Enforce a minimum value of
'RTPROT_STATIC' to prevent user space from using protocol values that
should only be set by the kernel (e.g., 'RTPROT_KERNEL'). Maintain
backward compatibility by defaulting to 'RTPROT_STATIC'.
The protocol is already visible to user space in RTM_NEWMDB responses
and notifications via the 'MDBA_MDB_EATTR_RTPROT' attribute.
The routing protocol allows a routing daemon to distinguish between
entries configured by it and those configured by the administrator. Once
MDB flush is supported, the protocol can be used as a criterion
according to which the flush is performed.
Examples:
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto kernel
Error: integer out of range.
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto static
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent proto zebra
# bridge mdb add dev br0 port dummy10 grp 239.1.1.2 permanent source_list 198.51.100.1,198.51.100.2 filter_mode include proto 250
# bridge -d mdb show
dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.2 permanent filter_mode include proto 250
dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.1 permanent filter_mode include proto 250
dev br0 port dummy10 grp 239.1.1.2 permanent filter_mode include source_list 198.51.100.2/0.00,198.51.100.1/0.00 proto 250
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto zebra
dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude proto static
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
v1:
* Reject protocol for host entries.
include/uapi/linux/if_bridge.h | 1 +
net/bridge/br_mdb.c | 15 +++++++++++++--
net/bridge/br_private.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index 0d9fe73fc48c..d9de241d90f9 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -725,6 +725,7 @@ enum {
MDBE_ATTR_SOURCE,
MDBE_ATTR_SRC_LIST,
MDBE_ATTR_GROUP_MODE,
+ MDBE_ATTR_RTPROT,
__MDBE_ATTR_MAX,
};
#define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 61d46b0a31b6..72d4e53193e5 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -682,6 +682,7 @@ static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = {
[MDBE_ATTR_GROUP_MODE] = NLA_POLICY_RANGE(NLA_U8, MCAST_EXCLUDE,
MCAST_INCLUDE),
[MDBE_ATTR_SRC_LIST] = NLA_POLICY_NESTED(br_mdbe_src_list_pol),
+ [MDBE_ATTR_RTPROT] = NLA_POLICY_MIN(NLA_U8, RTPROT_STATIC),
};
static bool is_valid_mdb_entry(struct br_mdb_entry *entry,
@@ -823,7 +824,7 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg,
}
p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL,
- MCAST_INCLUDE, RTPROT_STATIC);
+ MCAST_INCLUDE, cfg->rt_protocol);
if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (S, G) port group");
return -ENOMEM;
@@ -881,6 +882,7 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg,
sg_cfg.group = sg_ip;
sg_cfg.src_entry = true;
sg_cfg.filter_mode = MCAST_INCLUDE;
+ sg_cfg.rt_protocol = cfg->rt_protocol;
return br_mdb_add_group_sg(&sg_cfg, sgmp, brmctx, flags, extack);
}
@@ -982,7 +984,7 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg,
}
p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL,
- cfg->filter_mode, RTPROT_STATIC);
+ cfg->filter_mode, cfg->rt_protocol);
if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (*, G) port group");
return -ENOMEM;
@@ -1193,6 +1195,14 @@ static int br_mdb_config_attrs_init(struct nlattr *set_attrs,
return -EINVAL;
}
+ if (mdb_attrs[MDBE_ATTR_RTPROT]) {
+ if (!cfg->p) {
+ NL_SET_ERR_MSG_MOD(extack, "Protocol cannot be set for host groups");
+ return -EINVAL;
+ }
+ cfg->rt_protocol = nla_get_u8(mdb_attrs[MDBE_ATTR_RTPROT]);
+ }
+
return 0;
}
@@ -1212,6 +1222,7 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh,
memset(cfg, 0, sizeof(*cfg));
cfg->filter_mode = MCAST_EXCLUDE;
+ cfg->rt_protocol = RTPROT_STATIC;
bpm = nlmsg_data(nlh);
if (!bpm->ifindex) {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 368f5f6fa42b..cdc9e040f1f6 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -106,6 +106,7 @@ struct br_mdb_config {
u8 filter_mode;
struct br_mdb_src_entry *src_entries;
int num_src_entries;
+ u8 rt_protocol;
};
#endif
--
2.37.3
WARNING: multiple messages have this Message-ID (diff)
From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, roopa@nvidia.com, razor@blackwall.org,
mlxsw@nvidia.com, Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 11/14] bridge: mcast: Allow user space to specify MDB entry routing protocol
Date: Thu, 8 Dec 2022 17:28:36 +0200 [thread overview]
Message-ID: <20221208152839.1016350-12-idosch@nvidia.com> (raw)
In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com>
Add the 'MDBE_ATTR_RTPORT' attribute to allow user space to specify the
routing protocol of the MDB port group entry. Enforce a minimum value of
'RTPROT_STATIC' to prevent user space from using protocol values that
should only be set by the kernel (e.g., 'RTPROT_KERNEL'). Maintain
backward compatibility by defaulting to 'RTPROT_STATIC'.
The protocol is already visible to user space in RTM_NEWMDB responses
and notifications via the 'MDBA_MDB_EATTR_RTPROT' attribute.
The routing protocol allows a routing daemon to distinguish between
entries configured by it and those configured by the administrator. Once
MDB flush is supported, the protocol can be used as a criterion
according to which the flush is performed.
Examples:
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto kernel
Error: integer out of range.
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto static
# bridge mdb add dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent proto zebra
# bridge mdb add dev br0 port dummy10 grp 239.1.1.2 permanent source_list 198.51.100.1,198.51.100.2 filter_mode include proto 250
# bridge -d mdb show
dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.2 permanent filter_mode include proto 250
dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.1 permanent filter_mode include proto 250
dev br0 port dummy10 grp 239.1.1.2 permanent filter_mode include source_list 198.51.100.2/0.00,198.51.100.1/0.00 proto 250
dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto zebra
dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude proto static
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
v1:
* Reject protocol for host entries.
include/uapi/linux/if_bridge.h | 1 +
net/bridge/br_mdb.c | 15 +++++++++++++--
net/bridge/br_private.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index 0d9fe73fc48c..d9de241d90f9 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -725,6 +725,7 @@ enum {
MDBE_ATTR_SOURCE,
MDBE_ATTR_SRC_LIST,
MDBE_ATTR_GROUP_MODE,
+ MDBE_ATTR_RTPROT,
__MDBE_ATTR_MAX,
};
#define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 61d46b0a31b6..72d4e53193e5 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -682,6 +682,7 @@ static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = {
[MDBE_ATTR_GROUP_MODE] = NLA_POLICY_RANGE(NLA_U8, MCAST_EXCLUDE,
MCAST_INCLUDE),
[MDBE_ATTR_SRC_LIST] = NLA_POLICY_NESTED(br_mdbe_src_list_pol),
+ [MDBE_ATTR_RTPROT] = NLA_POLICY_MIN(NLA_U8, RTPROT_STATIC),
};
static bool is_valid_mdb_entry(struct br_mdb_entry *entry,
@@ -823,7 +824,7 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg,
}
p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL,
- MCAST_INCLUDE, RTPROT_STATIC);
+ MCAST_INCLUDE, cfg->rt_protocol);
if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (S, G) port group");
return -ENOMEM;
@@ -881,6 +882,7 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg,
sg_cfg.group = sg_ip;
sg_cfg.src_entry = true;
sg_cfg.filter_mode = MCAST_INCLUDE;
+ sg_cfg.rt_protocol = cfg->rt_protocol;
return br_mdb_add_group_sg(&sg_cfg, sgmp, brmctx, flags, extack);
}
@@ -982,7 +984,7 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg,
}
p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL,
- cfg->filter_mode, RTPROT_STATIC);
+ cfg->filter_mode, cfg->rt_protocol);
if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (*, G) port group");
return -ENOMEM;
@@ -1193,6 +1195,14 @@ static int br_mdb_config_attrs_init(struct nlattr *set_attrs,
return -EINVAL;
}
+ if (mdb_attrs[MDBE_ATTR_RTPROT]) {
+ if (!cfg->p) {
+ NL_SET_ERR_MSG_MOD(extack, "Protocol cannot be set for host groups");
+ return -EINVAL;
+ }
+ cfg->rt_protocol = nla_get_u8(mdb_attrs[MDBE_ATTR_RTPROT]);
+ }
+
return 0;
}
@@ -1212,6 +1222,7 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh,
memset(cfg, 0, sizeof(*cfg));
cfg->filter_mode = MCAST_EXCLUDE;
+ cfg->rt_protocol = RTPROT_STATIC;
bpm = nlmsg_data(nlh);
if (!bpm->ifindex) {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 368f5f6fa42b..cdc9e040f1f6 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -106,6 +106,7 @@ struct br_mdb_config {
u8 filter_mode;
struct br_mdb_src_entry *src_entries;
int num_src_entries;
+ u8 rt_protocol;
};
#endif
--
2.37.3
next prev parent reply other threads:[~2022-12-08 15:28 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 15:28 [Bridge] [PATCH net-next 00/14] bridge: mcast: Extensions for EVPN Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-08 15:28 ` [Bridge] [PATCH net-next 01/14] bridge: mcast: Do not derive entry type from its filter mode Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:27 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:27 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 02/14] bridge: mcast: Split (*, G) and (S, G) addition into different functions Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:29 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:29 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 03/14] bridge: mcast: Place netlink policy before validation functions Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:30 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:30 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 04/14] bridge: mcast: Add a centralized error path Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:30 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:30 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 05/14] bridge: mcast: Expose br_multicast_new_group_src() Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:30 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:30 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 06/14] bridge: mcast: Expose __br_multicast_del_group_src() Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:31 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:31 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 07/14] bridge: mcast: Add a flag for user installed source entries Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:32 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:32 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 08/14] bridge: mcast: Avoid arming group timer when (S, G) corresponds to a source Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:32 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:32 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 09/14] bridge: mcast: Add support for (*, G) with a source list and filter mode Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:41 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:41 ` Nikolay Aleksandrov
2022-12-10 13:33 ` [Bridge] " Ido Schimmel
2022-12-10 13:33 ` Ido Schimmel
2022-12-08 15:28 ` [Bridge] [PATCH net-next 10/14] bridge: mcast: Allow user space to add " Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 7:52 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:52 ` Nikolay Aleksandrov
2022-12-08 15:28 ` Ido Schimmel [this message]
2022-12-08 15:28 ` [PATCH net-next 11/14] bridge: mcast: Allow user space to specify MDB entry routing protocol Ido Schimmel
2022-12-09 7:53 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 7:53 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 12/14] bridge: mcast: Support replacement of MDB port group entries Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 8:08 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 8:08 ` Nikolay Aleksandrov
2022-12-10 13:59 ` [Bridge] " Ido Schimmel
2022-12-10 13:59 ` Ido Schimmel
2022-12-08 15:28 ` [Bridge] [PATCH net-next 13/14] selftests: forwarding: Rename bridge_mdb test Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 8:09 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 8:09 ` Nikolay Aleksandrov
2022-12-08 15:28 ` [Bridge] [PATCH net-next 14/14] selftests: forwarding: Add bridge MDB test Ido Schimmel
2022-12-08 15:28 ` Ido Schimmel
2022-12-09 8:09 ` [Bridge] " Nikolay Aleksandrov
2022-12-09 8:09 ` Nikolay Aleksandrov
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=20221208152839.1016350-12-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=roopa@nvidia.com \
/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.