32 memset(mld, 0,
sizeof(*mld));
42 return (mld - mpls_label_dpo_pool);
115 u32 indent = va_arg (*args,
u32);
120 s =
format(s,
"mpls-label:[%d]:", index);
205 ((
char*)hdr0)[3] = ttl0;
216 u8 payload_is_ethernet)
218 u32 n_left_from, next_index, * from, * to_next;
225 while (n_left_from > 0)
231 while (n_left_from >= 8 && n_left_to_next >= 4)
233 u32 bi0, mldi0, bi1, mldi1, bi2, mldi2, bi3, mldi3;
237 u32 next0, next1, next2, next3;
238 u8 ttl0, ttl1,ttl2, ttl3 ;
240 bi0 = to_next[0] = from[0];
241 bi1 = to_next[1] = from[1];
242 bi2 = to_next[2] = from[2];
243 bi3 = to_next[3] = from[3];
299 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
300 checksum1 = ip1->
checksum + clib_host_to_net_u16 (0x0100);
301 checksum2 = ip2->
checksum + clib_host_to_net_u16 (0x0100);
302 checksum3 = ip3->
checksum + clib_host_to_net_u16 (0x0100);
304 checksum0 += checksum0 >= 0xffff;
305 checksum1 += checksum1 >= 0xffff;
306 checksum2 += checksum2 >= 0xffff;
307 checksum3 += checksum3 >= 0xffff;
324 else if (payload_is_ip6)
344 else if (payload_is_ethernet)
349 ttl0 = ttl1 = ttl2 = ttl3 = 255;
453 next0, next1, next2, next3);
456 while (n_left_from > 0 && n_left_to_next > 0)
486 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
487 checksum0 += checksum0 >= 0xffff;
493 else if (payload_is_ip6)
538 ((
char*)hdr0)[3] = ttl;
551 n_left_to_next, bi0, next0);
571 s =
format (s,
"%Umpls-header:%U",
587 .name =
"mpls-label-imposition",
588 .vector_size =
sizeof (
u32),
608 .function = ip4_mpls_label_imposition,
609 .name =
"ip4-mpls-label-imposition",
610 .vector_size =
sizeof (
u32),
619 ip4_mpls_label_imposition)
630 .function = ip6_mpls_label_imposition,
631 .name =
"ip6-mpls-label-imposition",
632 .vector_size =
sizeof (
u32),
641 ip6_mpls_label_imposition)
652 .function = ethernet_mpls_label_imposition,
653 .name =
"ethernet-mpls-label-imposition",
654 .vector_size =
sizeof (
u32),
663 ethernet_mpls_label_imposition)
666 mpls_label_dpo_mem_show (
void)
678 .dv_mem_show = mpls_label_dpo_mem_show,
683 "ip4-mpls-label-imposition",
688 "ip6-mpls-label-imposition",
693 "mpls-label-imposition",
698 "ethernet-mpls-label-imposition",
dpo_lock_fn_t dv_lock
A reference counting lock function.
static const char *const mpls_label_imp_ip6_nodes[]
VLIB_NODE_FUNCTION_MULTIARCH(mpls_label_imposition_node, mpls_label_imposition)
A virtual function table regisitered for a DPO type.
static const char *const mpls_label_imp_mpls_nodes[]
format_function_t format_mpls_header
mpls_unicast_header_t hdr
The MPLS header imposed.
static const char *const mpls_label_imp_ethernet_nodes[]
u32 mpls_label_t
A label value only, i.e.
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.
u8 * format_mpls_label_dpo(u8 *s, va_list *args)
#define pool_len(p)
Number of elements in pool vector.
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
index_t mpls_label_dpo_create(mpls_label_t *label_stack, mpls_eos_bit_t eos, u8 ttl, u8 exp, dpo_proto_t payload_proto, const dpo_id_t *dpo)
Create an MPLS label object.
static index_t mpls_label_dpo_get_index(mpls_label_dpo_t *mld)
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
#define MPLS_LABEL_DPO_MAX_N_LABELS
Maximum number of labels in one DPO.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
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.
static void vnet_mpls_uc_set_label(mpls_label_t *label_exp_s_ttl, u32 value)
dpo_proto_t mld_payload_proto
The protocol of the payload/packets that are being encapped.
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...
static mpls_unicast_header_t * mpls_label_paint(vlib_buffer_t *b0, mpls_label_dpo_t *mld0, u8 ttl0)
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.
#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).
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
#define CLIB_PREFETCH(addr, size, type)
u16 mld_n_hdr_bytes
Cached amount of header bytes to paint.
vlib_node_registration_t ethernet_mpls_label_imposition_node
(constructor) VLIB_REGISTER_NODE (ethernet_mpls_label_imposition_node)
u16 mld_n_labels
Size of the label stack.
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
static mpls_label_dpo_t * mpls_label_dpo_get(index_t index)
#define clib_memcpy(a, b, c)
vlib_node_registration_t mpls_label_imposition_node
(constructor) VLIB_REGISTER_NODE (mpls_label_imposition_node)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
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 mpls_label_dpo_module_init(void)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void mpls_label_dpo_lock(dpo_id_t *dpo)
dpo_id_t mld_dpo
Next DPO in the graph.
struct mpls_label_imposition_trace_t_ mpls_label_imposition_trace_t
A struct to hold tracing information for the MPLS label imposition node.
vlib_node_registration_t ip6_mpls_label_imposition_node
(constructor) VLIB_REGISTER_NODE (ip6_mpls_label_imposition_node)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
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.
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 ip4_mpls_label_imposition_node
(constructor) VLIB_REGISTER_NODE (ip4_mpls_label_imposition_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)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void vnet_mpls_uc_set_ttl(mpls_label_t *label_exp_s_ttl, u32 ttl)
#define VLIB_REGISTER_NODE(x,...)
static const char *const *const mpls_label_imp_nodes[DPO_PROTO_NUM]
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.
u16 dpoi_next_node
The next VLIB node to follow.
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static mpls_label_dpo_t * mpls_label_dpo_alloc(void)
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.
A representation of an MPLS label for imposition in the data-path.
static uword mpls_label_imposition_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 payload_is_ip4, u8 payload_is_ip6, u8 payload_is_ethernet)
static const char *const mpls_label_imp_ip4_nodes[]
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 mpls_label_imposition(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword pool_elts(void *v)
Number of active elements in a pool.