aboutsummaryrefslogtreecommitdiff
path: root/lib/mac-learning.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-07-15 11:02:24 -0700
committerBen Pfaff <blp@nicira.com>2009-07-16 09:17:06 -0700
commit321943f7904e1e28948e68cb1c78d89f169c07a2 (patch)
tree6b8a811edb9d936c63be278c92d0894012396cce /lib/mac-learning.c
parenteaa71334348aa0d99abf5588e17b3e55d0db28ce (diff)
mac-learning: New function mac_entry_age().
This function will be used as part of printing the MAC learning table at user request.
Diffstat (limited to 'lib/mac-learning.c')
-rw-r--r--lib/mac-learning.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index eeebce86..c9b7d3e7 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -32,6 +32,14 @@
#define THIS_MODULE VLM_mac_learning
#include "vlog.h"
+/* Returns the number of seconds since 'e' was last learned. */
+int
+mac_entry_age(const struct mac_entry *e)
+{
+ time_t remaining = e->expires - time_now();
+ return MAC_ENTRY_IDLE_TIME - remaining;
+}
+
static uint32_t
mac_table_hash(const uint8_t mac[ETH_ADDR_LEN], uint16_t vlan)
{
@@ -174,7 +182,7 @@ mac_learning_learn(struct mac_learning *ml,
/* Make the entry most-recently-used. */
list_remove(&e->lru_node);
list_push_back(&ml->lrus, &e->lru_node);
- e->expires = time_now() + 60;
+ e->expires = time_now() + MAC_ENTRY_IDLE_TIME;
/* Did we learn something? */
if (e->port != src_port) {