Skip to content

Commit

Permalink
bridge: change arguments to fdb_create
Browse files Browse the repository at this point in the history
Later patch provides ability to create non-local static entry.
To make this easier move the updating of the flag values to
after the code that creates entry.

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 0545a30 commit 03e9b64
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions net/bridge/br_fdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,17 @@ static inline struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,

static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
struct net_bridge_port *source,
const unsigned char *addr,
int is_local)
const unsigned char *addr)
{
struct net_bridge_fdb_entry *fdb;

fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);
if (fdb) {
memcpy(fdb->addr.addr, addr, ETH_ALEN);
fdb->dst = source;
fdb->is_local = is_local;
fdb->is_static = is_local;
fdb->is_local = 0;
fdb->is_static = 0;
fdb->ageing_timer = jiffies;

hlist_add_head_rcu(&fdb->hlist, head);
}
return fdb;
Expand Down Expand Up @@ -360,12 +358,15 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
fdb_delete(fdb);
}

if (!fdb_create(head, source, addr, 1))
fdb = fdb_create(head, source, addr);
if (!fdb)
return -ENOMEM;

fdb->is_local = fdb->is_static = 1;
return 0;
}

/* Add entry for local address of interface */
int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
const unsigned char *addr)
{
Expand Down Expand Up @@ -407,8 +408,9 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
}
} else {
spin_lock(&br->hash_lock);
if (!fdb_find(head, addr))
fdb_create(head, source, addr, 0);
if (likely(!fdb_find(head, addr)))
fdb_create(head, source, addr);

/* else we lose race and someone else inserts
* it first, don't bother updating
*/
Expand Down

0 comments on commit 03e9b64

Please sign in to comment.