netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/3] bridge: make bridge address settings sticky
Date: Tue, 17 Jun 2008 09:52:13 -0700	[thread overview]
Message-ID: <20080617165223.184830407@vyatta.com> (raw)
In-Reply-To: 20080617165211.615620784@vyatta.com

[-- Attachment #1: br-sticky-mac.patch --]
[-- Type: text/plain, Size: 1517 bytes --]

Normally, the bridge just chooses the smallest mac address as the
bridge id and mac address of bridge device. But if the administrator
has explictly set the interface address then don't change it.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/net/bridge/br_device.c	2008-06-17 09:18:02.000000000 -0700
+++ b/net/bridge/br_device.c	2008-06-17 09:18:16.000000000 -0700
@@ -95,6 +95,7 @@ static int br_set_mac_address(struct net
 	spin_lock_bh(&br->lock);
 	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
 	br_stp_change_bridge_id(br, addr->sa_data);
+	br->flags |= BR_SET_MAC_ADDR;
 	spin_unlock_bh(&br->lock);
 
 	return 0;
--- a/net/bridge/br_private.h	2008-06-17 09:14:42.000000000 -0700
+++ b/net/bridge/br_private.h	2008-06-17 09:21:10.000000000 -0700
@@ -95,6 +95,8 @@ struct net_bridge
 	struct hlist_head		hash[BR_HASH_SIZE];
 	struct list_head		age_list;
 	unsigned long			feature_mask;
+	unsigned long			flags;
+#define BR_SET_MAC_ADDR		0x00000001
 
 	/* STP */
 	bridge_id			designated_root;
--- a/net/bridge/br_stp_if.c	2008-06-17 09:20:06.000000000 -0700
+++ b/net/bridge/br_stp_if.c	2008-06-17 09:21:00.000000000 -0700
@@ -216,6 +216,10 @@ void br_stp_recalculate_bridge_id(struct
 	const unsigned char *addr = br_mac_zero;
 	struct net_bridge_port *p;
 
+	/* user has chosen a value so keep it */
+	if (br->flags & BR_SET_MAC_ADDR)
+		return;
+
 	list_for_each_entry(p, &br->port_list, list) {
 		if (addr == br_mac_zero ||
 		    memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)

-- 


  parent reply	other threads:[~2008-06-17 16:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-17 16:52 [PATCH 0/3] Bridge patches for 2.6.27 Stephen Hemminger
2008-06-17 16:52 ` [PATCH 1/3] bridge: handle process all link-local frames Stephen Hemminger
2008-06-17 23:11   ` David Miller
2008-06-17 16:52 ` Stephen Hemminger [this message]
2008-06-17 23:11   ` [PATCH 2/3] bridge: make bridge address settings sticky David Miller
2008-06-17 16:52 ` [PATCH 3/3] bridge: use statistics in net_device Stephen Hemminger
2008-06-17 23:14   ` David Miller
2008-06-17 23:35     ` Stephen Hemminger
2008-06-17 23:50       ` David Miller

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=20080617165223.184830407@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --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).