61 u32 table_id, ip46_address_t * prefix,
u32 mask_width,
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];
79 key.
l3.mask_width = mask_width;
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;
246 memset (steer_pl, 0,
sizeof (*steer_pl));
251 sizeof (ip46_address_t));
252 steer_pl->
classify.
l3.mask_width = mask_width;
254 (table_id != (
u32) ~ 0 ? table_id : 0);
259 steer_pl->
classify.
l2.sw_if_index = sw_if_index;
278 goto cleanup_error_encap;
281 (
"device-input",
"sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
282 goto cleanup_error_redirection;
290 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:
369 ip46_address_t prefix;
370 u32 dst_mask_width = 0;
371 u32 sw_if_index = (
u32) ~ 0;
373 u32 fib_table = (
u32) ~ 0;
376 u32 sr_policy_index = (
u32) ~ 0;
378 u8 sr_policy_set = 0;
380 memset (&prefix, 0,
sizeof (ip46_address_t));
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 sr policy index %d",
403 else if (!sr_policy_set
404 &&
unformat (input,
"via sr policy bsid %U",
407 else if (fib_table == (
u32) ~ 0
408 &&
unformat (input,
"fib-table %d", &fib_table));
422 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
423 prefix.ip4.as_u32 &= mask;
434 sr_policy_index, fib_table, &prefix, dst_mask_width,
435 sw_if_index, traffic_type);
447 "The requested SR policy could not be located. Review the BSID/index.");
450 "Unable to do SW redirect. Incorrect interface.");
453 "The requested SR steering policy could not be deleted.");
456 "The SR policy is not an encapsulation one.");
466 .short_help =
"sr steer (del) [l3 <ip_addr/mask>|l2 <sf_if>]" 467 "via sr policy [index <sr_policy_index>|bsid <bsid_ip6_addr>]" 468 "(fib-table <fib_table_index>)",
470 "\tSteer a L2 or L3 traffic through an existing SR policy.\n" 472 "\t\tsr steer l3 2001::/64 via sr_policy index 5\n" 473 "\t\tsr steer l3 2001::/64 via sr_policy bsid 2010::9999:1\n" 474 "\t\tsr steer l2 GigabitEthernet0/5/0 via sr_policy index 5\n" 475 "\t\tsr steer del l3 2001::/64 via sr_policy index 5\n",
499 for (i = 0; i <
vec_len (steer_policies); i++)
501 steer_pl = steer_policies[
i];
532 .path =
"show sr steering policies",
533 .short_help =
"show sr steering policies",
561 .arc_name =
"device-input",
562 .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
sll srl srl sll sra u16x4 i
vnet_main_t * vnet_get_main(void)
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.
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, fib_protocol_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, mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
void fib_table_unlock(u32 fib_index, fib_protocol_t proto)
Take a reference counting lock on the table.
#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)
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)
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
#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,...)
struct sr_steering_key_t::@253::@256 l2
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 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)
struct sr_steering_key_t::@253::@255 l3
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)
Segment Routing data structures definitions.
static uword pool_elts(void *v)
Number of active elements in a pool.