Commit 7cd8861a authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

bridge: track last used time in forwarding table

Adds tracking the last used time in forwarding table.
Rename ageing_timer to updated to better describe it.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 03e9b64b
...@@ -62,7 +62,7 @@ static inline int has_expired(const struct net_bridge *br, ...@@ -62,7 +62,7 @@ static inline int has_expired(const struct net_bridge *br,
const struct net_bridge_fdb_entry *fdb) const struct net_bridge_fdb_entry *fdb)
{ {
return !fdb->is_static && return !fdb->is_static &&
time_before_eq(fdb->ageing_timer + hold_time(br), jiffies); time_before_eq(fdb->updated + hold_time(br), jiffies);
} }
static inline int br_mac_hash(const unsigned char *mac) static inline int br_mac_hash(const unsigned char *mac)
...@@ -140,7 +140,7 @@ void br_fdb_cleanup(unsigned long _data) ...@@ -140,7 +140,7 @@ void br_fdb_cleanup(unsigned long _data)
unsigned long this_timer; unsigned long this_timer;
if (f->is_static) if (f->is_static)
continue; continue;
this_timer = f->ageing_timer + delay; this_timer = f->updated + delay;
if (time_before_eq(this_timer, jiffies)) if (time_before_eq(this_timer, jiffies))
fdb_delete(f); fdb_delete(f);
else if (time_before(this_timer, next_timer)) else if (time_before(this_timer, next_timer))
...@@ -293,7 +293,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, ...@@ -293,7 +293,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,
fe->is_local = f->is_local; fe->is_local = f->is_local;
if (!f->is_static) if (!f->is_static)
fe->ageing_timer_value = jiffies_to_clock_t(jiffies - f->ageing_timer); fe->ageing_timer_value = jiffies_to_clock_t(jiffies - f->updated);
++fe; ++fe;
++num; ++num;
} }
...@@ -330,7 +330,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head, ...@@ -330,7 +330,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
fdb->dst = source; fdb->dst = source;
fdb->is_local = 0; fdb->is_local = 0;
fdb->is_static = 0; fdb->is_static = 0;
fdb->ageing_timer = jiffies; fdb->updated = fdb->used = jiffies;
hlist_add_head_rcu(&fdb->hlist, head); hlist_add_head_rcu(&fdb->hlist, head);
} }
return fdb; return fdb;
...@@ -404,7 +404,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, ...@@ -404,7 +404,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
} else { } else {
/* fastpath: update of existing entry */ /* fastpath: update of existing entry */
fdb->dst = source; fdb->dst = source;
fdb->ageing_timer = jiffies; fdb->updated = jiffies;
} }
} else { } else {
spin_lock(&br->hash_lock); spin_lock(&br->hash_lock);
......
...@@ -98,9 +98,10 @@ int br_handle_frame_finish(struct sk_buff *skb) ...@@ -98,9 +98,10 @@ int br_handle_frame_finish(struct sk_buff *skb)
} }
if (skb) { if (skb) {
if (dst) if (dst) {
dst->used = jiffies;
br_forward(dst->dst, skb, skb2); br_forward(dst->dst, skb, skb2);
else } else
br_flood_forward(br, skb, skb2); br_flood_forward(br, skb, skb2);
} }
......
...@@ -64,7 +64,8 @@ struct net_bridge_fdb_entry ...@@ -64,7 +64,8 @@ struct net_bridge_fdb_entry
struct net_bridge_port *dst; struct net_bridge_port *dst;
struct rcu_head rcu; struct rcu_head rcu;
unsigned long ageing_timer; unsigned long updated;
unsigned long used;
mac_addr addr; mac_addr addr;
unsigned char is_local; unsigned char is_local;
unsigned char is_static; unsigned char is_static;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment