Patchwork [3/7] bridge: split rcu and no-rcu cases of fdb lookup

login
register
mail settings
Submitter stephen hemminger
Date April 5, 2011, 12:03 a.m.
Message ID <20110405000537.187138133@vyatta.com>
Download mbox | patch
Permalink /patch/89738/
State Accepted
Delegated to: David Miller
Headers show

Comments

stephen hemminger - April 5, 2011, 12:03 a.m.
In some cases, look up of forward database entry is done with RCU;
and for others no RCU is needed because of locking. Split the two
cases into two differnt loops (and take off inline).

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



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/net/bridge/br_fdb.c	2011-03-21 10:36:51.109460181 -0700
+++ b/net/bridge/br_fdb.c	2011-03-21 10:37:11.872443564 -0700
@@ -305,8 +305,21 @@  int br_fdb_fillbuf(struct net_bridge *br
 	return num;
 }
 
-static inline struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
-						    const unsigned char *addr)
+static struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
+					     const unsigned char *addr)
+{
+	struct hlist_node *h;
+	struct net_bridge_fdb_entry *fdb;
+
+	hlist_for_each_entry(fdb, h, head, hlist) {
+		if (!compare_ether_addr(fdb->addr.addr, addr))
+			return fdb;
+	}
+	return NULL;
+}
+
+static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head,
+						 const unsigned char *addr)
 {
 	struct hlist_node *h;
 	struct net_bridge_fdb_entry *fdb;
@@ -393,7 +406,7 @@  void br_fdb_update(struct net_bridge *br
 	      source->state == BR_STATE_FORWARDING))
 		return;
 
-	fdb = fdb_find(head, addr);
+	fdb = fdb_find_rcu(head, addr);
 	if (likely(fdb)) {
 		/* attempt to update an entry for a local interface */
 		if (unlikely(fdb->is_local)) {