51 s =
format (s,
"%d", label);
69 else if (
unformat (input,
"%d", label))
90 return (
format(s,
"[%U:%d:%d:%U]",
102 u8 ** result = va_arg (*args,
u8 **);
104 u32 label, label_exp_s_ttl;
106 if (!
unformat (input,
"MPLS %d", &label))
109 label_exp_s_ttl = (label<<12) | (1<<8) | 0xFF;
115 u32 h_n_bytes =
sizeof (h[0]);
128 u32 * result = va_arg (*args,
u32 *);
131 if (!
unformat (input,
"MPLS: label %d", &label))
134 label = (label<<12) | (1<<8) | 0xFF ;
136 *result = clib_host_to_net_u32 (label);
145 s =
format (s,
"label %d exp %d, s %d, ttl %d",
178 return clib_net_to_host_u32(r1->
dest) - clib_net_to_host_u32(r2->
dest);
206 u32 table_id, is_del, is_ip;
221 memset(&pfx, 0,
sizeof(pfx));
229 memset(&rpath, 0,
sizeof(rpath));
231 if (
unformat (line_input,
"table %d", &table_id))
233 else if (
unformat (line_input,
"del"))
235 else if (
unformat (line_input,
"add"))
237 else if (
unformat (line_input,
"eos"))
239 else if (
unformat (line_input,
"non-eos"))
241 else if (
unformat (line_input,
"%U/%d",
249 else if (
unformat (line_input,
"%U/%d",
257 else if (
unformat (line_input,
"via %U %U weight %u",
261 &rpath.frp_sw_if_index,
268 else if (
unformat (line_input,
"via %U %U weight %u",
272 &rpath.frp_sw_if_index,
279 else if (
unformat (line_input,
"via %U %U",
283 &rpath.frp_sw_if_index))
285 rpath.frp_weight = 1;
289 else if (
unformat (line_input,
"rx-ip4 %U",
291 &rpath.frp_sw_if_index))
293 rpath.frp_weight = 1;
298 else if (
unformat (line_input,
"via %U %U",
302 &rpath.frp_sw_if_index))
304 rpath.frp_weight = 1;
308 else if (
unformat (line_input,
"via %U next-hop-table %d",
311 &rpath.frp_fib_index))
313 rpath.frp_weight = 1;
314 rpath.frp_sw_if_index = ~0;
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",
330 &rpath.frp_addr.ip4))
336 rpath.frp_fib_index = table_id;
337 rpath.frp_weight = 1;
338 rpath.frp_sw_if_index = ~0;
342 else if (
unformat (line_input,
"via %U",
344 &rpath.frp_addr.ip6))
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,
"%d", &local_label))
355 "ip4-lookup-in-table %d",
356 &rpath.frp_fib_index))
364 "ip6-lookup-in-table %d",
365 &rpath.frp_fib_index))
373 "mpls-lookup-in-table %d",
374 &rpath.frp_fib_index))
381 else if (
unformat (line_input,
"out-label %U",
507 .path =
"mpls local-label",
509 .short_help =
"Create/Delete MPL local labels",
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)
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.
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[]
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_GAL_STRING
#define MPLS_IETF_ELI_LABEL
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
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.
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
uword unformat_mpls_label_net_byte_order(unformat_input_t *input, va_list *args)
#define MPLS_IETF_ELI_STRING
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
#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