#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)
{
/* 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) {
#define MAC_MAX 1024
+/* Time, in seconds, before expiring a mac_entry due to inactivity. */
+#define MAC_ENTRY_IDLE_TIME 60
+
/* A MAC learning table entry. */
struct mac_entry {
struct list hash_node; /* Element in a mac_learning 'table' list. */
tag_type tag; /* Tag for this learning entry. */
};
+int mac_entry_age(const struct mac_entry *);
+
/* MAC learning table. */
struct mac_learning {
struct list free; /* Not-in-use entries. */