96 const void *dst_address)
124 muh[ii].
label_exp_s_ttl = clib_host_to_net_u32(muh[ii].label_exp_s_ttl);
141 muh[ii].
label_exp_s_ttl = clib_host_to_net_u32(muh[ii].label_exp_s_ttl);
159 sw_if_index = adj->rewrite_header.sw_if_index;
289 u32 dev_instance = va_arg (*args,
u32);
290 return format (s,
"mpls-tunnel%d", dev_instance);
296 u32 dev_instance = va_arg (*args,
u32);
299 return (
format (s,
"MPLS-tunnel: id %d\n", dev_instance));
334 u32 * from, * to_next, n_left_from, n_left_to_next;
349 while (n_left_from > 0)
357 while (n_left_from > 0 && n_left_to_next > 0)
381 to_next, n_left_to_next,
382 bi0, mt->mt_l2_tx_arc);
392 .name =
"MPLS tunnel device",
401 .name =
"MPLS-Tunnel",
465 memset (mt, 0,
sizeof (*mt));
486 mpls_tunnel_class.index,
488 mpls_tunnel_hw_interface_class.index,
540 memset(&rpath, 0,
sizeof(rpath));
552 else if (
unformat (line_input,
"add"))
554 else if (
unformat (line_input,
"out-label %U",
559 else if (
unformat (line_input,
"via %U %U",
569 else if (
unformat (line_input,
"via %U %U",
578 else if (
unformat (line_input,
"via %U",
587 else if (
unformat (line_input,
"via %U",
596 else if (
unformat (line_input,
"l2-only"))
640 .path =
"mpls tunnel",
642 "mpls tunnel via [addr] [interface] [out-labels]",
652 s =
format(s,
"mpls_tunnel%d: sw_if_index:%d hw_if_index:%d",
653 mt - mpls_tunnel_pool,
656 s =
format(s,
"\n label-stack:\n ");
661 s =
format(s,
"\n via:\n");
692 mt - mpls_tunnel_pool,
704 mt - mpls_tunnel_pool,
727 .path =
"show mpls tunnel",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u16 lb_n_buckets
number of buckets in the load-balance.
static u8 * format_mpls_tunnel_tx_trace(u8 *s, va_list *args)
fib_protocol_t frp_proto
The protocol of the address below.
ip46_address_t frp_addr
The next-hop address.
Contribute an object that is to be used to forward IP6 packets.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
void fib_path_list_child_remove(fib_node_index_t path_list_index, u32 si)
mpls_label_t * mt_label_stack
The Label stack to apply to egress packets.
u8 runtime_data[0]
Function dependent node-runtime data.
A representation of a path as described by a route producer.
vnet_main_t * vnet_get_main(void)
fib_node_index_t mt_path_list
The path-list over which the tunnel's destination is reachable.
void fib_node_init(fib_node_t *node, fib_node_type_t type)
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
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.
A uni-directional MPLS tunnel.
u32 mpls_label_t
A label value only, i.e.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
fib_protocol_t fib_path_list_get_proto(fib_node_index_t path_list_index)
#define MPLS_IETF_IMPLICIT_NULL_LABEL
static clib_error_t * mpls_tunnel_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
fib_node_t mt_node
The tunnel hooks into the FIB control plane graph.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Contribute an object that is to be used to forward IP4 packets.
#define STRUCT_OFFSET_OF(t, f)
unformat_function_t unformat_vnet_sw_interface
static uword mpls_tunnel_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
TX function.
static u8 * format_mpls_tunnel_name(u8 *s, va_list *args)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
const mpls_tunnel_t * mpls_tunnel_get(u32 mti)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u32 fib_path_list_child_add(fib_node_index_t path_list_index, fib_node_type_t child_type, fib_node_index_t child_index)
static u8 * format_mpls_tunnel_device(u8 *s, va_list *args)
void(* mpls_tunnel_walk_cb_t)(u32 index, void *ctx)
Callback function invoked while walking MPLS tunnels.
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
static fib_node_back_walk_rc_t mpls_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node.
unformat_function_t unformat_mpls_unicast_label
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, adj_midchain_flag_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
adj_index_t mt_l2_adj
If the tunnel is an L2 tunnel, this is the link type ETHERNET adjacency.
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
u32 frp_sw_if_index
The interface.
#define VLIB_INIT_FUNCTION(x)
static u32 * mpls_tunnel_db
DB of SW index to tunnel index.
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
VNET_HW_INTERFACE_CLASS(mpls_tunnel_hw_interface_class)
void fib_path_list_contribute_forwarding(fib_node_index_t path_list_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static u8 * format_mpls_tunnel(u8 *s, va_list *args)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
static void vnet_mpls_uc_set_label(mpls_label_t *label_exp_s_ttl, u32 value)
static void mpls_tunnel_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0)
Fixup the adj rewrite post encap.
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...
void vnet_mpls_tunnel_del(u32 sw_if_index)
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
fib_node_index_t fib_path_list_create(fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
dpo_type_t dpoi_type
the type
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
u32 mt_l2_tx_arc
on a L2 tunnel this is the VLIB arc from the L2-tx to the l2-midchain
load-balancing over a choice of [un]equal cost paths
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define FOR_EACH_FIB_PROTOCOL(_item)
static mpls_tunnel_t * mpls_tunnel_get_from_sw_if_index(u32 sw_if_index)
Get a tunnel object from a SW interface index.
u32 mt_sibling_index
sibling index on the path-list so notifications are received.
fib_node_type_t fn_type
The node's type.
#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.
An node in the FIB 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).
static adj_walk_rc_t mpls_adj_walk_cb(adj_index_t ai, void *ctx)
Call back when restacking all adjacencies on a MPLS interface.
u32 tunnel_id
Tunnel-id / index in tunnel vector.
VNET_DEVICE_CLASS(mpls_tunnel_class)
#define MPLS_LABEL_INVALID
#define vec_free(V)
Free vector's memory (no header).
u32 frp_weight
[un]equal cost path weight
static void mpls_tunnel_restack(mpls_tunnel_t *mt)
#define VLIB_BUFFER_IS_TRACED
u32 fib_node_index_t
A typedef of a node index.
void mpls_tunnel_walk(mpls_tunnel_walk_cb_t cb, void *ctx)
Walk all the MPLS tunnels.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u32 adj_index_t
An index for adjacencies.
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface.
static clib_error_t * mpls_tunnel_init(vlib_main_t *vm)
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
static mpls_tunnel_t * mpls_tunnel_pool
pool of tunnel instances
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
void vnet_mpls_tunnel_add(fib_route_path_t *rpaths, mpls_label_t *label_stack, u8 l2_only, u32 *sw_if_index)
Create a new MPLS tunnel.
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static load_balance_t * load_balance_get(index_t lbi)
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
u32 mt_hw_if_index
The HW interface index of the tunnel interfaces.
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
static void vnet_mpls_uc_set_s(mpls_label_t *label_exp_s_ttl, u32 eos)
static vlib_main_t * vlib_get_main(void)
static u8 * mpls_tunnel_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Build a rewrite string for the MPLS tunnel.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
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 u32 * mpls_tunnel_free_hw_if_indices
Pool of free tunnel SW indices - i.e.
static clib_error_t * vnet_create_mpls_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void mpls_tunnel_stack(adj_index_t ai)
mpls_tunnel_stack
u8 * fib_path_list_format(fib_node_index_t path_list_index, u8 *s)
struct mpls_tunnel_trace_t_ mpls_tunnel_trace_t
Packet trace structure.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
a point 2 point interface
static void mpls_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
A FIB graph nodes virtual function table.
static void vnet_mpls_uc_set_ttl(mpls_label_t *label_exp_s_ttl, u32 ttl)
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
u32 mt_sw_if_index
The SW interface index of the tunnel interfaces.
Contribute an object that is to be used to forward non-end-of-stack MPLS packets. ...
static fib_node_t * mpls_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
#define pool_foreach_index(i, v, body)
Iterate pool by index.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static fib_forward_chain_type_t mpls_tunnel_get_fwd_chain_type(const mpls_tunnel_t *mt)
Return true if the label stack is imp-null only.
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
const ip46_address_t zero_addr
static clib_error_t * show_mpls_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void mpls_tunnel_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
static mpls_tunnel_t * mpls_tunnel_from_fib_node(fib_node_t *node)
static uword pool_elts(void *v)
Number of active elements in a pool.