43 u32 next_index = va_arg (*args,
u32);
47 case VXLAN_INPUT_NEXT_DROP:
49 case VXLAN_INPUT_NEXT_L2_INPUT:
52 return format (s,
"index %d", next_index);
62 s =
format (s,
"[%d] src %U dst %U vni %d sw_if_index %d ",
71 s =
format (s,
"encap_fib_index %d fib_entry_index %d decap_next %U\n",
79 u32 dev_instance = va_arg (*args,
u32);
80 return format (s,
"vxlan_tunnel%d", dev_instance);
87 clib_warning (
"you shouldn't be here, leaking buffers...");
112 u32 dev_instance = va_arg (*args,
u32);
113 s =
format (s,
"unimplemented dev %u", dev_instance);
197 #define foreach_copy_field \ 199 _(mcast_sw_if_index) \ 201 _(decap_next_index) \ 209 ip4_vxlan_header_t * h0;
210 int len =
sizeof (*h0);
214 h0 = (ip4_vxlan_header_t *) rw;
228 h0->udp.src_port = clib_host_to_net_u16 (4789);
229 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
242 ip6_vxlan_header_t * h0;
243 int len =
sizeof (*h0);
247 h0 = (ip6_vxlan_header_t *) rw;
261 h0->udp.src_port = clib_host_to_net_u16 (4789);
262 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
361 u32 hw_if_index = ~0;
362 u32 sw_if_index = ~0;
364 vxlan4_tunnel_key_t key4;
365 vxlan6_tunnel_key_t key6;
370 key4.src = a->
dst.ip4.as_u32;
371 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
376 key6.src.as_u64[0] = a->
dst.ip6.as_u64[0];
377 key6.src.as_u64[1] = a->
dst.ip6.as_u64[1];
378 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
388 return VNET_API_ERROR_TUNNEL_EXIST;
394 return VNET_API_ERROR_INVALID_DECAP_NEXT;
397 memset (t, 0,
sizeof (*t));
400 #define _(x) t->x = a->x; 454 (vnm, vxlan_device_class.index, t - vxm->
tunnels,
455 vxlan_hw_class.index, t - vxm->
tunnels);
474 u32 encap_index = !is_ip6 ?
512 ip46_address_t * dst_copy =
clib_mem_alloc (
sizeof(ip46_address_t));
543 return VNET_API_ERROR_NO_SUCH_ENTRY;
571 ip46_address_t * ip = ep->
ip;
584 *sw_if_indexp = sw_if_index;
617 uword next_index = ~0;
633 u32 * result = va_arg (*args,
u32 *);
634 u32 ipv4_set = va_arg (*args,
int);
641 *result = VXLAN_INPUT_NEXT_L2_INPUT;
644 else if (
unformat (input,
"%d", &tmp))
657 ip46_address_t src , dst;
664 u32 encap_fib_index = 0;
665 u32 mcast_sw_if_index = ~0;
666 u32 decap_next_index = VXLAN_INPUT_NEXT_L2_INPUT;
671 u32 tunnel_sw_if_index;
674 memset(&src, 0,
sizeof src);
675 memset(&dst, 0,
sizeof dst);
686 else if (
unformat (line_input,
"src %U",
692 else if (
unformat (line_input,
"dst %U",
698 else if (
unformat (line_input,
"src %U",
704 else if (
unformat (line_input,
"dst %U",
710 else if (
unformat (line_input,
"group %U %U",
715 grp_set = dst_set = 1;
718 else if (
unformat (line_input,
"group %U %U",
723 grp_set = dst_set = 1;
726 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
732 if (encap_fib_index == ~0)
736 &decap_next_index, ipv4_set))
738 else if (
unformat (line_input,
"vni %d", &vni))
762 if (grp_set && mcast_sw_if_index == ~0)
765 if (ipv4_set && ipv6_set)
771 if (decap_next_index == ~0)
777 memset (a, 0,
sizeof (*a));
782 #define _(x) a->x = x; 796 case VNET_API_ERROR_TUNNEL_EXIST:
799 case VNET_API_ERROR_NO_SUCH_ENTRY:
804 (0,
"vnet_vxlan_add_del_tunnel returned %d", rv);
832 .path =
"create vxlan tunnel",
834 "create vxlan tunnel src <local-vtep-addr>" 835 " {dst <remote-vtep-addr>|group <mcast-vtep-addr> <intf-name>} vni <nn>" 836 " [encap-vrf-id <nn>] [decap-next [l2|node <name>]] [del]",
854 vlib_cli_output (vm,
"%U", format_vxlan_tunnel, t);
871 .path =
"show vxlan tunnel",
872 .short_help =
"show vxlan tunnel",
887 sizeof(vxlan6_tunnel_key_t),
890 sizeof(ip46_address_t),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
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.
Recursive resolution source.
Contribute an object that is to be used to forward IP6 packets.
#define hash_set(h, key, value)
l2_input_config_t * configs
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
mcast_remote_t * mcast_eps
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define hash_unset(h, key)
static uword ip46_address_is_multicast(ip46_address_t *a)
vnet_interface_main_t interface_main
clib_error_t * vxlan_init(vlib_main_t *vm)
void fib_node_init(fib_node_t *node, fib_node_type_t type)
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
adj_index_t adj_rewrite_add_and_lock(fib_protocol_t nh_proto, vnet_link_t link_type, u32 sw_if_index, u8 *rewrite)
adj_rewrite_add_and_lock
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
static int vxlan_check_decap_next(vxlan_main_t *vxm, u32 is_ip6, u32 decap_next_index)
static u32 fib4_index_from_fib_id(u32 fib_id)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vxlan6_tunnel_key_t * key6
Contribute an object that is to be used to forward IP4 packets.
#define hash_set_mem(h, key, value)
#define STRUCT_OFFSET_OF(t, f)
void fib_node_deinit(fib_node_t *node)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
static u32 fib6_index_from_fib_id(u32 fib_id)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static vxlan_tunnel_t * vxlan_tunnel_from_fib_node(fib_node_t *node)
#define ip46_address_cmp(ip46_1, ip46_2)
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * show_vxlan_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static fib_node_back_walk_rc_t vxlan_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node - Here we will restack the new dpo of VXLAN DIP to encap n...
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
vnet_main_t * vnet_get_main(void)
vnet_flood_class_t flood_class
VNET_DEVICE_CLASS(vxlan_device_class, static)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static void mcast_ep_add(mcast_remote_t *new_ep)
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
static void ip46_multicast_ethernet_address(u8 *ethernet_address, ip46_address_t *ip)
Aggregrate type for a prefix.
static void vxlan_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
static void mcast_ep_remove(mcast_remote_t *ep)
#define clib_warning(format, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
static clib_error_t * vxlan_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_node_t node
Linkage into the FIB object graph.
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define hash_create_mem(elts, key_bytes, value_bytes)
#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.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
#define hash_unset_mem(h, key)
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, adj_index_t adj_index)
Add a 'special' entry to the FIB that links to the adj passed A special entry is an entry that the FI...
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
static clib_error_t * vxlan_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
uword * vxlan4_tunnel_by_key
#define pool_put(P, E)
Free an object E in pool P.
vlib_simple_counter_main_t * sw_if_counters
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
static uword vtep_addr_unref(ip46_address_t *ip)
uword * fib_index_by_table_id
#define ip46_address_is_ip4(ip46)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
static void ip4_multicast_ethernet_address(u8 *ethernet_address, ip4_address_t *a)
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int vxlan4_rewrite(vxlan_tunnel_t *t)
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define clib_memcpy(a, b, c)
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
u32 fib_node_index_t
A typedef of a node index.
static void vnet_set_vni_and_flags(vxlan_header_t *h, u32 vni)
static uword unformat_decap_next(unformat_input_t *input, va_list *args)
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
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.
u8 * default_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Return a complete, zero-length (aka dummy) rewrite.
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
static u8 * format_vxlan_header_with_length(u8 *s, va_list *args)
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static void vxlan_tunnel_restack_dpo(vxlan_tunnel_t *t)
static fib_node_t * vxlan_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
static void clib_mem_free(void *p)
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
uword * vxlan6_tunnel_by_key
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static uword get_decap_next_for_node(u32 node_index, u32 ipv4_set)
static void * clib_mem_alloc(uword size)
static uword vtep_addr_ref(ip46_address_t *ip)
adj_index_t mcast_adj_index
#define foreach_copy_field
static int vxlan6_rewrite(vxlan_tunnel_t *t)
static mcast_remote_t * mcast_ep_get(ip46_address_t *ip)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
fib_node_index_t fib_entry_index
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
unformat_function_t unformat_vlib_node
u32 * tunnel_index_by_sw_if_index
#define hash_get_mem(h, key)
A FIB graph nodes virtual function table.
static u8 * format_decap_next(u8 *s, va_list *args)
vlib_node_registration_t vxlan4_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan4_encap_node)
ip4_main_t ip4_main
Global ip4 main structure.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
vlib_node_registration_t vxlan6_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan6_encap_node)
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static void ip6_multicast_ethernet_address(u8 *ethernet_address, u32 group_id)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
vxlan4_tunnel_key_t * key4
#define clib_error_return(e, args...)
VNET_HW_INTERFACE_CLASS(vxlan_hw_class)
#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)
#define CLIB_CACHE_LINE_BYTES
static u16 ip4_header_checksum(ip4_header_t *i)
u32 * free_vxlan_tunnel_hw_if_indices
u8 * format_vxlan_tunnel(u8 *s, va_list *args)
static u8 * format_vxlan_name(u8 *s, va_list *args)
fib_node_index_t fib_entry_index
static uword pool_elts(void *v)
Number of active elements in a pool.