From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: bridge@lists.linux-foundation.org, Vlad Yasevich <vyasevic@redhat.com>
Subject: [PATCH net-next 4/4] bridge: sync device list when a new uplink is designated
Date: Tue, 12 Mar 2013 21:45:26 -0400 [thread overview]
Message-ID: <1363139126-13396-5-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1363139126-13396-1-git-send-email-vyasevic@redhat.com>
What a new device is designated as "uplink" sync any device
addresses to it. This allows for dynamic replacement of
uplinks while maintaining the device list.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
net/bridge/br_netlink.c | 11 +++++++++++
net/bridge/br_sysfs_if.c | 27 ++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index e08a50e..02f3425 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -326,6 +326,7 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[],
static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])
{
int err;
+ int old_flags = p->flags;
br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE);
br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD);
@@ -349,6 +350,16 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])
if (err)
return err;
}
+
+ if ((old_flags ^ p->flags) & BR_UPLINK) {
+ /* UPLINK flag changed on the device. Take care of device
+ * addresses.
+ */
+ if (p->flags & BR_UPLINK)
+ dev_uc_sync(p->dev, p->br->dev);
+ else
+ dev_uc_unsync(p->dev, p->br->dev);
+ }
return 0;
}
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 1f28cd4..d7a89c9 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -158,7 +158,32 @@ static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush);
BRPORT_ATTR_FLAG(hairpin_mode, BR_HAIRPIN_MODE);
BRPORT_ATTR_FLAG(bpdu_guard, BR_BPDU_GUARD);
BRPORT_ATTR_FLAG(root_block, BR_ROOT_BLOCK);
-BRPORT_ATTR_FLAG(uplink, BR_UPLINK);
+
+static ssize_t show_uplink(struct net_bridge_port *p, char *buf)
+{
+ return sprintf(buf, "%d\n", !!(p->flags & BR_UPLINK));
+}
+
+static int store_uplink(struct net_bridge_port *p, unsigned long v)
+{
+ unsigned long flags = p->flags;
+
+ if (v)
+ flags |= BR_UPLINK;
+ else
+ flags &= ~BR_UPLINK;
+
+ if (flags != p->flags) {
+ p->flags = flags;
+ if (p->flags & BR_UPLINK)
+ dev_uc_sync(p->dev, p->br->dev);
+ else
+ dev_uc_unsync(p->dev, p->br->dev);
+ br_ifinfo_notify(RTM_NEWLINK, p);
+ }
+ return 0;
+}
+static BRPORT_ATTR(uplink, S_IRUGO | S_IWUSR, show_uplink, store_uplink);
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
--
1.7.7.6
next prev parent reply other threads:[~2013-03-13 1:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-13 1:45 [PATCH net-next 0/4] Allow bridge to function in non-promisc mode Vlad Yasevich
2013-03-13 1:45 ` [PATCH net-next 1/4] bridge: Add sysfs interface to control promisc mode Vlad Yasevich
2013-03-13 15:38 ` Stephen Hemminger
2013-03-13 15:44 ` Vlad Yasevich
2013-03-13 1:45 ` [PATCH net-next 2/4] bridge: Allow an ability to designate an uplink port Vlad Yasevich
2013-03-13 20:33 ` Michael S. Tsirkin
2013-03-13 22:54 ` Stephen Hemminger
2013-03-13 23:43 ` Vlad Yasevich
2013-03-14 14:53 ` Dan Williams
2013-03-13 1:45 ` [PATCH net-next 3/4] bridge: Implement IFF_UNICAST_FLT Vlad Yasevich
2013-03-13 1:45 ` Vlad Yasevich [this message]
2013-03-13 6:22 ` [PATCH net-next 0/4] Allow bridge to function in non-promisc mode "Oleg A. Arkhangelsky"
2013-03-13 12:12 ` Vlad Yasevich
2013-03-13 15:39 ` Stephen Hemminger
2013-03-13 15:45 ` Vlad Yasevich
2013-03-13 16:09 ` Stephen Hemminger
2013-03-13 17:04 ` Vlad Yasevich
2013-03-13 18:56 ` [Bridge] " Joel Wirāmu Pauling
2013-03-13 20:08 ` Michael S. Tsirkin
2013-03-13 20:31 ` Michael S. Tsirkin
2013-03-14 15:10 ` Vlad Yasevich
2013-03-14 17:46 ` Michael S. Tsirkin
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=1363139126-13396-5-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=bridge@lists.linux-foundation.org \
--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).