Skip to content

Commit

Permalink
bridge: split rcu and no-rcu cases of fdb lookup
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Apr 5, 2011
1 parent 7cd8861 commit 664de48
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions net/bridge/br_fdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,21 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,
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;
Expand Down Expand Up @@ -393,7 +406,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
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)) {
Expand Down

0 comments on commit 664de48

Please sign in to comment.