Netdev List
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	bridge@lists.linux-foundation.org (moderated list:ETHERNET
	BRIDGE)
Subject: [PATCH net-next 2/6] net: bridge: check multicast bridge only once
Date: Wed, 17 May 2017 17:27:05 -0400	[thread overview]
Message-ID: <20170517212709.6473-3-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <20170517212709.6473-1-vivien.didelot@savoirfairelinux.com>

__br_mdb_add and __br_mdb_del both check that the bridge is up and
running and that multicast is enabled on it before doing any operation.

Since they can be called multiple times by br_mdb_add and br_mdb_del,
move the check in their caller functions so that it is done just once.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/bridge/br_mdb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index bef0331f46a4..d20a01622b20 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -548,9 +548,6 @@ static int __br_mdb_add(struct net_bridge_port *p, struct br_mdb_entry *entry)
 	struct br_ip ip;
 	int ret;
 
-	if (!netif_running(br->dev) || br->multicast_disabled)
-		return -EINVAL;
-
 	__mdb_entry_to_br_ip(entry, &ip);
 
 	spin_lock_bh(&br->multicast_lock);
@@ -577,6 +574,9 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	br = netdev_priv(dev);
 
+	if (!netif_running(br->dev) || br->multicast_disabled)
+		return -EINVAL;
+
 	/* If vlan filtering is enabled and VLAN is not specified
 	 * install mdb entry on all vlans configured on the port.
 	 */
@@ -615,9 +615,6 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
 	struct br_ip ip;
 	int err = -EINVAL;
 
-	if (!netif_running(br->dev) || br->multicast_disabled)
-		return -EINVAL;
-
 	__mdb_entry_to_br_ip(entry, &ip);
 
 	spin_lock_bh(&br->multicast_lock);
@@ -672,6 +669,9 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	br = netdev_priv(dev);
 
+	if (!netif_running(br->dev) || br->multicast_disabled)
+		return -EINVAL;
+
 	/* If vlan filtering is enabled and VLAN is not specified
 	 * delete mdb entry on all vlans configured on the port.
 	 */
-- 
2.13.0

  parent reply	other threads:[~2017-05-17 21:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 21:27 [PATCH net-next 0/6] net: bridge: factorize MDB new and del functions Vivien Didelot
2017-05-17 21:27 ` [PATCH net-next 1/6] net: bridge: pass net_bridge_port to __br_mdb_add Vivien Didelot
2017-05-17 21:27 ` Vivien Didelot [this message]
2017-05-17 21:27 ` [PATCH net-next 3/6] net: bridge: break if __br_mdb_del fails Vivien Didelot
2017-05-18 13:45   ` Nikolay Aleksandrov
2017-05-18 15:08     ` Vivien Didelot
2017-05-18 15:25       ` Nikolay Aleksandrov
2017-05-18 15:45         ` Vivien Didelot
2017-05-17 21:27 ` [PATCH net-next 4/6] net: bridge: add __br_mdb_do Vivien Didelot
2017-05-17 21:27 ` [PATCH net-next 5/6] net: bridge: get msgtype from nlmsghdr in mdb ops Vivien Didelot
2017-05-18 15:28   ` Nikolay Aleksandrov
2017-05-18 15:53     ` [SPAM]Re: " Vivien Didelot
2017-05-18 17:01       ` Nikolay Aleksandrov
2017-05-17 21:27 ` [PATCH net-next 6/6] net: bridge: add br_mdb_do Vivien Didelot

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=20170517212709.6473-3-vivien.didelot@savoirfairelinux.com \
    --to=vivien.didelot@savoirfairelinux.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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