43 memset(mld, 0,
sizeof(*mld));
53 return (mld - mpls_label_dpo_pool);
108 if (0 != label_stack[ii].fml_ttl)
132 if (0 != label_stack[ii].fml_ttl)
181 if ((1 << attr) & flags)
194 u32 indent = va_arg (*args,
u32);
204 return (
format(s,
"mpls-label[???,%d]:", index));
208 s =
format(s,
"mpls-label[%U%d]:",
310 ((
char*)hdr0)[3] = ttl0;
329 ((
char*)hdr0)[2] |= (exp0 << 1);
350 ((
char*)hdr0)[2] |= exp0;
362 u32 n_left_from, next_index, * from, * to_next;
369 while (n_left_from > 0)
375 while (n_left_from >= 8 && n_left_to_next >= 4)
377 u32 bi0, mldi0, bi1, mldi1, bi2, mldi2, bi3, mldi3;
381 u32 next0, next1, next2, next3;
382 u8 ttl0, ttl1, ttl2, ttl3;
383 u8 exp0, exp1, exp2, exp3;
385 bi0 = to_next[0] = from[0];
386 bi1 = to_next[1] = from[1];
387 bi2 = to_next[2] = from[2];
388 bi3 = to_next[3] = from[3];
452 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
453 checksum1 = ip1->
checksum + clib_host_to_net_u16 (0x0100);
454 checksum2 = ip2->
checksum + clib_host_to_net_u16 (0x0100);
455 checksum3 = ip3->
checksum + clib_host_to_net_u16 (0x0100);
457 checksum0 += checksum0 >= 0xffff;
458 checksum1 += checksum1 >= 0xffff;
459 checksum2 += checksum2 >= 0xffff;
460 checksum3 += checksum3 >= 0xffff;
584 ttl0 = ((
u8*)hdr0)[3];
585 exp0 = ((
u8*)hdr0)[2] & 0xe;
606 ttl1 = ((
u8*)hdr1)[3];
607 exp1 = ((
u8*)hdr1)[2] & 0xe;
628 ttl2 = ((
u8*)hdr2)[3];
629 exp2 = ((
u8*)hdr2)[2] & 0xe;
650 ttl3 = ((
u8*)hdr3)[3];
651 exp3 = ((
u8*)hdr3)[2] & 0xe;
740 next0, next1, next2, next3);
743 while (n_left_from > 0 && n_left_to_next > 0)
777 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
778 checksum0 += checksum0 >= 0xffff;
846 ttl0 = ((
u8*)hdr0)[3];
847 exp0 = ((
u8*)hdr0)[2] & 0xe;
879 n_left_to_next, bi0, next0);
899 s =
format (s,
"%Umpls-header:%U",
917 .name =
"mpls-label-imposition-pipe",
918 .vector_size =
sizeof (
u32),
940 .function = ip4_mpls_label_imposition_pipe,
941 .name =
"ip4-mpls-label-imposition-pipe",
942 .vector_size =
sizeof (
u32),
951 ip4_mpls_label_imposition_pipe)
964 .function = ip6_mpls_label_imposition_pipe,
965 .name =
"ip6-mpls-label-imposition-pipe",
966 .vector_size =
sizeof (
u32),
975 ip6_mpls_label_imposition_pipe)
988 .function = ethernet_mpls_label_imposition_pipe,
989 .name =
"ethernet-mpls-label-imposition-pipe",
990 .vector_size =
sizeof (
u32),
1000 ethernet_mpls_label_imposition_pipe)
1013 .function = mpls_mpls_label_imposition_uniform,
1014 .name =
"mpls-label-imposition-uniform",
1015 .vector_size =
sizeof (
u32),
1024 mpls_mpls_label_imposition_uniform)
1037 .function = ip4_mpls_label_imposition_uniform,
1038 .name =
"ip4-mpls-label-imposition-uniform",
1039 .vector_size =
sizeof (
u32),
1048 ip4_mpls_label_imposition_uniform)
1061 .function = ip6_mpls_label_imposition_uniform,
1062 .name =
"ip6-mpls-label-imposition-uniform",
1063 .vector_size =
sizeof (
u32),
1072 ip6_mpls_label_imposition_uniform)
1085 .function = ethernet_mpls_label_imposition_uniform,
1086 .name =
"ethernet-mpls-label-imposition-uniform",
1087 .vector_size =
sizeof (
u32),
1097 ethernet_mpls_label_imposition_uniform)
1100 ip4_mpls_label_imposition_pipe_no_ip_ttl_decr (
vlib_main_t *
vm,
1110 .function = ip4_mpls_label_imposition_pipe_no_ip_ttl_decr,
1111 .name =
"ip4-mpls-label-imposition-pipe-no-ip-ttl-decr",
1112 .vector_size =
sizeof (
u32),
1121 ip4_mpls_label_imposition_pipe_no_ip_ttl_decr)
1124 ip6_mpls_label_imposition_pipe_no_ip_ttl_decr (
vlib_main_t *
vm,
1134 .function = ip6_mpls_label_imposition_pipe_no_ip_ttl_decr,
1135 .name =
"ip6-mpls-label-imposition-pipe-no-ip-ttl-decr",
1136 .vector_size =
sizeof (
u32),
1145 ip6_mpls_label_imposition_pipe_no_ip_ttl_decr)
1148 ip4_mpls_label_imposition_uniform_no_ip_ttl_decr (
vlib_main_t *
vm,
1159 .function = ip4_mpls_label_imposition_uniform_no_ip_ttl_decr,
1160 .name =
"ip4-mpls-label-imposition-uniform-no-ip-ttl-decr",
1161 .vector_size =
sizeof (
u32),
1170 ip4_mpls_label_imposition_uniform_no_ip_ttl_decr)
1173 ip6_mpls_label_imposition_uniform_no_ip_ttl_decr (
vlib_main_t *
vm,
1184 .function = ip6_mpls_label_imposition_uniform_no_ip_ttl_decr,
1185 .name =
"ip6-mpls-label-imposition-uniform-no-ip-ttl-decr",
1186 .vector_size =
sizeof (
u32),
1195 ip6_mpls_label_imposition_uniform_no_ip_ttl_decr)
1199 mpls_label_dpo_mem_show (
void)
1243 .dv_mem_show = mpls_label_dpo_mem_show,
1249 "ip4-mpls-label-imposition-pipe",
1254 "ip6-mpls-label-imposition-pipe",
1259 "mpls-label-imposition-pipe",
1264 "ethernet-mpls-label-imposition-pipe",
1278 "ip4-mpls-label-imposition-uniform",
1283 "ip6-mpls-label-imposition-uniform",
1288 "mpls-label-imposition-uniform",
1293 "ethernet-mpls-label-imposition-uniform",
1307 "ip4-mpls-label-imposition-pipe-no-ip-ttl-decr",
1312 "ip6-mpls-label-imposition-pipe-no-ip-ttl-decr",
1324 "ip4-mpls-label-imposition-uniform-no-ip-ttl-decr",
1329 "ip6-mpls-label-imposition-uniform-no-ip-ttl-decr",
static const char *const mpls_label_imp_pipe_ip6_nodes[]
dpo_lock_fn_t dv_lock
A reference counting lock function.
A virtual function table regisitered for a DPO type.
format_function_t format_mpls_header
static const char *const mpls_label_imp_pipe_no_ip_tll_decr_ip6_nodes[]
mpls_unicast_header_t hdr
The MPLS header imposed.
static const char *const mpls_label_imp_pipe_no_ip_tll_decr_ip4_nodes[]
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
static const char *const mpls_label_imp_pipe_ethernet_nodes[]
u8 * format_mpls_label_dpo(u8 *s, va_list *args)
vlib_node_registration_t ip4_mpls_label_imposition_uniform_no_ip_ttl_decr_node
(constructor) VLIB_REGISTER_NODE (ip4_mpls_label_imposition_uniform_no_ip_ttl_decr_node) ...
static uword mpls_label_imposition_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, const dpo_proto_t dproto, const mpls_label_dpo_flags_t flags)
#define pool_len(p)
Number of elements in pool vector.
vlib_node_registration_t ip4_mpls_label_imposition_pipe_no_ip_ttl_decr_node
(constructor) VLIB_REGISTER_NODE (ip4_mpls_label_imposition_pipe_no_ip_ttl_decr_node) ...
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
static index_t mpls_label_dpo_get_index(mpls_label_dpo_t *mld)
vlib_node_registration_t ip6_mpls_label_imposition_uniform_node
(constructor) VLIB_REGISTER_NODE (ip6_mpls_label_imposition_uniform_node)
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
static const char *const mpls_label_imp_uniform_no_ip_tll_decr_ip6_nodes[]
vlib_node_registration_t ip6_mpls_label_imposition_pipe_node
(constructor) VLIB_REGISTER_NODE (ip6_mpls_label_imposition_pipe_node)
#define MPLS_LABEL_DPO_MAX_N_LABELS
Maximum number of labels in one DPO.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static_always_inline u8 ip6_traffic_class_network_order(const ip6_header_t *ip6)
#define MPLS_LABEL_DEFAULT_EXP
The Default EXP added to MPLS label headers when no other value is available.
static const char *const mpls_label_imp_uniform_mpls_nodes[]
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u8 exp
TTL imposed - only valid for uniform LSPs.
static void vnet_mpls_uc_set_label(mpls_label_t *label_exp_s_ttl, u32 value)
static const char *const mpls_label_imp_pipe_mpls_nodes[]
enum mpls_label_dpo_flags_t_ mpls_label_dpo_flags_t
dpo_proto_t mld_payload_proto
The protocol of the payload/packets that are being encapped.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
#define FOR_EACH_MPLS_LABEL_DPO_ATTR(_item)
static void vnet_mpls_uc_set_exp(mpls_label_t *label_exp_s_ttl, u32 exp)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
VLIB_NODE_FUNCTION_MULTIARCH(mpls_mpls_label_imposition_pipe_node, mpls_mpls_label_imposition_pipe)
static const char *const *const mpls_label_imp_uniform_nodes[DPO_PROTO_NUM]
void mpls_label_dpo_create(fib_mpls_label_t *label_stack, mpls_eos_bit_t eos, dpo_proto_t payload_proto, mpls_label_dpo_flags_t flags, const dpo_id_t *parent, dpo_id_t *dpo)
Create an MPLS label object.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
Configuration for each label value in the output-stack.
vlib_node_registration_t ip4_mpls_label_imposition_pipe_node
(constructor) VLIB_REGISTER_NODE (ip4_mpls_label_imposition_pipe_node)
static uword mpls_mpls_label_imposition_pipe(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define MPLS_LABEL_DPO_ATTR_NAMES
static const char *const *const mpls_label_imp_pipe_nodes[DPO_PROTO_NUM]
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
const char * mpls_label_dpo_attr_names[]
Strings for the flags.
vlib_node_registration_t ip6_mpls_label_imposition_uniform_no_ip_ttl_decr_node
(constructor) VLIB_REGISTER_NODE (ip6_mpls_label_imposition_uniform_no_ip_ttl_decr_node) ...
static const char *const mpls_label_imp_uniform_no_ip_tll_decr_ip4_nodes[]
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
#define MPLS_LABEL_DPO_ATTR_MAX
vlib_node_registration_t ip6_mpls_label_imposition_pipe_no_ip_ttl_decr_node
(constructor) VLIB_REGISTER_NODE (ip6_mpls_label_imposition_pipe_no_ip_ttl_decr_node) ...
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
static const char *const mpls_label_imp_uniform_ethernet_nodes[]
u16 mld_n_hdr_bytes
Cached amount of header bytes to paint.
vlib_node_registration_t mpls_mpls_label_imposition_pipe_node
(constructor) VLIB_REGISTER_NODE (mpls_mpls_label_imposition_pipe_node)
vlib_node_registration_t mpls_mpls_label_imposition_uniform_node
(constructor) VLIB_REGISTER_NODE (mpls_mpls_label_imposition_uniform_node)
#define clib_warning(format, args...)
static mpls_label_dpo_t * mpls_label_dpo_get(index_t index)
static const char *const mpls_label_imp_uniform_ip6_nodes[]
#define clib_memcpy(a, b, c)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
mpls_label_t fml_value
The label value.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
static u8 ip_dscp_to_mpls_exp(u8 tos)
When in uniform mode convert an IPv[46] DSCP value to an MPLS EXP value.
void mpls_label_dpo_module_init(void)
static const char *const mpls_label_imp_uniform_ip4_nodes[]
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u8 mld_n_labels
Size of the label stack.
static void mpls_label_dpo_lock(dpo_id_t *dpo)
static mpls_unicast_header_t * mpls_label_paint_w_ttl(vlib_buffer_t *b0, mpls_label_dpo_t *mld0, u8 ttl0)
Paint on an MPLS label and fixup the TTL.
dpo_id_t mld_dpo
Next DPO in the graph.
u8 ttl
TTL imposed - only valid for uniform LSPs.
struct mpls_label_imposition_trace_t_ mpls_label_imposition_trace_t
A struct to hold tracing information for the MPLS label imposition node.
static mpls_unicast_header_t * mpls_label_paint_w_ttl_mpls_exp(vlib_buffer_t *b0, mpls_label_dpo_t *mld0, u8 ttl0, u8 exp0)
Paint on an MPLS label and fixup the TTL and EXP bits When the EXP bits are already bit shift to the ...
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static const char *const *const mpls_label_imp_uniform_no_ip_tll_decr_nodes[DPO_PROTO_NUM]
static void vnet_mpls_uc_set_s(mpls_label_t *label_exp_s_ttl, u32 eos)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject
mpls_unicast_header_t mld_hdr[MPLS_LABEL_DPO_MAX_N_LABELS]
The MPLS label header to impose.
vlib_node_registration_t ethernet_mpls_label_imposition_uniform_node
(constructor) VLIB_REGISTER_NODE (ethernet_mpls_label_imposition_uniform_node)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vlib_node_registration_t ethernet_mpls_label_imposition_pipe_node
(constructor) VLIB_REGISTER_NODE (ethernet_mpls_label_imposition_pipe_node)
index_t dpoi_index
the index of objects of that type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_registration_t ip4_mpls_label_imposition_uniform_node
(constructor) VLIB_REGISTER_NODE (ip4_mpls_label_imposition_uniform_node)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static mpls_unicast_header_t * mpls_label_paint_w_ttl_exp(vlib_buffer_t *b0, mpls_label_dpo_t *mld0, u8 ttl0, u8 exp0)
Paint on an MPLS label and fixup the TTL and EXP bits.
static void vnet_mpls_uc_set_ttl(mpls_label_t *label_exp_s_ttl, u32 ttl)
mpls_label_dpo_flags_t mld_flags
Flags.
static u8 * format_mpls_label_imposition_trace(u8 *s, va_list *args)
mpls_label_dpo_t * mpls_label_dpo_pool
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
u16 mld_locks
Number of locks/users of the label.
u8 fml_exp
EXP bits; valid only at imposition.
u16 dpoi_next_node
The next VLIB node to follow.
static const char *const *const mpls_label_imp_pipe_no_ip_tll_decr_nodes[DPO_PROTO_NUM]
#define CLIB_CACHE_LINE_BYTES
dpo_type_t mpls_label_dpo_get_type(mpls_label_dpo_flags_t flags)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
enum mpls_label_dpo_attr_t_ mpls_label_dpo_attr_t
Flags present on an MPLS label sourced path-extension.
static mpls_unicast_header_t * mpls_label_paint(vlib_buffer_t *b0, mpls_label_dpo_t *mld0)
static mpls_label_dpo_t * mpls_label_dpo_alloc(void)
u8 * format_mpls_label_dpo_flags(u8 *s, va_list *args)
Format the flags variable.
#define MPLS_LABEL_DEFAULT_TTL
The Default TTL added to MPLS label headers when no other value is available.
static void mpls_label_interpose(const dpo_id_t *original, const dpo_id_t *parent, dpo_id_t *clone)
Interpose a label DPO.
A struct to hold tracing information for the MPLS label imposition node.
static void mpls_label_dpo_unlock(dpo_id_t *dpo)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static const char *const mpls_label_imp_pipe_ip4_nodes[]
A representation of an MPLS label for imposition in the data-path.
static dpo_type_t mpls_label_dpo_types[1<< MPLS_LABEL_DPO_ATTR_MAX]
registered DPO types for each of the label sub-types.
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
enum mpls_eos_bit_t_ mpls_eos_bit_t
static uword pool_elts(void *v)
Number of active elements in a pool.