62 u32 sw_if_index,
u8 traffic_type)
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);
84 key.
l2.sw_if_index = sw_if_index;
139 "sr-policy-rewrite-encaps-l2",
140 sw_if_index, 0, 0, 0);
150 goto cleanup_error_redirection;
248 memset (steer_pl, 0,
sizeof (*steer_pl));
253 sizeof (ip46_address_t));
256 (table_id != (
u32) ~ 0 ? table_id : 0);
261 steer_pl->
classify.
l2.sw_if_index = sw_if_index;
280 goto cleanup_error_encap;
283 (
"device-input",
"sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
284 goto cleanup_error_redirection;
292 goto cleanup_error_redirection;
299 goto cleanup_error_encap;
316 (ip46_address_t *) & sr_policy->
bsid, ~0,
333 (ip46_address_t *) & sr_policy->
bsid, ~0,
357 cleanup_error_redirection:
371 ip46_address_t prefix;
372 u32 dst_mask_width = 0;
373 u32 sw_if_index = (
u32) ~ 0;
375 u32 fib_table = (
u32) ~ 0;
378 u32 sr_policy_index = (
u32) ~ 0;
380 u8 sr_policy_set = 0;
382 memset (&prefix, 0,
sizeof (ip46_address_t));
389 else if (!traffic_type
391 &prefix.ip6, &dst_mask_width))
393 else if (!traffic_type
395 &prefix.ip4, &dst_mask_width))
397 else if (!traffic_type
401 else if (!sr_policy_set
402 &&
unformat (input,
"via index %d", &sr_policy_index))
404 else if (!sr_policy_set
408 else if (fib_table == (
u32) ~ 0
409 &&
unformat (input,
"fib-table %d", &fib_table));
423 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
424 prefix.ip4.as_u32 &= mask;
435 sr_policy_index, fib_table, &prefix, dst_mask_width,
436 sw_if_index, traffic_type);
448 "The requested SR policy could not be located. Review the BSID/index.");
451 "Unable to do SW redirect. Incorrect interface.");
454 "The requested SR steering policy could not be deleted.");
457 "The SR policy is not an encapsulation one.");
467 .short_help =
"sr steer (del) [l3 <ip_addr/mask>|l2 <sf_if>] " 468 "via [index <sr_policy_index>|bsid <bsid_ip6_addr>] " 469 "(fib-table <fib_table_index>)",
471 "\tSteer a L2 or L3 traffic through an existing SR policy.\n" 473 "\t\tsr steer l3 2001::/64 via sr_policy index 5\n" 474 "\t\tsr steer l3 2001::/64 via sr_policy bsid 2010::9999:1\n" 475 "\t\tsr steer l2 GigabitEthernet0/5/0 via sr_policy index 5\n" 476 "\t\tsr steer del l3 2001::/64 via sr_policy index 5\n",
500 for (i = 0; i <
vec_len (steer_policies); i++)
502 steer_pl = steer_policies[
i];
533 .path =
"show sr steering-policies",
534 .short_help =
"show sr steering-policies",
562 .arc_name =
"device-input",
563 .node_name =
"sr-pl-rewrite-encaps-l2",
static void ip6_address_mask(ip6_address_t *a, ip6_address_t *mask)
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)
struct sr_steering_key_t::@312::@315 l2
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)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
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).
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
ethernet_main_t ethernet_main
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
Aggregrate 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.
#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.
struct sr_steering_key_t::@312::@314 l3
#define clib_memcpy(a, b, c)
#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)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
#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.