Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: roopa@nvidia.com, davem@davemloft.net,
bridge@lists.linux-foundation.org,
Nikolay Aleksandrov <nikolay@nvidia.com>
Subject: [PATCH net-next 02/16] net: bridge: mdb: move all port and bridge checks to br_mdb_add
Date: Mon, 21 Sep 2020 13:55:12 +0300 [thread overview]
Message-ID: <20200921105526.1056983-3-razor@blackwall.org> (raw)
In-Reply-To: <20200921105526.1056983-1-razor@blackwall.org>
From: Nikolay Aleksandrov <nikolay@nvidia.com>
To avoid doing duplicate device checks and searches (the same were done
in br_mdb_add and __br_mdb_add) pass the already found port to __br_mdb_add
and pull the bridge's netif_running and enabled multicast checks to
br_mdb_add. This would also simplify the future extack errors.
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
net/bridge/br_mdb.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index d4031f5554f7..92ab7369fee0 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -775,31 +775,18 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
}
static int __br_mdb_add(struct net *net, struct net_bridge *br,
+ struct net_bridge_port *p,
struct br_mdb_entry *entry)
{
struct br_ip ip;
- struct net_device *dev;
- struct net_bridge_port *p = NULL;
int ret;
- if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED))
- return -EINVAL;
-
- if (entry->ifindex != br->dev->ifindex) {
- dev = __dev_get_by_index(net, entry->ifindex);
- if (!dev)
- return -ENODEV;
-
- p = br_port_get_rtnl(dev);
- if (!p || p->br != br || p->state == BR_STATE_DISABLED)
- return -EINVAL;
- }
-
__mdb_entry_to_br_ip(entry, &ip);
spin_lock_bh(&br->multicast_lock);
ret = br_mdb_add_group(br, p, &ip, entry);
spin_unlock_bh(&br->multicast_lock);
+
return ret;
}
@@ -821,6 +808,9 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
br = netdev_priv(dev);
+ if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED))
+ return -EINVAL;
+
if (entry->ifindex != br->dev->ifindex) {
pdev = __dev_get_by_index(net, entry->ifindex);
if (!pdev)
@@ -840,12 +830,12 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) {
entry->vid = v->vid;
- err = __br_mdb_add(net, br, entry);
+ err = __br_mdb_add(net, br, p, entry);
if (err)
break;
}
} else {
- err = __br_mdb_add(net, br, entry);
+ err = __br_mdb_add(net, br, p, entry);
}
return err;
--
2.25.4
next prev parent reply other threads:[~2020-09-21 10:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 10:55 [PATCH net-next 00/16] net: bridge: mcast: IGMPv3/MLDv2 fast-path (part 2) Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 01/16] net: bridge: mdb: use extack in br_mdb_parse() Nikolay Aleksandrov
2020-09-21 10:55 ` Nikolay Aleksandrov [this message]
2020-09-21 10:55 ` [PATCH net-next 03/16] net: bridge: mdb: use extack in br_mdb_add() and br_mdb_add_group() Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 04/16] net: bridge: add src field to br_ip Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 05/16] net: bridge: mcast: use br_ip's src for src groups and querier address Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 06/16] net: bridge: mcast: rename br_ip's u member to dst Nikolay Aleksandrov
2020-09-21 13:30 ` kernel test robot
2020-09-21 13:33 ` Nikolay Aleksandrov
2020-09-21 20:49 ` kernel test robot
2020-09-21 10:55 ` [PATCH net-next 07/16] net: bridge: mdb: add support to extend add/del commands Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 08/16] net: bridge: mdb: add support for add/del/dump of entries with source Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 09/16] net: bridge: mcast: when igmpv3/mldv2 are enabled lookup (S,G) first, then (*,G) Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 10/16] net: bridge: mcast: add rt_protocol field to the port group struct Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 11/16] net: bridge: mcast: add sg_port rhashtable Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 12/16] net: bridge: mcast: install S,G entries automatically based on reports Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 13/16] net: bridge: mcast: handle port group filter modes Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 14/16] net: bridge: mcast: add support for blocked port groups Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 15/16] net: bridge: mcast: handle host state Nikolay Aleksandrov
2020-09-21 10:55 ` [PATCH net-next 16/16] net: bridge: mcast: when forwarding handle filter mode and blocked flag 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=20200921105526.1056983-3-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=roopa@nvidia.com \
--subject='Re: [PATCH net-next 02/16] net: bridge: mdb: move all port and bridge checks to br_mdb_add' \
/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
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).