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 v2 3/9] bridge: mcast: Use MDB configuration structure where possible
Date: Tue, 6 Dec 2022 12:58:03 +0200 [thread overview]
Message-ID: <20221206105809.363767-4-idosch@nvidia.com> (raw)
In-Reply-To: <20221206105809.363767-1-idosch@nvidia.com>
The MDB configuration structure (i.e., struct br_mdb_config) now
includes all the necessary information from the parsed RTM_{NEW,DEL}MDB
netlink messages, so use it.
This will later allow us to delete the calls to br_mdb_parse() from
br_mdb_add() and br_mdb_del().
No functional changes intended.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_mdb.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index c8d78e4ec94e..080516a3ee9c 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -1094,7 +1094,6 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net_bridge_vlan *v;
struct br_mdb_config cfg;
struct net_device *dev;
- struct net_bridge *br;
int err;
err = br_mdb_config_init(net, nlh, &cfg, extack);
@@ -1105,30 +1104,30 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0)
return err;
- br = netdev_priv(dev);
-
- if (entry->ifindex != br->dev->ifindex) {
- if (cfg.p->state == BR_STATE_DISABLED && entry->state != MDB_PERMANENT) {
+ if (cfg.p) {
+ if (cfg.p->state == BR_STATE_DISABLED && cfg.entry->state != MDB_PERMANENT) {
NL_SET_ERR_MSG_MOD(extack, "Port is in disabled state and entry is not permanent");
return -EINVAL;
}
vg = nbp_vlan_group(cfg.p);
} else {
- vg = br_vlan_group(br);
+ vg = br_vlan_group(cfg.br);
}
/* If vlan filtering is enabled and VLAN is not specified
* install mdb entry on all vlans configured on the port.
*/
- if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
+ if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) {
- entry->vid = v->vid;
- err = __br_mdb_add(net, br, cfg.p, entry, mdb_attrs, extack);
+ cfg.entry->vid = v->vid;
+ err = __br_mdb_add(net, cfg.br, cfg.p, cfg.entry,
+ mdb_attrs, extack);
if (err)
break;
}
} else {
- err = __br_mdb_add(net, br, cfg.p, entry, mdb_attrs, extack);
+ err = __br_mdb_add(net, cfg.br, cfg.p, cfg.entry, mdb_attrs,
+ extack);
}
return err;
@@ -1186,7 +1185,6 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net_bridge_vlan *v;
struct br_mdb_config cfg;
struct net_device *dev;
- struct net_bridge *br;
int err;
err = br_mdb_config_init(net, nlh, &cfg, extack);
@@ -1197,23 +1195,21 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0)
return err;
- br = netdev_priv(dev);
-
- if (entry->ifindex != br->dev->ifindex)
+ if (cfg.p)
vg = nbp_vlan_group(cfg.p);
else
- vg = br_vlan_group(br);
+ vg = br_vlan_group(cfg.br);
/* If vlan filtering is enabled and VLAN is not specified
* delete mdb entry on all vlans configured on the port.
*/
- if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
+ if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) {
- entry->vid = v->vid;
- err = __br_mdb_del(br, entry, mdb_attrs);
+ cfg.entry->vid = v->vid;
+ err = __br_mdb_del(cfg.br, cfg.entry, mdb_attrs);
}
} else {
- err = __br_mdb_del(br, entry, mdb_attrs);
+ err = __br_mdb_del(cfg.br, cfg.entry, mdb_attrs);
}
return err;
--
2.37.3
next prev parent reply other threads:[~2022-12-06 10:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 10:58 [PATCH net-next v2 0/9] bridge: mcast: Preparations for EVPN extensions Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 1/9] bridge: mcast: Centralize netlink attribute parsing Ido Schimmel
2022-12-06 12:32 ` Nikolay Aleksandrov
2022-12-06 10:58 ` [PATCH net-next v2 2/9] bridge: mcast: Remove redundant checks Ido Schimmel
2022-12-06 10:58 ` Ido Schimmel [this message]
2022-12-06 10:58 ` [PATCH net-next v2 4/9] bridge: mcast: Propagate MDB configuration structure further Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 5/9] bridge: mcast: Use MDB group key from configuration structure Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 6/9] bridge: mcast: Remove br_mdb_parse() Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 7/9] bridge: mcast: Move checks out of critical section Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 8/9] bridge: mcast: Remove redundant function arguments Ido Schimmel
2022-12-06 10:58 ` [PATCH net-next v2 9/9] bridge: mcast: Constify 'group' argument in br_multicast_new_port_group() Ido Schimmel
2022-12-06 12:32 ` Nikolay Aleksandrov
2022-12-08 4:10 ` [PATCH net-next v2 0/9] bridge: mcast: Preparations for EVPN extensions 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=20221206105809.363767-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).