netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: bridge@lists.linux-foundation.org, mst@redhat.com,
	Vlad Yasevich <vyasevic@redhat.com>
Subject: [PATCH v2 net-next 6/6] bridge: Store bridge mac to uplinks
Date: Fri, 19 Apr 2013 16:52:50 -0400	[thread overview]
Message-ID: <1366404770-28523-7-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1366404770-28523-1-git-send-email-vyasevic@redhat.com>

Bridge mac address can change for many reasons.  Since now some ports
may be non-promisc, we need to keep track of the bridge mac and program
it onto ports that may need that information.  We do that by writing
to any port that turns non-promisc and delete it from any port that
turns back to promisc.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 net/bridge/br_device.c  |   21 ++++++++++++++++++++-
 net/bridge/br_private.h |    2 ++
 net/bridge/br_stp_if.c  |    2 +-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 470fb1b..2521fb8 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -141,9 +141,23 @@ static void br_dev_set_rx_mode(struct net_device *dev)
 			if (promisc) {
 				port->flags |= BR_PROMISC;
 				dev_set_promiscuity(dev, 1);
+
+				/* Remove the bridge mac from port since it
+				 * is now promisc.
+				 */
+				if (memcmp(dev->dev_addr, port->dev->dev_addr,
+					   dev->addr_len))
+					dev_uc_del(port->dev, dev->dev_addr);
 			} else {
 				port->flags &= ~BR_PROMISC;
 				dev_set_promiscuity(dev, -1);
+
+				/* Add bridge mac address to the port since
+				 * it is non-promisc.
+				 */
+				if (memcmp(dev->dev_addr, port->dev->dev_addr,
+					   dev->addr_len))
+					dev_uc_add(port->dev, dev->dev_addr);
 			}
 		}
 	}
@@ -207,6 +221,12 @@ static int br_change_mtu(struct net_device *dev, int new_mtu)
 	return 0;
 }
 
+void br_change_mac_address(struct net_device *dev, const unsigned char *addr)
+{
+	memcpy(dev->dev_addr, addr, ETH_ALEN);
+	dev_set_rx_mode(dev);
+}
+
 /* Allow setting mac address to any valid ethernet address. */
 static int br_set_mac_address(struct net_device *dev, void *p)
 {
@@ -218,7 +238,6 @@ static int br_set_mac_address(struct net_device *dev, void *p)
 
 	spin_lock_bh(&br->lock);
 	if (!ether_addr_equal(dev->dev_addr, addr->sa_data)) {
-		memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
 		br_fdb_change_mac_address(br, addr->sa_data);
 		br_stp_change_bridge_id(br, addr->sa_data);
 	}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 40ac501..ace976f 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -334,6 +334,8 @@ extern void br_dev_setup(struct net_device *dev);
 extern void br_dev_delete(struct net_device *dev, struct list_head *list);
 extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
 			       struct net_device *dev);
+extern void br_change_mac_address(struct net_device *dev,
+				  const unsigned char *addr);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
 {
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 0bdb4eb..5a5b894 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -186,9 +186,9 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
 
 	wasroot = br_is_root_bridge(br);
 
+	br_change_mac_address(br->dev, addr);
 	memcpy(oldaddr, br->bridge_id.addr, ETH_ALEN);
 	memcpy(br->bridge_id.addr, addr, ETH_ALEN);
-	memcpy(br->dev->dev_addr, addr, ETH_ALEN);
 
 	list_for_each_entry(p, &br->port_list, list) {
 		if (ether_addr_equal(p->designated_bridge.addr, oldaddr))
-- 
1.7.7.6

  parent reply	other threads:[~2013-04-19 20:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19 20:52 [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 1/6] bridge: Allow an ability to designate an uplink port Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 2/6] bridge: make flags sysfs interface a little bit more extensible Vlad Yasevich
2013-04-19 20:54   ` Stephen Hemminger
2013-04-19 21:35     ` Vlad Yasevich
2013-04-19 20:55   ` Stephen Hemminger
2013-04-19 21:33     ` Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 3/6] bridge: Implement IFF_UNICAST_FLT Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 4/6] bridge: Allow user to program hw addresses to uplink devices Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 5/6] bridge: Automatically set promisc on uplink ports Vlad Yasevich
2013-04-19 20:52 ` Vlad Yasevich [this message]
2013-04-19 20:58 ` [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Stephen Hemminger
2013-04-19 21:48   ` Vlad Yasevich
2013-04-25 15:56 ` Stephen Hemminger
2013-04-25 16:45   ` Michael S. Tsirkin
2013-04-25 17:35     ` Stephen Hemminger
2013-04-25 21:13       ` Michael S. Tsirkin
2013-05-02 17:23 ` Stephen Hemminger
2013-05-02 17:41   ` Vlad Yasevich
2013-05-02 18:14     ` Stephen Hemminger
2013-05-02 18:37   ` Michael S. Tsirkin
2013-05-02 21:16     ` Stephen Hemminger

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=1366404770-28523-7-git-send-email-vyasevic@redhat.com \
    --to=vyasevic@redhat.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).