#include <vppinfra/error.h>
#include <vppinfra/hash.h>
+l2learn_main_t l2learn_main;
+
/**
* @file
* @brief Ethernet Bridge Learning.
/* 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 */
- if (result0->fields.age_not)
+ if (l2fib_entry_result_is_set_AGE_NOT (result0))
return; /* Static MAC always age_not */
if (msm->global_learn_count > msm->global_learn_limit)
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;
msm->global_learn_count++;
result0->raw = 0; /* clear all fields */
result0->fields.sw_if_index = sw_if_index0;
- result0->fields.lrn_evt = (msm->client_pid != 0);
+ if (msm->client_pid != 0)
+ l2fib_entry_result_set_LRN_EVT (result0);
+ else
+ l2fib_entry_result_clear_LRN_EVT (result0);
}
else
{
/* Entry in L2FIB with different sw_if_index - mac move or filter */
- if (result0->fields.filter)
+ if (l2fib_entry_result_is_set_FILTER (result0))
{
ASSERT (result0->fields.sw_if_index == ~0);
/* drop packet because lookup matched a filter mac entry */
return;
}
- if (result0->fields.static_mac)
+ if (l2fib_entry_result_is_set_STATIC (result0))
{
/*
* Don't overwrite a static mac
* TODO: check global/bridge domain/interface learn limits
*/
result0->fields.sw_if_index = sw_if_index0;
- if (result0->fields.age_not) /* The mac was provisioned */
+ if (l2fib_entry_result_is_set_AGE_NOT (result0))
{
+ /* The mac was provisioned */
msm->global_learn_count++;
- result0->fields.age_not = 0;
+ l2fib_entry_result_clear_AGE_NOT (result0);
}
- result0->fields.lrn_evt = (msm->client_pid != 0);
+ if (msm->client_pid != 0)
+ l2fib_entry_result_set_bits (result0,
+ (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT |
+ L2FIB_ENTRY_RESULT_FLAG_LRN_MOV));
+ else
+ l2fib_entry_result_clear_bits (result0,
+ (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT |
+ L2FIB_ENTRY_RESULT_FLAG_LRN_MOV));
counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
}