42 #define SRMPLS_TE_OFFSET 50 63 uword *color_table, *result_label;
73 memset (&color_t, 0,
sizeof (
mhash_t));
83 return (
u32) * result_label;
86 u32 *new_internal_label = 0;
88 *new_internal_label = 0;
98 ip46_address_t zero,
any;
100 any.as_u64[0] = any.as_u64[1] = (
u64) ~ 0;
128 uword *color_table, *result_label;
152 ip46_address_t zero,
any;
154 any.as_u64[0] = any.as_u64[1] = (
u64) ~ 0;
182 uword *color_table, *result_label;
200 if (*label_lock == 0)
231 u32 *internal_labels = 0;
232 ip46_address_t zero,
any;
234 any.as_u64[0] = any.as_u64[1] = (
u64) ~ 0;
271 "SR-MPLS Traffic Engineering (NextHop,Color)");
281 .frp_sw_if_index = ~0,
379 u8 traffic_type, ip46_address_t * next_hop,
380 u8 nh_type,
u32 color,
char co_bits,
396 key.
prefix.as_u64[0] = prefix->as_u64[0];
397 key.
prefix.as_u64[1] = prefix->as_u64[1];
421 if (steer_pl->
bsid != (
u32) ~ 0)
429 if (steer_pl->
co_bits != co_bits)
444 memset (steer_pl, 0,
sizeof (*steer_pl));
460 if (bsid != (
u32) ~ 0)
464 steer_pl->
bsid = bsid;
472 .frp_local_label = sr_policy->
bsid,
474 .frp_sw_if_index = ~0,
496 (table_id != (
u32) ~ 0 ? table_id : 0)),
511 (table_id != (
u32) ~ 0 ? table_id : 0)),
546 u8 traffic_type,
u32 table_id,
u32 color)
560 key.
prefix.as_u64[0] = prefix->as_u64[0];
561 key.
prefix.as_u64[1] = prefix->as_u64[1];
579 if (steer_pl->
bsid == (
u32) ~ 0)
663 ip46_address_t prefix, nh;
664 u32 dst_mask_width = 0;
667 u32 fib_table = (
u32) ~ 0, color = (
u32) ~ 0;
672 u8 sr_policy_set = 0;
674 memset (&prefix, 0,
sizeof (ip46_address_t));
675 memset (&nh, 0,
sizeof (ip46_address_t));
682 else if (!traffic_type
684 &prefix.ip6, &dst_mask_width))
686 else if (!traffic_type
688 &prefix.ip4, &dst_mask_width))
690 else if (!sr_policy_set
691 &&
unformat (input,
"via sr policy bsid %U",
694 else if (!sr_policy_set
695 &&
unformat (input,
"via next-hop %U color %d co %d",
701 else if (!sr_policy_set
702 &&
unformat (input,
"via next-hop %U color %d co %d",
708 else if (fib_table == (
u32) ~ 0
709 &&
unformat (input,
"fib-table %d", &fib_table));
710 else if (
unformat (input,
"vpn-label %U",
725 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
726 prefix.ip4.as_u32 &= mask;
741 traffic_type, fib_table, color);
746 traffic_type, &nh, nh_type, color, co_bits,
774 .path =
"sr mpls steer",
775 .short_help =
"sr mpls steer (del) l3 <ip_addr/mask> " 776 "via [sr policy bsid <mpls_label> || next-hop <ip46_addr> color <u32> co <0|1|2|3> ](fib-table <fib_table_index>)(vpn-label 500)",
778 "\tSteer L3 traffic through an existing SR policy.\n" 780 "\t\tsr steer l3 2001::/64 via sr_policy bsid 29999\n" 781 "\t\tsr steer del l3 2001::/64 via sr_policy bsid 29999\n" 782 "\t\tsr steer l3 2001::/64 via next-hop 1.1.1.1 color 1234 co 0\n" 783 "\t\tsr steer l3 2001::/64 via next-hop 2001::1 color 1234 co 2 vpn-label 500\n",
802 vec_add1(steer_policies, steer_pl);
805 for (i = 0; i <
vec_len (steer_policies); i++)
808 steer_pl = steer_policies[
i];
824 if (steer_pl->
bsid != (
u32) ~ 0)
847 s =
format (s,
"%d, ", *color_i);
875 .path =
"show sr mpls steering policies",
876 .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
#define vec_foreach_index(var, v)
Iterate over vector indices.
ip46_address_t frp_addr
The next-hop address.
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
sll srl srl sll sra u16x4 i
mpls_eos_bit_t frp_eos
EOS bit for the resolving label.
u32 * color
Vector of SR TE colors.
A representation of a path as described by a route producer.
ip46_address_t next_hop
SR TE NH.
void internal_label_lock(ip46_address_t endpoint, u32 color)
lock the label for (NH, C) endpoint might be NULL or ANY NULL = 0, ANY=~0
fib_node_index_t fib_table_entry_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *paths)
Update an entry to have a new set of paths.
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
dpo_proto_t frp_proto
The protocol of the address below.
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
int sort_color_descent(const u32 *x, u32 *y)
function to sort the colors in descending order
#define ip46_address_cmp(ip46_1, ip46_2)
u32 fib_table
VRF of the prefix.
unformat_function_t unformat_mpls_unicast_label
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
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)
void fib_table_flush(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Flush all entries from a table for the source.
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
#define vec_search(v, E)
Search a vector for the index of the entry that matches.
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.
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_del1(v, i)
Delete the element at index I.
mpls_sr_steering_policy_t * steer_policies
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)
int sr_mpls_steering_policy_add(mpls_label_t bsid, u32 table_id, ip46_address_t *prefix, u32 mask_width, u8 traffic_type, ip46_address_t *next_hop, u8 nh_type, u32 color, char co_bits, mpls_label_t vpn_label)
Steer traffic L3 traffic through a given SR-MPLS policy.
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
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...
int sr_mpls_steering_policy_del(ip46_address_t *prefix, u32 mask_width, u8 traffic_type, u32 table_id, u32 color)
Delete steering rule for an SR-MPLS policy.
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.
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)
static uword mhash_elts(mhash_t *m)
mpls_sr_policy_t * sr_policies
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
Segment Routing main datastructure.
void compute_sr_te_automated_steering_fib_entry(mpls_sr_steering_policy_t *steer_pl)
function to update the FIB
static uword * mhash_get(mhash_t *h, const void *key)
static void mhash_free(mhash_t *h)
u8 frp_preference
A path preference.
static void internal_label_lock_co(ip46_address_t endpoint, u32 color, char co_bits)
uword * sr_policies_index_hash
static void internal_label_unlock_co(ip46_address_t endpoint, u32 color, char co_bits)
mpls_label_t bsid
SR Policy index.
format_function_t format_mpls_unicast_label
mpls_label_t frp_local_label
The MPLS local Label to reursively resolve through.
#define ip46_address_reset(ip46)
mhash_t sr_policies_c2e2eclabel_hash
SR TE.
u32 find_or_create_internal_label(ip46_address_t endpoint, u32 color)
find the corresponding label for (endpoint, color) and lock it endpoint might be NULL or ANY NULL = 0...
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
char co_bits
Color-Only bits.
Segment Routing MPLS data structures definitions.
void internal_label_unlock(ip46_address_t endpoint, u32 color)
Release lock on label for (endpoint, color) endpoint might be NULL or ANY NULL = 0, ANY=~0.
static void ip6_address_mask_from_width(ip6_address_t *a, u32 width)
mpls_sr_main_t sr_mpls_main
#define vec_foreach(var, vec)
Vector iterator.
u32 fib_table_create_and_lock(fib_protocol_t proto, fib_source_t src, const char *const fmt,...)
Create a new table with no table ID.
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,...)