summaryrefslogtreecommitdiff
path: root/lib/mac-learning.c
diff options
context:
space:
mode:
authorEelco Chaudron <echaudro@redhat.com>2018-06-25 12:57:40 +0200
committerBen Pfaff <blp@ovn.org>2018-07-06 14:26:20 -0700
commitf34a5d4022c536484bcee4464c7e2c3e23a020c9 (patch)
tree1599bc11ea6ec5f13dd6a09cd048fb8db6a66d87 /lib/mac-learning.c
parent5f3818f1c601d006a53a2a2d71faecfc223163b4 (diff)
downloadopenvswitch-f34a5d4022c536484bcee4464c7e2c3e23a020c9.tar.gz
mac-learning: Add per mac learning instance counters
This patch adds counters per mac_learning instance. The following counters are added: total_learned: Total number of learned MAC entries total_expired: Total number of expired MAC entries total_evicted: Total number of evicted MAC entries, i.e. entries moved out due to the table being full. total_moved : Total number of port moved MAC entries, i.e. entries where the MAC address moved to a different port. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/mac-learning.c')
-rw-r--r--lib/mac-learning.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index 8b7981dbb..c13a5fac8 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -153,6 +153,7 @@ evict_mac_entry_fairly(struct mac_learning *ml)
e = CONTAINER_OF(ovs_list_front(&mlport->port_lrus),
struct mac_entry, port_lru_node);
COVERAGE_INC(mac_learning_evicted);
+ ml->total_evicted++;
mac_learning_expire(ml, e);
}
@@ -180,6 +181,18 @@ normalize_idle_time(unsigned int idle_time)
: idle_time);
}
+/* Clear all the mac_learning statistics */
+static void
+mac_learning_clear_statistics(struct mac_learning *ml)
+{
+ if (ml != NULL) {
+ ml->total_learned = 0;
+ ml->total_expired = 0;
+ ml->total_evicted = 0;
+ ml->total_moved = 0;
+ }
+}
+
/* Creates and returns a new MAC learning table with an initial MAC aging
* timeout of 'idle_time' seconds and an initial maximum of MAC_DEFAULT_MAX
* entries. */
@@ -200,6 +213,7 @@ mac_learning_create(unsigned int idle_time)
heap_init(&ml->ports_by_usage);
ovs_refcount_init(&ml->ref_cnt);
ovs_rwlock_init(&ml->rwlock);
+ mac_learning_clear_statistics(ml);
return ml;
}
@@ -323,6 +337,7 @@ mac_learning_insert(struct mac_learning *ml,
e->grat_arp_lock = TIME_MIN;
e->mlport = NULL;
COVERAGE_INC(mac_learning_learned);
+ ml->total_learned++;
} else {
ovs_list_remove(&e->lru_node);
}
@@ -426,6 +441,7 @@ update_learning_table__(struct mac_learning *ml, struct eth_addr src,
if (mac_entry_get_port(ml, mac) != in_port) {
if (mac_entry_get_port(ml, mac) != NULL) {
COVERAGE_INC(mac_learning_moved);
+ ml->total_moved++;
}
mac_entry_set_port(ml, mac, in_port);
return true;
@@ -524,6 +540,7 @@ mac_learning_run(struct mac_learning *ml)
&& (hmap_count(&ml->table) > ml->max_entries
|| time_now() >= e->expires)) {
COVERAGE_INC(mac_learning_expired);
+ ml->total_expired++;
mac_learning_expire(ml, e);
}