diff options
author | Ahmed Abdelsalam <ahabdels@cisco.com> | 2024-11-12 08:56:45 -0600 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2024-11-12 17:14:50 +0000 |
commit | c68c9708387c1d7a7ed6b59b7c2162950fcbc122 (patch) | |
tree | 9132871c0632235d79f57df8f0e4542d18fb0254 | |
parent | 27a901ece39c371eba0f11806d9fe54b0e8dc95c (diff) |
sr : enable SRv6 uSID in the SRv6 API
Type: improvement
Change-Id: I026b1a8fd1df0e6ac1dba8df78b12cde95aae419
Signed-off-by: Ahmed Abdelsalam <ahabdels@cisco.com>
-rw-r--r-- | src/vnet/srv6/sr.h | 23 | ||||
-rw-r--r-- | src/vnet/srv6/sr_localsid.c | 39 | ||||
-rw-r--r-- | src/vnet/srv6/sr_policy_rewrite.c | 6 | ||||
-rw-r--r-- | src/vnet/srv6/sr_types.api | 5 | ||||
-rw-r--r-- | test/vpp_srv6.py | 7 |
5 files changed, 48 insertions, 32 deletions
diff --git a/src/vnet/srv6/sr.h b/src/vnet/srv6/sr.h index ba114f2de6c..40edbbaf437 100644 --- a/src/vnet/srv6/sr.h +++ b/src/vnet/srv6/sr.h @@ -43,10 +43,22 @@ #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 @@ -165,7 +177,8 @@ typedef int (sr_plugin_callback_t) (ip6_sr_localsid_t * localsid); */ 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). */ diff --git a/src/vnet/srv6/sr_localsid.c b/src/vnet/srv6/sr_localsid.c index 578ee7d7239..2172fa10ef1 100644 --- a/src/vnet/srv6/sr_localsid.c +++ b/src/vnet/srv6/sr_localsid.c @@ -100,10 +100,10 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, { /* 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; } @@ -130,7 +130,7 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, || 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); @@ -149,13 +149,13 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, 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) { @@ -294,14 +294,14 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, 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 */ @@ -672,11 +672,10 @@ show_sr_localsid_command_fn (vlib_main_t * vm, unformat_input_t * input, 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", @@ -2404,7 +2403,7 @@ sr_localsid_register_function (vlib_main_t * vm, u8 * fn_name, 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; diff --git a/src/vnet/srv6/sr_policy_rewrite.c b/src/vnet/srv6/sr_policy_rewrite.c index 0aa88cc273e..a9114628f95 100644 --- a/src/vnet/srv6/sr_policy_rewrite.c +++ b/src/vnet/srv6/sr_policy_rewrite.c @@ -418,7 +418,7 @@ create_sl (ip6_sr_policy_t *sr_policy, ip6_address_t *sl, { 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; @@ -828,7 +828,7 @@ sr_policy_del (ip6_address_t * bsid, u32 index) 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; @@ -3499,7 +3499,7 @@ sr_policy_register_function (vlib_main_t * vm, u8 * fn_name, 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; diff --git a/src/vnet/srv6/sr_types.api b/src/vnet/srv6/sr_types.api index 967eab0bd5a..7bc22c1a0f4 100644 --- a/src/vnet/srv6/sr_types.api +++ b/src/vnet/srv6/sr_types.api @@ -35,7 +35,10 @@ enum sr_behavior : u8 SR_BEHAVIOR_API_DX4 = 7, SR_BEHAVIOR_API_DT6 = 8, SR_BEHAVIOR_API_DT4 = 9, - SR_BEHAVIOR_API_LAST = 10, /* Must always be the last one */ + SR_BEHAVIOR_API_LAST = 10, /* Not used. Kept not to break the API */ + SR_BEHAVIOR_API_END_UN_PERF = 11 [backwards_compatible], + SR_BEHAVIOR_API_END_UN = 12 [backwards_compatible], + SR_BEHAVIOR_API_UA = 13 [backwards_compatible], }; enum sr_steer : u8 diff --git a/test/vpp_srv6.py b/test/vpp_srv6.py index 1b09103f297..5fa293f62ec 100644 --- a/test/vpp_srv6.py +++ b/test/vpp_srv6.py @@ -20,9 +20,10 @@ class SRv6LocalSIDBehaviors: SR_BEHAVIOR_DX4 = 7 SR_BEHAVIOR_DT6 = 8 SR_BEHAVIOR_DT4 = 9 - SR_BEHAVIOR_END_UN_PERF = 10 - SR_BEHAVIOR_END_UN = 11 - SR_BEHAVIOR_LAST = 12 # Must always be the last one + SR_BEHAVIOR_LAST = 10 # Not used anymore. Kept not to break the API. + SR_BEHAVIOR_END_UN_PERF = 11 + SR_BEHAVIOR_END_UN = 12 + SR_BEHAVIOR_END_UA = 13 class SRv6PolicyType: |