85 const void *dst_address)
241 sw_if_index = adj->rewrite_header.sw_if_index;
291 mt - mpls_tunnel_pool);
442 u32 dev_instance = va_arg (*args,
u32);
443 return format (s,
"mpls-tunnel%d", dev_instance);
449 u32 dev_instance = va_arg (*args,
u32);
452 return (
format (s,
"MPLS-tunnel: id %d\n", dev_instance));
487 u32 * from, * to_next, n_left_from, n_left_to_next;
502 while (n_left_from > 0)
510 while (n_left_from > 0 && n_left_to_next > 0)
539 to_next, n_left_to_next,
550 .name =
"MPLS tunnel device",
559 .name =
"MPLS-Tunnel",
634 mpls_tunnel_class.index,
636 mpls_tunnel_hw_interface_class.index,
789 return (mt - mpls_tunnel_pool);
799 u8 is_del = 0, l2_only = 0, is_multicast =0;
817 else if (
unformat (line_input,
"add %U",
821 else if (
unformat (line_input,
"add"))
823 else if (
unformat (line_input,
"l2-only"))
825 else if (
unformat (line_input,
"multicast"))
827 else if (
unformat (line_input,
"via %U",
829 &rpath, &payload_proto))
859 if (~0 == sw_if_index)
882 .path =
"mpls tunnel",
884 "mpls tunnel [multicast] [l2-only] via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
894 s =
format(s,
"mpls-tunnel%d: sw_if_index:%d hw_if_index:%d",
895 mt - mpls_tunnel_pool,
899 s =
format(s,
" \n flags:");
906 s =
format(s,
"\n via:\n");
913 s =
format(s,
" forwarding: %U\n",
946 mt - mpls_tunnel_pool,
958 mt - mpls_tunnel_pool,
981 .path =
"show mpls tunnel",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
int fib_path_is_resolved(fib_node_index_t path_index)
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
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 u8 * format_mpls_tunnel_tx_trace(u8 *s, va_list *args)
fib_forward_chain_type_t fib_forw_chain_type_from_link_type(vnet_link_t link_type)
Convert from a adjacency's link type to chain type.
static void mpls_tunnel_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Fixup the adj rewrite post encap.
void fib_path_list_child_remove(fib_node_index_t path_list_index, u32 si)
u8 runtime_data[0]
Function dependent node-runtime data.
A representation of a path as described by a route producer.
static fib_path_list_walk_rc_t mpls_tunnel_collect_forwarding(fib_node_index_t pl_index, fib_node_index_t path_index, void *arg)
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)
uword unformat_fib_route_path(unformat_input_t *input, va_list *args)
Unformat a fib_route_path_t from CLI input.
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
#define FOR_EACH_MPLS_TUNNEL_ATTRIBUTE(_item)
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
mpls_tunnel_flags_t mt_flags
Tunnel flags.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
An MPLS extension that maintains the path's outgoing labels,.
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
A uni-directional MPLS tunnel.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
dpo_proto_t fib_forw_chain_type_to_dpo_proto(fib_forward_chain_type_t fct)
Convert from a chain type to the DPO proto it will install.
This packet is to be rewritten and forwarded to the next processing node.
static clib_error_t * mpls_tunnel_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
struct mpls_tunnel_collect_forwarding_ctx_t_ mpls_tunnel_collect_forwarding_ctx_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
fib_node_t mt_node
The tunnel hooks into the FIB control plane graph.
void fib_path_list_walk(fib_node_index_t path_list_index, fib_path_list_walk_fn_t func, void *ctx)
#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)
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.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
vnet_link_t ia_link
link/ether-type 1 bytes
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
Adjacency to punt this packet.
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.
vl_api_interface_index_t sw_if_index
#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)
#define clib_error_return(e, args...)
fib_path_ext_list_t mt_path_exts
A vector of path extensions o hold the label stack for each path.
void load_balance_multipath_update(const dpo_id_t *dpo, const load_balance_path_t *raw_nhs, load_balance_flags_t flags)
Contribute an object that is to be used to forward Ethernet packets.
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
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)
#define MPLS_TUNNEL_ATTRIBUTES
fib_path_ext_t * fib_path_ext_list_find_by_path_index(const fib_path_ext_list_t *list, fib_node_index_t path_index)
fib_path_ext_mpls_flags_t fpe_mpls_flags
For an MPLS type extension.
fib_node_index_t fib_path_list_copy_and_path_add(fib_node_index_t orig_path_list_index, fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
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)
Delete an MPLS tunnel.
#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 const char * mpls_tunnel_attribute_names[]
MPLS tunnel flags strings.
int vnet_mpls_tunnel_get_index(u32 sw_if_index)
return the tunnel index from the sw_if_index
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
load-balancing over a choice of [un]equal cost paths
#define MPLS_FLOW_HASH_DEFAULT
There are no options for controlling the MPLS flow hash.
#define pool_put(P, E)
Free an object E in pool P.
#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.
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
void fib_path_list_lock(fib_node_index_t path_list_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.
fib_node_index_t fib_path_list_copy_and_path_remove(fib_node_index_t orig_path_list_index, fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
u32 tunnel_id
Tunnel-id / index in tunnel vector.
Adjacency to drop this packet.
static u8 * mpls_tunnel_build_rewrite_i(void)
Build a rewrite string for the MPLS tunnel.
VNET_DEVICE_CLASS(mpls_tunnel_class)
#define vec_free(V)
Free vector's memory (no header).
Multicast Midchain Adjacency.
static void mpls_tunnel_restack(mpls_tunnel_t *mt)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
void fib_path_ext_list_remove(fib_path_ext_list_t *list, fib_path_ext_type_t ext_type, const fib_route_path_t *rpath)
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
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 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 adj_mcast_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite, u8 offset, u32 mask)
adj_mcast_midchain_update_rewrite
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.
void fib_path_list_unlock(fib_node_index_t path_list_index)
index_t replicate_create(u32 n_buckets, dpo_proto_t rep_proto)
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.
vlib_main_t vlib_node_runtime_t * node
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
This packets follow a mid-chain adjacency.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u32 vnet_mpls_tunnel_create(u8 l2_only, u8 is_multicast)
Create a new MPLS tunnel.
int vnet_mpls_tunnel_path_remove(u32 sw_if_index, fib_route_path_t *rpaths)
remove a path from a tunnel.
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
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.
u8 * format_fib_forw_chain_type(u8 *s, va_list *args)
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
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)
This packets needs to go to ICMP error.
This packet is for one of our own IP addresses.
enum fib_path_list_walk_rc_t_ fib_path_list_walk_rc_t
return code to control pat-hlist walk
void vnet_mpls_tunnel_path_add(u32 sw_if_index, fib_route_path_t *rpaths)
Add a path to an MPLS tunnel.
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
void fib_path_ext_list_resolve(fib_path_ext_list_t *list, fib_node_index_t path_list_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
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
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
VLIB buffer representation.
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.
One path from an [EU]CMP set that the client wants to add to a load-balance object.
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
A FIB graph nodes virtual function table.
load_balance_path_t * next_hops
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
A path extension is a per-entry addition to the forwarding information when packets are sent for that...
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u8 * format_fib_path_ext_list(u8 *s, va_list *args)
u32 mt_sw_if_index
The SW interface index of the tunnel interfaces.
dpo_id_t mt_l2_lb
If the tunnel is an L2 tunnel, this is the link type ETHERNET load-balance.
static fib_node_t * mpls_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
u16 dpoi_next_node
The next VLIB node to follow.
enum mpls_tunnel_attribute_t_ mpls_tunnel_attribute_t
#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)
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.
static clib_error_t * show_mpls_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_forward_chain_type_t fct
fib_path_ext_t * fib_path_ext_list_insert(fib_path_ext_list_t *list, fib_node_index_t path_list_index, fib_path_ext_type_t ext_type, const fib_route_path_t *rpath)
static void mpls_tunnel_mk_lb(mpls_tunnel_t *mt, vnet_link_t linkt, fib_forward_chain_type_t fct, dpo_id_t *dpo_lb)
load_balance_path_t * fib_path_ext_stack(fib_path_ext_t *path_ext, fib_forward_chain_type_t child_fct, fib_forward_chain_type_t imp_null_fct, load_balance_path_t *nhs)
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.