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,
382 u8 traffic_type, ip46_address_t * next_hop,
383 u8 nh_type,
u32 color,
char co_bits,
400 key.
prefix.as_u64[0] = prefix->as_u64[0];
401 key.
prefix.as_u64[1] = prefix->as_u64[1];
418 if (steer_pl->
bsid != (
u32) ~ 0)
426 if (steer_pl->
co_bits != co_bits)
441 memset (steer_pl, 0,
sizeof (*steer_pl));
457 if (bsid != (
u32) ~ 0)
461 steer_pl->
bsid = bsid;
469 .frp_local_label = sr_policy->
bsid,
471 .frp_sw_if_index = ~0,
498 (table_id != (
u32) ~ 0 ? table_id : 0)),
513 (table_id != (
u32) ~ 0 ? table_id : 0)),
548 u8 traffic_type,
u32 table_id,
u32 color)
562 key.
prefix.as_u64[0] = prefix->as_u64[0];
563 key.
prefix.as_u64[1] = prefix->as_u64[1];
581 if (steer_pl->
bsid == (
u32) ~ 0)
665 ip46_address_t
prefix, nh;
666 u32 dst_mask_width = 0;
669 u32 fib_table = (
u32) ~ 0, color = (
u32) ~ 0;
674 u8 sr_policy_set = 0;
676 memset (&prefix, 0,
sizeof (ip46_address_t));
677 memset (&nh, 0,
sizeof (ip46_address_t));
684 else if (!traffic_type
686 &prefix.ip6, &dst_mask_width))
688 else if (!traffic_type
690 &prefix.ip4, &dst_mask_width))
692 else if (!sr_policy_set
693 &&
unformat (input,
"via sr policy bsid %U",
696 else if (!sr_policy_set
697 &&
unformat (input,
"via next-hop %U color %d co %d",
703 else if (!sr_policy_set
704 &&
unformat (input,
"via next-hop %U color %d co %d",
710 else if (fib_table == (
u32) ~ 0
711 &&
unformat (input,
"fib-table %d", &fib_table));
712 else if (
unformat (input,
"vpn-label %U",
727 (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
728 prefix.ip4.as_u32 &= mask;
743 traffic_type, fib_table, color);
748 traffic_type, &nh, nh_type, color, co_bits,
776 .path =
"sr mpls steer",
777 .short_help =
"sr mpls steer (del) l3 <ip_addr/mask> " 778 "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)",
780 "\tSteer L3 traffic through an existing SR policy.\n" 782 "\t\tsr steer l3 2001::/64 via sr_policy bsid 29999\n" 783 "\t\tsr steer del l3 2001::/64 via sr_policy bsid 29999\n" 784 "\t\tsr steer l3 2001::/64 via next-hop 1.1.1.1 color 1234 co 0\n" 785 "\t\tsr steer l3 2001::/64 via next-hop 2001::1 color 1234 co 2 vpn-label 500\n",
804 vec_add1(steer_policies, steer_pl);
807 for (i = 0; i <
vec_len (steer_policies); i++)
810 steer_pl = steer_policies[
i];
826 if (steer_pl->
bsid != (
u32) ~ 0)
849 s =
format (s,
"%d, ", *color_i);
877 .path =
"show sr mpls steering policies",
878 .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)
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.
#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.
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.
Configuration for each label value in the output-stack.
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
#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)
mpls_label_t fml_value
The label value.
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,...)