#define SR_BEHAVIOR_DX4 7
#define SR_BEHAVIOR_DT6 8
#define SR_BEHAVIOR_DT4 9
-#define SR_BEHAVIOR_END_UN_PERF 10
-#define SR_BEHAVIOR_END_UN 11
-#define SR_BEHAVIOR_UA 12
-#define SR_BEHAVIOR_LAST 13 /* Must always be the last one */
+/**
+ * SR_BEHAVIOR_LAST
+ * Not used anymore. Kept not to break the API.
+ * We use SR_BEHAVIOR_CURRENT_LAST going forward
+ * */
+#define SR_BEHAVIOR_LAST 10
+#define SR_BEHAVIOR_END_UN_PERF 11
+#define SR_BEHAVIOR_END_UN 12
+#define SR_BEHAVIOR_UA 13
+
+/**
+ * SR_BEHAVIOR_CURRENT_LAST
+ * MUST be updated everytime we add new behaviors.
+ * MUST be set to value of last added behavior + 1.
+ * */
+#define SR_BEHAVIOR_CURRENT_LAST 14
#define SR_STEER_L2 2
#define SR_STEER_IPV4 4
*/
typedef struct
{
- u16 sr_localsid_function_number; /**< SR LocalSID plugin function (>SR_BEHAVIOR_LAST) */
+ u16 sr_localsid_function_number; /**< SR LocalSID plugin function
+ (>SR_BEHAVIOR_CURRENT_LAST) */
u8 *function_name; /**< Function name. (key). */
{
/* Retrieve localsid */
ls = pool_elt_at_index (sm->localsids, p[0]);
- if (ls->behavior >= SR_BEHAVIOR_LAST)
+ if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST)
{
- plugin = pool_elt_at_index (sm->plugin_functions,
- ls->behavior - SR_BEHAVIOR_LAST);
+ plugin = pool_elt_at_index (
+ sm->plugin_functions, ls->behavior - SR_BEHAVIOR_CURRENT_LAST);
pref_length = plugin->prefix_length;
}
|| ls->behavior == SR_BEHAVIOR_DX4)
adj_unlock (ls->nh_adj);
- if (ls->behavior >= SR_BEHAVIOR_LAST)
+ if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST)
{
/* Callback plugin removal function */
rv = plugin->removal (ls);
if (is_del)
return -2;
- if (behavior >= SR_BEHAVIOR_LAST)
- {
- sr_localsid_fn_registration_t *plugin = 0;
- plugin =
- pool_elt_at_index (sm->plugin_functions, behavior - SR_BEHAVIOR_LAST);
- pref_length = plugin->prefix_length;
- }
+ if (behavior >= SR_BEHAVIOR_CURRENT_LAST)
+ {
+ sr_localsid_fn_registration_t *plugin = 0;
+ plugin = pool_elt_at_index (sm->plugin_functions,
+ behavior - SR_BEHAVIOR_CURRENT_LAST);
+ pref_length = plugin->prefix_length;
+ }
if (localsid_prefix_len != 0)
{
ls->behavior == SR_BEHAVIOR_UA)
dpo_set (&dpo, sr_localsid_un_perf_dpo_type, DPO_PROTO_IP6,
ls - sm->localsids);
- else if (ls->behavior > SR_BEHAVIOR_D_FIRST
- && ls->behavior < SR_BEHAVIOR_LAST)
+ else if (ls->behavior > SR_BEHAVIOR_D_FIRST &&
+ ls->behavior < SR_BEHAVIOR_CURRENT_LAST)
dpo_set (&dpo, sr_localsid_d_dpo_type, DPO_PROTO_IP6, ls - sm->localsids);
- else if (ls->behavior >= SR_BEHAVIOR_LAST)
+ else if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST)
{
sr_localsid_fn_registration_t *plugin = 0;
plugin = pool_elt_at_index (sm->plugin_functions,
- ls->behavior - SR_BEHAVIOR_LAST);
+ ls->behavior - SR_BEHAVIOR_CURRENT_LAST);
/* Copy the unformat memory result */
ls->plugin_mem = ls_plugin_mem;
/* Callback plugin creation function */
FIB_PROTOCOL_IP4));
break;
default:
- if (ls->behavior >= SR_BEHAVIOR_LAST)
+ if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST)
{
- sr_localsid_fn_registration_t *plugin =
- pool_elt_at_index (sm->plugin_functions,
- ls->behavior - SR_BEHAVIOR_LAST);
+ sr_localsid_fn_registration_t *plugin = pool_elt_at_index (
+ sm->plugin_functions, ls->behavior - SR_BEHAVIOR_CURRENT_LAST);
vlib_cli_output (vm, "\tAddress: \t%U/%u\n"
"\tBehavior: \t%s (%s)\n\t%U",
clib_memset (plugin, 0, sizeof (*plugin));
plugin->sr_localsid_function_number = (plugin - sm->plugin_functions);
- plugin->sr_localsid_function_number += SR_BEHAVIOR_LAST;
+ plugin->sr_localsid_function_number += SR_BEHAVIOR_CURRENT_LAST;
plugin->prefix_length = prefix_length;
plugin->ls_format = ls_format;
plugin->ls_unformat = ls_unformat;
{
plugin =
pool_elt_at_index (sm->policy_plugin_functions,
- sr_policy->plugin - SR_BEHAVIOR_LAST);
+ sr_policy->plugin - SR_BEHAVIOR_CURRENT_LAST);
segment_list->plugin = sr_policy->plugin;
segment_list->plugin_mem = sr_policy->plugin_mem;
plugin =
pool_elt_at_index (sm->policy_plugin_functions,
- sr_policy->plugin - SR_BEHAVIOR_LAST);
+ sr_policy->plugin - SR_BEHAVIOR_CURRENT_LAST);
plugin->removal (sr_policy);
sr_policy->plugin = 0;
clib_memset (plugin, 0, sizeof (*plugin));
plugin->sr_policy_function_number = (plugin - sm->policy_plugin_functions);
- plugin->sr_policy_function_number += SR_BEHAVIOR_LAST;
+ plugin->sr_policy_function_number += SR_BEHAVIOR_CURRENT_LAST;
plugin->prefix_length = prefix_length;
plugin->ls_format = ls_format;
plugin->ls_unformat = ls_unformat;