Commit a471be41 authored by Scott Feldman's avatar Scott Feldman Committed by David S. Miller

rocker: track when FDB entry is touched.

The entry is touched once when created, and touched again for each update.
The touched time is used to calculate FDB entry age.
Signed-off-by: default avatarScott Feldman <sfeldma@gmail.com>
Acked-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 34ea90ef
...@@ -152,6 +152,7 @@ struct rocker_fdb_tbl_entry { ...@@ -152,6 +152,7 @@ struct rocker_fdb_tbl_entry {
struct hlist_node entry; struct hlist_node entry;
u32 key_crc32; /* key */ u32 key_crc32; /* key */
bool learned; bool learned;
unsigned long touched;
struct rocker_fdb_tbl_key { struct rocker_fdb_tbl_key {
u32 pport; u32 pport;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
...@@ -3629,6 +3630,7 @@ static int rocker_port_fdb(struct rocker_port *rocker_port, ...@@ -3629,6 +3630,7 @@ static int rocker_port_fdb(struct rocker_port *rocker_port,
return -ENOMEM; return -ENOMEM;
fdb->learned = (flags & ROCKER_OP_FLAG_LEARNED); fdb->learned = (flags & ROCKER_OP_FLAG_LEARNED);
fdb->touched = jiffies;
fdb->key.pport = rocker_port->pport; fdb->key.pport = rocker_port->pport;
ether_addr_copy(fdb->key.addr, addr); ether_addr_copy(fdb->key.addr, addr);
fdb->key.vlan_id = vlan_id; fdb->key.vlan_id = vlan_id;
...@@ -3638,13 +3640,17 @@ static int rocker_port_fdb(struct rocker_port *rocker_port, ...@@ -3638,13 +3640,17 @@ static int rocker_port_fdb(struct rocker_port *rocker_port,
found = rocker_fdb_tbl_find(rocker, fdb); found = rocker_fdb_tbl_find(rocker, fdb);
if (removing && found) { if (found) {
rocker_port_kfree(trans, fdb); found->touched = jiffies;
if (trans != SWITCHDEV_TRANS_PREPARE) if (removing) {
hash_del(&found->entry); rocker_port_kfree(trans, fdb);
} else if (!removing && !found) { if (trans != SWITCHDEV_TRANS_PREPARE)
hash_del(&found->entry);
}
} else if (!removing) {
if (trans != SWITCHDEV_TRANS_PREPARE) if (trans != SWITCHDEV_TRANS_PREPARE)
hash_add(rocker->fdb_tbl, &fdb->entry, fdb->key_crc32); hash_add(rocker->fdb_tbl, &fdb->entry,
fdb->key_crc32);
} }
spin_unlock_irqrestore(&rocker->fdb_tbl_lock, lock_flags); spin_unlock_irqrestore(&rocker->fdb_tbl_lock, lock_flags);
......
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