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",
170 return clib_net_to_host_u32(r1->
dest) - clib_net_to_host_u32(r2->
dest);
198 u32 table_id, is_del, is_ip;
213 memset(&pfx, 0,
sizeof(pfx));
221 memset(&rpath, 0,
sizeof(rpath));
223 if (
unformat (line_input,
"table %d", &table_id))
225 else if (
unformat (line_input,
"del"))
227 else if (
unformat (line_input,
"add"))
229 else if (
unformat (line_input,
"eos"))
231 else if (
unformat (line_input,
"non-eos"))
233 else if (
unformat (line_input,
"%U/%d",
241 else if (
unformat (line_input,
"%U/%d",
249 else if (
unformat (line_input,
"via %U %U weight %u",
253 &rpath.frp_sw_if_index,
260 else if (
unformat (line_input,
"via %U %U weight %u",
264 &rpath.frp_sw_if_index,
271 else if (
unformat (line_input,
"via %U %U",
275 &rpath.frp_sw_if_index))
277 rpath.frp_weight = 1;
282 else if (
unformat (line_input,
"via %U %U",
286 &rpath.frp_sw_if_index))
288 rpath.frp_weight = 1;
292 else if (
unformat (line_input,
"via %U next-hop-table %d",
295 &rpath.frp_fib_index))
297 rpath.frp_weight = 1;
298 rpath.frp_sw_if_index = ~0;
302 else if (
unformat (line_input,
"via %U next-hop-table %d",
305 &rpath.frp_fib_index))
307 rpath.frp_weight = 1;
308 rpath.frp_sw_if_index = ~0;
312 else if (
unformat (line_input,
"via %U",
314 &rpath.frp_addr.ip4))
320 rpath.frp_fib_index = table_id;
321 rpath.frp_weight = 1;
322 rpath.frp_sw_if_index = ~0;
326 else if (
unformat (line_input,
"via %U",
328 &rpath.frp_addr.ip6))
330 rpath.frp_fib_index = table_id;
331 rpath.frp_weight = 1;
332 rpath.frp_sw_if_index = ~0;
336 else if (
unformat (line_input,
"%d", &local_label))
339 "ip4-lookup-in-table %d",
340 &rpath.frp_fib_index))
348 "ip6-lookup-in-table %d",
349 &rpath.frp_fib_index))
357 "mpls-lookup-in-table %d",
358 &rpath.frp_fib_index))
365 else if (
unformat (line_input,
"out-label %U",
477 .path =
"mpls local-label",
479 .short_help =
"Create/Delete MPL local labels",
u32 fib_table_id_find_fib_index(fib_protocol_t proto, u32 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.
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)
static clib_error_t * mpls_input_init(vlib_main_t *vm)
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...
vnet_main_t * vnet_get_main(void)
#define MPLS_IETF_ROUTER_ALERT_STRING
#define VLIB_INIT_FUNCTION(x)
int mpls_fib_reset_labels(u32 fib_id)
Aggregrate type for a prefix.
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.
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)
mpls_main_t * mpls_get_main(vlib_main_t *vm)
int mpls_label_cmp(void *a1, void *a2)
static u32 vnet_mpls_uc_get_exp(mpls_label_t label_exp_s_ttl)
#define clib_error_return(e, args...)
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