提交 03e9b64b 编写于 作者: S stephen hemminger 提交者: David S. Miller

bridge: change arguments to fdb_create

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: NStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 0545a303
...@@ -320,8 +320,7 @@ static inline struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head, ...@@ -320,8 +320,7 @@ 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, static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
struct net_bridge_port *source, struct net_bridge_port *source,
const unsigned char *addr, const unsigned char *addr)
int is_local)
{ {
struct net_bridge_fdb_entry *fdb; struct net_bridge_fdb_entry *fdb;
...@@ -329,10 +328,9 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head, ...@@ -329,10 +328,9 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
if (fdb) { if (fdb) {
memcpy(fdb->addr.addr, addr, ETH_ALEN); memcpy(fdb->addr.addr, addr, ETH_ALEN);
fdb->dst = source; fdb->dst = source;
fdb->is_local = is_local; fdb->is_local = 0;
fdb->is_static = is_local; fdb->is_static = 0;
fdb->ageing_timer = jiffies; fdb->ageing_timer = jiffies;
hlist_add_head_rcu(&fdb->hlist, head); hlist_add_head_rcu(&fdb->hlist, head);
} }
return fdb; return fdb;
...@@ -360,12 +358,15 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source, ...@@ -360,12 +358,15 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
fdb_delete(fdb); fdb_delete(fdb);
} }
if (!fdb_create(head, source, addr, 1)) fdb = fdb_create(head, source, addr);
if (!fdb)
return -ENOMEM; return -ENOMEM;
fdb->is_local = fdb->is_static = 1;
return 0; return 0;
} }
/* Add entry for local address of interface */
int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source, int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
const unsigned char *addr) const unsigned char *addr)
{ {
...@@ -407,8 +408,9 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, ...@@ -407,8 +408,9 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
} }
} else { } else {
spin_lock(&br->hash_lock); spin_lock(&br->hash_lock);
if (!fdb_find(head, addr)) if (likely(!fdb_find(head, addr)))
fdb_create(head, source, addr, 0); fdb_create(head, source, addr);
/* else we lose race and someone else inserts /* else we lose race and someone else inserts
* it first, don't bother updating * it first, don't bother updating
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册