Improve l2_macs_events API to provide MAC move information
[vpp.git] / src / vnet / l2 / l2_learn.c
index 066bb54..04e0721 100644 (file)
@@ -29,6 +29,8 @@
 #include <vppinfra/error.h>
 #include <vppinfra/hash.h>
 
+l2learn_main_t l2learn_main;
+
 /**
  * @file
  * @brief Ethernet Bridge Learning.
@@ -126,7 +128,7 @@ l2learn_process (vlib_node_runtime_t * node,
       /* Entry in L2FIB with matching sw_if_index matched - normal fast path */
       u32 dtime = timestamp - result0->fields.timestamp;
       u32 dsn = result0->fields.sn.as_u16 - vnet_buffer (b0)->l2.l2fib_sn;
-      u32 check = dtime | dsn;
+      u32 check = (dtime && vnet_buffer (b0)->l2.bd_age) || dsn;
 
       if (PREDICT_TRUE (check == 0))
        return;                 /* MAC entry up to date */
@@ -136,8 +138,9 @@ l2learn_process (vlib_node_runtime_t * node,
        return;                 /* Above learn limit - do not update */
 
       /* Limit updates per l2-learn node call to avoid prolonged update burst
-       * as dtime advance over 1 minute mark, unless more than 1 min behind */
-      if ((*count > 2) && (dtime == 1))
+       * as dtime advance over 1 minute mark, unless more than 1 min behind
+       * or SN obsolete */
+      if ((*count > 2) && (dtime == 1) && (dsn == 0))
        return;
 
       counter_base[L2LEARN_ERROR_HIT_UPDATE] += 1;
@@ -204,6 +207,7 @@ l2learn_process (vlib_node_runtime_t * node,
          result0->fields.age_not = 0;
        }
       result0->fields.lrn_evt = (msm->client_pid != 0);
+      result0->fields.lrn_mov = (msm->client_pid != 0);
       counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
     }