77 key.
l3.prefix.as_u64[0] = prefix->as_u64[0];
78 key.
l3.prefix.as_u64[1] = prefix->as_u64[1];
80 key.
l3.fib_table = (table_id != (
u32) ~ 0 ? table_id : 0);
139 "sr-pl-rewrite-encaps-l2",
140 sw_if_index, 0, 0, 0);
254 sizeof (ip46_address_t));
257 (table_id != (
u32) ~ 0 ? table_id : 0);
281 goto cleanup_error_encap;
284 (
"device-input",
"sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
285 goto cleanup_error_redirection;
297 goto cleanup_error_encap;
314 (ip46_address_t *) & sr_policy->
bsid, ~0,
331 (ip46_address_t *) & sr_policy->
bsid, ~0,
355 cleanup_error_redirection:
370 u32 dst_mask_width = 0;
373 u32 fib_table = (
u32) ~ 0;
376 u32 sr_policy_index = (
u32) ~ 0;
378 u8 sr_policy_set = 0;
387 else if (!traffic_type
389 &prefix.ip6, &dst_mask_width))
391 else if (!traffic_type
393 &prefix.ip4, &dst_mask_width))
395 else if (!traffic_type
399 else if (!sr_policy_set
400 &&
unformat (input,
"via index %d", &sr_policy_index))
402 else if (!sr_policy_set
406 else if (fib_table == (
u32) ~ 0
407 &&
unformat (input,
"fib-table %d", &fib_table));
421 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
422 prefix.ip4.as_u32 &= mask;
433 sr_policy_index, fib_table, &prefix, dst_mask_width,
434 sw_if_index, traffic_type);
446 "The requested SR policy could not be located. Review the BSID/index.");
449 "Unable to do SW redirect. Incorrect interface.");
452 "The requested SR steering policy could not be deleted.");
455 "The SR policy is not an encapsulation one.");
465 .short_help =
"sr steer (del) [l3 <ip_addr/mask>|l2 <sf_if>] " 466 "via [index <sr_policy_index>|bsid <bsid_ip6_addr>] " 467 "(fib-table <fib_table_index>)",
469 "\tSteer a L2 or L3 traffic through an existing SR policy.\n" 471 "\t\tsr steer l3 2001::/64 via sr_policy index 5\n" 472 "\t\tsr steer l3 2001::/64 via sr_policy bsid 2010::9999:1\n" 473 "\t\tsr steer l2 GigabitEthernet0/5/0 via sr_policy index 5\n" 474 "\t\tsr steer del l3 2001::/64 via sr_policy index 5\n",
498 for (i = 0; i <
vec_len (steer_policies); i++)
500 steer_pl = steer_policies[
i];
531 .path =
"show sr steering-policies",
532 .short_help =
"show sr steering-policies",
560 .arc_name =
"device-input",
561 .node_name =
"sr-pl-rewrite-encaps-l2",
fib_protocol_t fp_proto
protocol type
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
static clib_error_t * sr_steer_policy_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_memcpy_fast(a, b, c)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static void ip6_address_mask(ip6_address_t *a, const ip6_address_t *mask)
ip6_sr_steering_policy_t * steer_policies
format_function_t format_vnet_sw_if_index_name
#define pool_len(p)
Number of elements in pool vector.
static clib_error_t * show_sr_steering_policies_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_FEATURE_INIT(sr_pl_rewrite_encaps_l2, static)
u32 * sw_iface_sr_policies
struct sr_steering_key_t::@365::@367 l3
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
Aggregate type for a prefix.
#define clib_error_return(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
struct sr_steering_key_t::@365::@368 l2
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
#define pool_put(P, E)
Free an object E in pool P.
sr_steering_key_t classify
Traffic classification.
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
u8 is_encap
Mode (0 is SRH insert, 1 Encaps)
u32 sr_policy
SR Policy index.
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
uint32_t mask_width(const boost::asio::ip::address &addr)
Get the prefix mask length of a host route from the boost address.
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
int sr_steering_policy(int is_del, ip6_address_t *bsid, u32 sr_policy_index, u32 table_id, ip46_address_t *prefix, u32 mask_width, u32 sw_if_index, u8 traffic_type)
Steer traffic L2 and L3 traffic through a given SR policy.
#define VLIB_CLI_COMMAND(x,...)
static uword * mhash_get(mhash_t *h, const void *key)
#define VNET_FEATURES(...)
mhash_t sr_policies_index_hash
clib_error_t * sr_steering_init(vlib_main_t *vm)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_sr_policy_t * sr_policies
mhash_t sr_steer_policies_hash
vnet_sw_interface_t * sw_interfaces
static void ip6_address_mask_from_width(ip6_address_t *a, u32 width)
Segment Routing data structures definitions.
Segment Routing main datastructure.
vnet_sw_interface_type_t type
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
ip6_address_t bsid
BindingSID (key)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static uword pool_elts(void *v)
Number of active elements in a pool.