39 u32 next_index = va_arg (*args,
u32);
43 case VXLAN_INPUT_NEXT_DROP:
45 case VXLAN_INPUT_NEXT_L2_INPUT:
47 case VXLAN_INPUT_NEXT_IP4_INPUT:
49 case VXLAN_INPUT_NEXT_IP6_INPUT:
52 return format (s,
"unknown %d", next_index);
63 "[%d] %U (src) %U (dst) vni %d encap_fib_index %d",
75 u32 dev_instance = va_arg (*args,
u32);
76 return format (s,
"vxlan_tunnel%d", dev_instance);
83 clib_warning (
"you shouldn't be here, leaking buffers...");
111 uword max_rewrite_bytes)
118 u32 dev_instance = va_arg (*args,
u32);
119 s =
format (s,
"unimplemented dev %u", dev_instance);
129 #define foreach_copy_field \ 134 #define foreach_copy_ipv4 { \ 139 #define foreach_copy_ipv6 { \ 140 _(src.ip6.as_u64[0]) \ 141 _(src.ip6.as_u64[1]) \ 142 _(dst.ip6.as_u64[0]) \ 143 _(dst.ip6.as_u64[1]) \ 150 ip4_vxlan_header_t * h0;
151 int len =
sizeof (*h0);
155 h0 = (ip4_vxlan_header_t *) rw;
169 h0->udp.src_port = clib_host_to_net_u16 (4789);
170 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
183 ip6_vxlan_header_t * h0;
184 int len =
sizeof (*h0);
188 h0 = (ip6_vxlan_header_t *) rw;
202 h0->udp.src_port = clib_host_to_net_u16 (4789);
203 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
222 u32 hw_if_index = ~0;
223 u32 sw_if_index = ~0;
225 vxlan4_tunnel_key_t key4;
226 vxlan6_tunnel_key_t key6;
230 key4.src = a->
dst.ip4.as_u32;
231 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
235 key6.src.as_u64[0] = a->
dst.ip6.as_u64[0];
236 key6.src.as_u64[1] = a->
dst.ip6.as_u64[1];
237 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
246 return VNET_API_ERROR_TUNNEL_EXIST;
252 return VNET_API_ERROR_INVALID_DECAP_NEXT;
255 memset (t, 0,
sizeof (*t));
258 #define _(x) t->x = a->x; 319 (vnm, vxlan_device_class.index, t - vxm->
tunnels,
320 vxlan_hw_class.index, t - vxm->
tunnels);
362 return VNET_API_ERROR_NO_SUCH_ENTRY;
390 *sw_if_indexp = sw_if_index;
421 u32 * result = va_arg (*args,
u32 *);
425 *result = VXLAN_INPUT_NEXT_L2_INPUT;
427 *result = VXLAN_INPUT_NEXT_DROP;
429 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
431 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
432 else if (
unformat (input,
"%d", &tmp))
445 ip46_address_t src, dst;
451 u32 encap_fib_index = 0;
452 u32 decap_next_index = ~0;
468 else if (
unformat (line_input,
"src %U",
474 else if (
unformat (line_input,
"dst %U",
480 else if (
unformat (line_input,
"src %U",
486 else if (
unformat (line_input,
"dst %U",
492 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
498 if (encap_fib_index == ~0)
504 else if (
unformat (line_input,
"vni %d", &vni))
522 if (ipv4_set && ipv6_set)
525 if ((ipv4_set && memcmp(&src.ip4, &dst.ip4,
sizeof(src.ip4)) == 0) ||
526 (ipv6_set && memcmp(&src.ip6, &dst.ip6,
sizeof(src.ip6)) == 0))
532 memset (a, 0,
sizeof (*a));
537 #define _(x) a->x = x; 551 case VNET_API_ERROR_INVALID_DECAP_NEXT:
554 case VNET_API_ERROR_TUNNEL_EXIST:
557 case VNET_API_ERROR_NO_SUCH_ENTRY:
562 (0,
"vnet_vxlan_add_del_tunnel returned %d", rv);
590 .path =
"create vxlan tunnel",
592 "create vxlan tunnel src <local-vtep-addr> dst <remote-vtep-addr> vni <nn>" 593 " [encap-vrf-id <nn>] [decap-next [l2|ip4|ip6]] [del]",
611 vlib_cli_output (vm,
"%U", format_vxlan_tunnel, t);
628 .path =
"show vxlan tunnel",
629 .short_help =
"show vxlan tunnel",
644 sizeof(vxlan6_tunnel_key_t),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define hash_set(h, key, value)
l2_input_config_t * configs
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define hash_unset(h, key)
vnet_interface_main_t interface_main
clib_error_t * vxlan_init(vlib_main_t *vm)
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
static uword dummy_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
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)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vxlan6_tunnel_key_t * key6
#define hash_set_mem(h, key, value)
u32 * fib_index_by_sw_if_index
Table index indexed by software 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)
l2_output_next_nodes_st next_nodes
format_function_t format_vnet_sw_if_index_name
static clib_error_t * show_vxlan_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_copy_ipv6
vnet_main_t * vnet_get_main(void)
VNET_DEVICE_CLASS(vxlan_device_class, static)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
#define clib_warning(format, args...)
static clib_error_t * vxlan_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
#define hash_create_mem(elts, key_bytes, value_bytes)
#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)
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 foreach_copy_ipv4
#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)
l2output_main_t l2output_main
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
uword * fib_index_by_table_id
#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 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).
#define clib_memcpy(a, b, c)
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
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)
static u8 * format_vxlan_header_with_length(u8 *s, va_list *args)
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static void clib_mem_free(void *p)
uword * vxlan6_tunnel_by_key
vlib_node_registration_t vxlan_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_encap_node)
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.
static void * clib_mem_alloc(uword size)
#define foreach_copy_field
static int vxlan6_rewrite(vxlan_tunnel_t *t)
u32 * output_node_index_vec
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VXLAN_TUNNEL_IS_IPV4
u32 * tunnel_index_by_sw_if_index
#define hash_get_mem(h, key)
static u8 * format_decap_next(u8 *s, va_list *args)
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
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
u32 * fib_index_by_sw_if_index
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)
static uword pool_elts(void *v)
Number of active elements in a pool.