netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, bridge@linux-foundation.org
Subject: [PATCH 4/4] bridge: add flush attribute
Date: Wed, 21 Feb 2007 14:41:11 -0800	[thread overview]
Message-ID: <20070221224255.897039436@linux-foundation.org> (raw)
In-Reply-To: 20070221224107.741532037@linux-foundation.org

[-- Attachment #1: bridge-fdb-flush.patch --]
[-- Type: text/plain, Size: 2903 bytes --]

Add a flush attribute to sysfs to allow flushing forwarding table.
This can be used by user level spanning tree protocol to clear state.

---
 net/bridge/br_fdb.c      |   11 ++++++++---
 net/bridge/br_sysfs_br.c |   14 ++++++++++++++
 net/bridge/br_sysfs_if.c |    8 ++++++++
 3 files changed, 30 insertions(+), 3 deletions(-)

--- bridge.orig/net/bridge/br_sysfs_br.c	2007-02-21 14:28:49.000000000 -0800
+++ bridge/net/bridge/br_sysfs_br.c	2007-02-21 14:39:50.000000000 -0800
@@ -310,6 +310,19 @@
 		   show_group_addr, store_group_addr);
 
 
+static ssize_t store_flush(struct device *d, struct device_attribute *attr,
+			   const char *buf, size_t len)
+{
+	struct net_bridge *br = to_bridge(d);
+
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	br_fdb_delete_by_port(br, NULL, 0);
+	return len;
+}
+static DEVICE_ATTR(flush, S_IWUSR, NULL, store_flush);
+
 static struct attribute *bridge_attrs[] = {
 	&dev_attr_forward_delay.attr,
 	&dev_attr_hello_time.attr,
@@ -328,6 +341,7 @@
 	&dev_attr_topology_change_timer.attr,
 	&dev_attr_gc_timer.attr,
 	&dev_attr_group_addr.attr,
+	&dev_attr_flush.attr,
 	NULL
 };
 
--- bridge.orig/net/bridge/br_sysfs_if.c	2007-02-21 14:29:25.000000000 -0800
+++ bridge/net/bridge/br_sysfs_if.c	2007-02-21 14:29:27.000000000 -0800
@@ -137,6 +137,13 @@
 }
 static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL);
 
+static ssize_t store_flush(struct net_bridge_port *p, unsigned long v)
+{
+	br_fdb_delete_by_port(p->br, p, 0); // Don't delete local entry
+	return 0;
+}
+static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush);
+
 static struct brport_attribute *brport_attrs[] = {
 	&brport_attr_path_cost,
 	&brport_attr_priority,
@@ -152,6 +159,7 @@
 	&brport_attr_message_age_timer,
 	&brport_attr_forward_delay_timer,
 	&brport_attr_hold_timer,
+	&brport_attr_flush,
 	NULL
 };
 
--- bridge.orig/net/bridge/br_fdb.c	2007-02-21 14:28:49.000000000 -0800
+++ bridge/net/bridge/br_fdb.c	2007-02-21 14:29:27.000000000 -0800
@@ -128,7 +128,11 @@
 	mod_timer(&br->gc_timer, jiffies + HZ/10);
 }
 
-
+/*
+ * Flush all forwarding entries for a port.
+ * if p is NULL, it means flush for all ports.
+ * if do_all is non-zero, then flush static entries as well
+ */
 void br_fdb_delete_by_port(struct net_bridge *br,
 			   const struct net_bridge_port *p,
 			   int do_all)
@@ -142,7 +146,8 @@
 		hlist_for_each_safe(h, g, &br->hash[i]) {
 			struct net_bridge_fdb_entry *f
 				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
-			if (f->dst != p)
+
+			if (p && f->dst != p)
 				continue;
 
 			if (f->is_static && !do_all)
@@ -152,7 +157,7 @@
 			 * then when one port is deleted, assign
 			 * the local entry to other port
 			 */
-			if (f->is_local) {
+			if (p && f->is_local) {
 				struct net_bridge_port *op;
 				list_for_each_entry(op, &br->port_list, list) {
 					if (op != p &&

--
Stephen Hemminger <shemminger@linux-foundation.org>


  parent reply	other threads:[~2007-02-21 22:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 22:41 [PATCH 0/4] bridge patches Stephen Hemminger
2007-02-21 22:41 ` [PATCH 1/4] bridge: get rid of miscdevice include Stephen Hemminger
2007-02-21 23:40   ` Marc.Obbad
2007-02-22  9:09   ` David Miller
2007-02-21 22:41 ` [PATCH 2/4] bridge: eliminate workqueue for carrier check Stephen Hemminger
2007-02-22  9:10   ` David Miller
2007-02-21 22:41 ` [PATCH 3/4] bridge: make path cost setting persistent Stephen Hemminger
2007-02-27 17:52   ` [PATCH 3+/4] bridge: fix locking of set path cost Stephen Hemminger
2007-02-27 17:56     ` David Miller
2007-02-21 22:41 ` Stephen Hemminger [this message]
2007-02-22  9:11 ` [PATCH 0/4] bridge patches 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=20070221224255.897039436@linux-foundation.org \
    --to=shemminger@linux-foundation.org \
    --cc=bridge@linux-foundation.org \
    --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).