X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsrv6%2Fsr.h;h=98304b8bafd58a9a76b5898c2afa882b1120c810;hb=adef691a6f544c30c417a8f747688cfbf30de356;hp=1a30cf3e3e09b4288e0951ee7f92c0518457b2cb;hpb=1a5e301fcdcd109d14112aafc5f5ee48d1462458;p=vpp.git diff --git a/src/vnet/srv6/sr.h b/src/vnet/srv6/sr.h old mode 100755 new mode 100644 index 1a30cf3e3e0..98304b8bafd --- a/src/vnet/srv6/sr.h +++ b/src/vnet/srv6/sr.h @@ -43,7 +43,9 @@ #define SR_BEHAVIOR_DX4 7 #define SR_BEHAVIOR_DT6 8 #define SR_BEHAVIOR_DT4 9 -#define SR_BEHAVIOR_LAST 10 /* Must always be the last one */ +#define SR_BEHAVIOR_END_UN_PERF 10 +#define SR_BEHAVIOR_END_UN 11 +#define SR_BEHAVIOR_LAST 12 /* Must always be the last one */ #define SR_STEER_L2 2 #define SR_STEER_IPV4 4 @@ -54,6 +56,14 @@ #define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1 +/* *INDENT-OFF* */ +typedef struct +{ + ip6_header_t ip; + ip6_sr_header_t sr; +} __attribute__ ((packed)) ip6srv_combo_header_t; +/* *INDENT-ON* */ + /** * @brief SR Segment List (SID list) */ @@ -66,9 +76,14 @@ typedef struct u8 *rewrite; /**< Precomputed rewrite header */ u8 *rewrite_bsid; /**< Precomputed rewrite header for bindingSID */ + u32 egress_fib_table; /**< Egress FIB table for encap packet */ + dpo_id_t bsid_dpo; /**< DPO for Encaps/Insert for BSID */ dpo_id_t ip6_dpo; /**< DPO for Encaps/Insert IPv6 */ dpo_id_t ip4_dpo; /**< DPO for Encaps IPv6 */ + + u16 plugin; + void *plugin_mem; } ip6_sr_sl_t; /* SR policy types */ @@ -94,8 +109,13 @@ typedef struct u32 fib_table; /**< FIB table */ u8 is_encap; /**< Mode (0 is SRH insert, 1 Encaps) */ + + u16 plugin; + void *plugin_mem; } ip6_sr_policy_t; +typedef int (sr_p_plugin_callback_t) (ip6_sr_policy_t * sr); + /** * @brief SR LocalSID */ @@ -103,6 +123,8 @@ typedef struct { ip6_address_t localsid; /**< LocalSID IPv6 address */ + u16 localsid_prefix_len; + char end_psp; /**< Combined with End.PSP? */ u16 behavior; /**< Behavior associated to this localsid */ @@ -121,6 +143,15 @@ typedef struct u32 nh_adj; /**< Next_adj for xconnect usage only */ + ip6_address_t usid_block; + ip6_address_t usid_block_mask; + + u8 usid_index; + u8 usid_len; + + u8 usid_next_index; + u8 usid_next_len; + void *plugin_mem; /**< Memory to be used by the plugin callback functions */ } ip6_sr_localsid_t; @@ -141,6 +172,8 @@ typedef struct u8 *params_str; /**< Behavior parameters (i.e. ) */ + u8 prefix_length; + dpo_type_t dpo; /**< DPO type registration */ format_function_t *ls_format; /**< LocalSID format function */ @@ -152,6 +185,34 @@ typedef struct sr_plugin_callback_t *removal; /**< Function within plugin that will be called before localsid removal */ } sr_localsid_fn_registration_t; +/** + * @brief SR Policy behavior registration + */ +typedef struct +{ + u16 sr_policy_function_number; /**< SR Policy plugin function */ + + u8 *function_name; /**< Function name. (key). */ + + u8 *keyword_str; /**< Behavior keyword (i.e. End.X) */ + + u8 *def_str; /**< Behavior definition (i.e. Endpoint with cross-connect) */ + + u8 *params_str; /**< Behavior parameters (i.e. ) */ + + u8 prefix_length; + + dpo_type_t dpo; /**< DPO type registration */ + + format_function_t *ls_format; /**< LocalSID format function */ + + unformat_function_t *ls_unformat; /**< LocalSID unformat function */ + + sr_p_plugin_callback_t *creation; /**< Function within plugin that will be called after localsid creation*/ + + sr_p_plugin_callback_t *removal; /**< Function within plugin that will be called before localsid removal */ +} sr_policy_fn_registration_t; + /** * @brief Steering db key * @@ -183,6 +244,13 @@ typedef struct u32 sr_policy; /**< SR Policy index */ } ip6_sr_steering_policy_t; +typedef struct +{ + ip6_address_t address; + u16 pref_len; + u8 padding[2]; +} sr_localsid_key_t; + /** * @brief Segment Routing main datastructure */ @@ -224,6 +292,12 @@ typedef struct /* Find plugin function by name */ uword *plugin_functions_by_key; + /* Plugin functions for Policy */ + sr_policy_fn_registration_t *policy_plugin_functions; + + /* Find plugin function by name */ + uword *policy_plugin_functions_by_key; + /* Counters */ vlib_combined_counter_main_t sr_ls_valid_counters; vlib_combined_counter_main_t sr_ls_invalid_counters; @@ -250,26 +324,37 @@ extern void sr_dpo_unlock (dpo_id_t * dpo); extern int sr_localsid_register_function (vlib_main_t * vm, u8 * fn_name, u8 * keyword_str, u8 * def_str, - u8 * params_str, dpo_type_t * dpo, + u8 * params_str, u8 prefix_length, + dpo_type_t * dpo, format_function_t * ls_format, unformat_function_t * ls_unformat, sr_plugin_callback_t * creation_fn, sr_plugin_callback_t * removal_fn); extern int -sr_policy_add (ip6_address_t * bsid, ip6_address_t * segments, - u32 weight, u8 behavior, u32 fib_table, u8 is_encap); +sr_policy_register_function (vlib_main_t * vm, u8 * fn_name, + u8 * keyword_str, u8 * def_str, + u8 * params_str, u8 prefix_length, + dpo_type_t * dpo, + format_function_t * ls_format, + unformat_function_t * ls_unformat, + sr_p_plugin_callback_t * creation_fn, + sr_p_plugin_callback_t * removal_fn); + extern int -sr_policy_mod (ip6_address_t * bsid, u32 index, u32 fib_table, - u8 operation, ip6_address_t * segments, u32 sl_index, - u32 weight); +sr_policy_add (ip6_address_t * bsid, ip6_address_t * segments, + u32 weight, u8 behavior, u32 fib_table, u8 is_encap, + u16 plugin, void *plugin_mem); +extern int sr_policy_mod (ip6_address_t * bsid, u32 index, u32 fib_table, + u8 operation, ip6_address_t * segments, + u32 sl_index, u32 weight); extern int sr_policy_del (ip6_address_t * bsid, u32 index); extern int sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, - char end_psp, u8 behavior, u32 sw_if_index, - u32 vlan_index, u32 fib_table, ip46_address_t * nh_addr, - void *ls_plugin_mem); + u16 localsid_prefix_len, char end_psp, u8 behavior, + u32 sw_if_index, u32 vlan_index, u32 fib_table, + ip46_address_t * nh_addr, int usid_len, void *ls_plugin_mem); extern int sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, @@ -277,6 +362,10 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, u32 sw_if_index, u8 traffic_type); extern void sr_set_source (ip6_address_t * address); +extern ip6_address_t *sr_get_encaps_source (); + +extern void sr_set_hop_limit (u8 hop_limit); +extern u8 sr_get_hop_limit (void); /** * @brief SR rewrite string computation for SRH insertion (inline) @@ -302,21 +391,21 @@ ip6_sr_compute_rewrite_string_insert (ip6_address_t * sl) srh = (ip6_sr_header_t *) rs; srh->type = ROUTING_HEADER_TYPE_SR; srh->segments_left = vec_len (sl); - srh->first_segment = vec_len (sl); + srh->last_entry = vec_len (sl); srh->length = ((sizeof (ip6_sr_header_t) + ((vec_len (sl) + 1) * sizeof (ip6_address_t))) / 8) - 1; srh->flags = 0x00; - srh->reserved = 0x0000; + srh->tag = 0x0000; addrp = srh->segments + vec_len (sl); vec_foreach (this_address, sl) { - clib_memcpy (addrp->as_u8, this_address->as_u8, sizeof (ip6_address_t)); + clib_memcpy_fast (addrp->as_u8, this_address->as_u8, + sizeof (ip6_address_t)); addrp--; } return rs; } - #endif /* included_vnet_sr_h */ /*