51 s =
format (s,
"%d", label);
77 else if (
unformat (input,
"%d", label))
100 return (
format(s,
"[%U:%d:%d:%U]",
112 u8 ** result = va_arg (*args,
u8 **);
114 u32 label, label_exp_s_ttl;
116 if (!
unformat (input,
"MPLS %d", &label))
119 label_exp_s_ttl = (label<<12) | (1<<8) | 0xFF;
125 u32 h_n_bytes =
sizeof (h[0]);
138 u32 * result = va_arg (*args,
u32 *);
141 if (!
unformat (input,
"MPLS: label %d", &label))
144 label = (label<<12) | (1<<8) | 0xFF ;
146 *result = clib_host_to_net_u32 (label);
155 s =
format (s,
"label %d exp %d, s %d, ttl %d",
188 return clib_net_to_host_u32(r1->
dest) - clib_net_to_host_u32(r2->
dest);
216 u32 table_id, is_del, is_ip;
231 memset(&pfx, 0,
sizeof(pfx));
239 memset(&rpath, 0,
sizeof(rpath));
241 if (
unformat (line_input,
"table %d", &table_id))
243 else if (
unformat (line_input,
"del"))
245 else if (
unformat (line_input,
"add"))
247 else if (
unformat (line_input,
"eos"))
249 else if (
unformat (line_input,
"non-eos"))
251 else if (
unformat (line_input,
"%U/%d",
259 else if (
unformat (line_input,
"%U/%d",
267 else if (
unformat (line_input,
"via %U %U weight %u",
271 &rpath.frp_sw_if_index,
278 else if (
unformat (line_input,
"via %U %U weight %u",
282 &rpath.frp_sw_if_index,
289 else if (
unformat (line_input,
"via %U %U",
293 &rpath.frp_sw_if_index))
295 rpath.frp_weight = 1;
299 else if (
unformat (line_input,
"rx-ip4 %U",
301 &rpath.frp_sw_if_index))
303 rpath.frp_weight = 1;
308 else if (
unformat (line_input,
"via %U %U",
312 &rpath.frp_sw_if_index))
314 rpath.frp_weight = 1;
318 else if (
unformat (line_input,
"via %U next-hop-table %d",
321 &rpath.frp_fib_index))
323 rpath.frp_weight = 1;
324 rpath.frp_sw_if_index = ~0;
328 else if (
unformat (line_input,
"via %U next-hop-table %d",
331 &rpath.frp_fib_index))
333 rpath.frp_weight = 1;
334 rpath.frp_sw_if_index = ~0;
338 else if (
unformat (line_input,
"via %U",
340 &rpath.frp_addr.ip4))
346 rpath.frp_fib_index = table_id;
347 rpath.frp_weight = 1;
348 rpath.frp_sw_if_index = ~0;
352 else if (
unformat (line_input,
"via %U",
354 &rpath.frp_addr.ip6))
356 rpath.frp_fib_index = table_id;
357 rpath.frp_weight = 1;
358 rpath.frp_sw_if_index = ~0;
362 else if (
unformat (line_input,
"%d", &local_label))
365 "ip4-lookup-in-table %d",
366 &rpath.frp_fib_index))
374 "ip6-lookup-in-table %d",
375 &rpath.frp_fib_index))
383 "mpls-lookup-in-table %d",
384 &rpath.frp_fib_index))
394 &rpath.frp_sw_if_index))
401 else if (
unformat (line_input,
"out-labels"))
534 .path =
"mpls local-label",
536 .short_help =
"Create/Delete MPL local labels",
546 u32 table_id, is_add;
558 if (
unformat (line_input,
"%d", &table_id))
560 else if (
unformat (line_input,
"del"))
562 else if (
unformat (line_input,
"add"))
564 else if (
unformat (line_input,
"name %s", &name))
603 .path =
"mpls table",
604 .short_help =
"mpls table [add|del] <table-id>",
fib_protocol_t fp_proto
protocol type
uword unformat_mpls_unicast_label(unformat_input_t *input, va_list *args)
A representation of a path as described by a route producer.
vnet_main_t * vnet_get_main(void)
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.
u32 mpls_label_t
A label value only, i.e.
#define MPLS_IETF_IMPLICIT_NULL_LABEL
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define MPLS_IETF_ROUTER_ALERT_LABEL
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
u8 * format_mpls_unicast_label(u8 *s, va_list *args)
u8 * format_mpls_unicast_header_host_byte_order(u8 *s, va_list *args)
dpo_proto_t frp_proto
The protocol of the address below.
unformat_function_t unformat_vnet_sw_interface
int mpls_dest_cmp(void *a1, void *a2)
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
void fib_table_entry_local_label_remove(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
remove a MPLS local label for the prefix/route.
#define MPLS_IETF_IPV4_EXPLICIT_NULL_BRIEF_STRING
dpo_proto_t fp_payload_proto
This protocol determines the payload protocol of packets that will be forwarded by this entry once th...
#define MPLS_IETF_ROUTER_ALERT_STRING
#define VLIB_INIT_FUNCTION(x)
int mpls_fib_reset_labels(u32 fib_id)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
static const char * mpls_eos_bit_names[]
#define MPLS_IETF_ROUTER_ALERT_BRIEF_STRING
static u32 vnet_mpls_uc_get_ttl(mpls_label_t label_exp_s_ttl)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
u16 fp_len
The mask length.
#define vlib_call_init_function(vm, x)
#define MPLS_IETF_IPV6_EXPLICIT_NULL_BRIEF_STRING
#define MPLS_IETF_GAL_STRING
void mpls_table_delete(u32 table_id, u8 is_api)
#define MPLS_IETF_ELI_LABEL
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
clib_error_t * vnet_mpls_table_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmdo)
void fib_table_entry_path_remove2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
static u32 vnet_mpls_uc_get_label(mpls_label_t label_exp_s_ttl)
uword unformat_mpls_header(unformat_input_t *input, va_list *args)
#define MPLS_IETF_IPV4_EXPLICIT_NULL_STRING
clib_error_t * ip_main_init(vlib_main_t *vm)
fib_node_index_t fib_table_entry_local_label_add(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
Add a MPLS local label for the prefix/route.
#define MPLS_LABEL_INVALID
#define MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL
#define clib_memcpy(a, b, c)
u32 fib_node_index_t
A typedef of a node index.
#define MPLS_IETF_IMPLICIT_NULL_BRIEF_STRING
u32 mpls_fib_index_from_table_id(u32 table_id)
#define VLIB_CLI_COMMAND(x,...)
#define MPLS_IETF_IPV6_EXPLICIT_NULL_STRING
static clib_error_t * vnet_mpls_local_label(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define MPLS_IETF_GAL_LABEL
void mpls_table_create(u32 table_id, u8 is_api, const u8 *name)
uword unformat_mpls_label_net_byte_order(unformat_input_t *input, va_list *args)
#define MPLS_IETF_ELI_STRING
#define MPLS_IETF_IMPLICIT_NULL_STRING
u8 * format_fib_protocol(u8 *s, va_list ap)
static clib_error_t * mpls_init(vlib_main_t *vm)
u8 * format_mpls_unicast_header_net_byte_order(u8 *s, va_list *args)
#define FIB_NODE_INDEX_INVALID
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u32 vnet_mpls_uc_get_s(mpls_label_t label_exp_s_ttl)
#define MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL
u8 * format_dpo_proto(u8 *s, va_list *args)
format a DPO protocol
u8 * format_mpls_eos_bit(u8 *s, va_list *args)
int mpls_label_cmp(void *a1, void *a2)
static u32 vnet_mpls_uc_get_exp(mpls_label_t label_exp_s_ttl)
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
int mpls_fib_index_cmp(void *a1, void *a2)
u8 * format_mpls_header(u8 *s, va_list *args)
enum mpls_eos_bit_t_ mpls_eos_bit_t