57 u32 table_id, ip46_address_t * prefix,
58 u32 mask_width,
u8 traffic_type)
73 key.
prefix.as_u64[0] = prefix->as_u64[0];
74 key.
prefix.as_u64[1] = prefix->as_u64[1];
195 memset (steer_pl, 0,
sizeof (*steer_pl));
200 sizeof (ip46_address_t));
222 .frp_local_label = sr_policy->
bsid,
224 .frp_sw_if_index = ~0,
228 .frp_label_stack =
NULL 245 (table_id != (
u32) ~ 0 ? table_id : 0)),
262 (table_id != (
u32) ~ 0 ? table_id : 0)),
278 ip46_address_t prefix;
279 u32 dst_mask_width = 0;
281 u32 fib_table = (
u32) ~ 0;
284 u32 sr_policy_index = (
u32) ~ 0;
286 u8 sr_policy_set = 0;
288 memset (&prefix, 0,
sizeof (ip46_address_t));
295 else if (!traffic_type
297 &prefix.ip6, &dst_mask_width))
299 else if (!traffic_type
301 &prefix.ip4, &dst_mask_width))
303 else if (!sr_policy_set
304 &&
unformat (input,
"via sr policy index %d",
307 else if (!sr_policy_set
308 &&
unformat (input,
"via sr policy bsid %U",
311 else if (fib_table == (
u32) ~ 0
312 &&
unformat (input,
"fib-table %d", &fib_table));
326 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
327 prefix.ip4.as_u32 &= mask;
338 sr_policy_index, fib_table, &prefix,
339 dst_mask_width, traffic_type);
351 "The requested SR policy could not be located. Review the BSID/index.");
354 "Unable to do SW redirect. Incorrect interface.");
357 "The requested SR steering policy could not be deleted.");
360 "The SR policy is not an encapsulation one.");
369 .path =
"sr mpls steer",
370 .short_help =
"sr mpls steer (del) l3 <ip_addr/mask>" 371 "via sr policy bsid <mpls_label> (fib-table <fib_table_index>)",
373 "\tSteer L3 traffic through an existing SR policy.\n" 375 "\t\tsr steer l3 2001::/64 via sr_policy index 5\n" 376 "\t\tsr steer l3 2001::/64 via sr_policy bsid 29999\n" 377 "\t\tsr steer del l3 2001::/64 via sr_policy index 5\n",
399 for (i = 0; i <
vec_len (steer_policies); i++)
401 steer_pl = steer_policies[
i];
425 .path =
"show sr mpls steering policies",
426 .short_help =
"show sr mpls steering policies",
static void ip6_address_mask(ip6_address_t *a, ip6_address_t *mask)
fib_protocol_t fp_proto
protocol type
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
sll srl srl sll sra u16x4 i
A representation of a path as described by a route producer.
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
fib_node_index_t fib_table_entry_path_add2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *rpath)
Add n paths to an entry (aka route) in the FIB.
ip46_address_t prefix
IP address of the prefix.
u32 mpls_label_t
A label value only, i.e.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
mhash_t sr_steer_policies_hash
MHash table mapping steering rules to SR steer instance.
dpo_proto_t frp_proto
The protocol of the address below.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u32 fib_table
VRF of the prefix.
unformat_function_t unformat_mpls_unicast_label
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static clib_error_t * show_sr_mpls_steering_policies_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_INIT_FUNCTION(x)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
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.
mpls_sr_steering_policy_t * steer_policies
Pool of SR steer policies instances.
clib_error_t * sr_mpls_steering_init(vlib_main_t *vm)
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
mpls_label_t bsid
BindingSID (key)
static clib_error_t * sr_mpls_steer_policy_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
mpls_sr_main_t sr_mpls_main
sr_mpls_steering_key_t classify
Traffic classification.
u32 mask_width
Mask width of the prefix.
#define vec_free(V)
Free vector's memory (no header).
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)
mpls_sr_policy_t * sr_policies
SR MPLS policies.
#define VLIB_CLI_COMMAND(x,...)
Segment Routing main datastructure.
static uword * mhash_get(mhash_t *h, const void *key)
uword * sr_policies_index_hash
Hash table mapping BindingSID to SR MPLS policy.
u32 sr_policy
SR Policy index.
format_function_t format_mpls_unicast_label
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Segment Routing MPLS data structures definitions.
static void ip6_address_mask_from_width(ip6_address_t *a, u32 width)
int sr_mpls_steering_policy(int is_del, mpls_label_t bsid, u32 sr_policy_index, u32 table_id, ip46_address_t *prefix, u32 mask_width, u8 traffic_type)
Steer traffic L3 traffic through a given SR-MPLS policy.
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)