22 u32 next_index = va_arg (*args,
u32);
26 case VXLAN_INPUT_NEXT_DROP:
28 case VXLAN_INPUT_NEXT_L2_INPUT:
30 case VXLAN_INPUT_NEXT_IP4_INPUT:
32 case VXLAN_INPUT_NEXT_IP6_INPUT:
35 return format (s,
"unknown %d", next_index);
46 "[%d] %U (src) %U (dst) vni %d encap_fib_index %d",
58 u32 dev_instance = va_arg (*args,
u32);
59 return format (s,
"vxlan_tunnel%d", dev_instance);
66 clib_warning (
"you shouldn't be here, leaking buffers...");
94 uword max_rewrite_bytes)
101 u32 dev_instance = va_arg (*args,
u32);
102 s =
format (s,
"unimplemented dev %u", dev_instance);
112 #define foreach_copy_field \ 117 #define foreach_copy_ipv4 { \ 122 #define foreach_copy_ipv6 { \ 123 _(src.ip6.as_u64[0]) \ 124 _(src.ip6.as_u64[1]) \ 125 _(dst.ip6.as_u64[0]) \ 126 _(dst.ip6.as_u64[1]) \ 133 ip4_vxlan_header_t * h0;
134 int len =
sizeof (*h0);
138 h0 = (ip4_vxlan_header_t *) rw;
152 h0->udp.src_port = clib_host_to_net_u16 (4789);
153 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
166 ip6_vxlan_header_t * h0;
167 int len =
sizeof (*h0);
171 h0 = (ip6_vxlan_header_t *) rw;
185 h0->udp.src_port = clib_host_to_net_u16 (4789);
186 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
205 u32 hw_if_index = ~0;
206 u32 sw_if_index = ~0;
208 vxlan4_tunnel_key_t key4;
209 vxlan6_tunnel_key_t key6;
212 key4.src = a->
dst.ip4.as_u32;
213 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
217 key6.src.as_u64[0] = a->
dst.ip6.as_u64[0];
218 key6.src.as_u64[1] = a->
dst.ip6.as_u64[1];
219 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
228 return VNET_API_ERROR_TUNNEL_EXIST;
234 return VNET_API_ERROR_INVALID_DECAP_NEXT;
237 memset (t, 0,
sizeof (*t));
240 #define _(x) t->x = a->x; 301 (vnm, vxlan_device_class.index, t - vxm->
tunnels,
302 vxlan_hw_class.index, t - vxm->
tunnels);
335 return VNET_API_ERROR_NO_SUCH_ENTRY;
368 *sw_if_indexp = sw_if_index;
399 u32 * result = va_arg (*args,
u32 *);
403 *result = VXLAN_INPUT_NEXT_L2_INPUT;
405 *result = VXLAN_INPUT_NEXT_DROP;
407 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
409 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
410 else if (
unformat (input,
"%d", &tmp))
423 ip46_address_t src, dst;
429 u32 encap_fib_index = 0;
430 u32 decap_next_index = ~0;
445 else if (
unformat (line_input,
"src %U",
451 else if (
unformat (line_input,
"dst %U",
457 else if (
unformat (line_input,
"src %U",
463 else if (
unformat (line_input,
"dst %U",
469 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
475 if (encap_fib_index == ~0)
481 else if (
unformat (line_input,
"vni %d", &vni))
499 if (ipv4_set && ipv6_set)
502 if ((ipv4_set && memcmp(&src.ip4, &dst.ip4,
sizeof(src.ip4)) == 0) ||
503 (ipv6_set && memcmp(&src.ip6, &dst.ip6,
sizeof(src.ip6)) == 0))
509 memset (a, 0,
sizeof (*a));
514 #define _(x) a->x = x; 526 case VNET_API_ERROR_INVALID_DECAP_NEXT:
529 case VNET_API_ERROR_TUNNEL_EXIST:
532 case VNET_API_ERROR_NO_SUCH_ENTRY:
537 (0,
"vnet_vxlan_add_del_tunnel returned %d", rv);
544 .path =
"create vxlan tunnel",
546 "create vxlan tunnel src <local-vtep-addr> dst <remote-vtep-addr> vni <nn>" 547 " [encap-vrf-id <nn>] [decap-next [l2|ip4|ip6] [del]\n",
564 vlib_cli_output (vm,
"%U", format_vxlan_tunnel, t);
571 .path =
"show vxlan tunnel",
579 ip4_vxlan_header_t * hdr4;
581 ip6_vxlan_header_t * hdr6;
589 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)
always_inline void clib_mem_free(void *p)
static u32 fib4_index_from_fib_id(u32 fib_id)
#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
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 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
#define vxlan4_dummy_rewrite
vnet_main_t * vnet_get_main(void)
VNET_DEVICE_CLASS(vxlan_device_class, static)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
always_inline uword pool_elts(void *v)
#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)
#define hash_unset_mem(h, key)
uword * fib_index_by_table_id
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
vlib_simple_counter_main_t * sw_if_counters
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
always_inline u16 ip4_header_checksum(ip4_header_t *i)
uword * fib_index_by_table_id
#define pool_get_aligned(P, E, A)
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
#define vxlan6_dummy_rewrite
always_inline void * clib_mem_alloc(uword size)
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)
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VLIB_CLI_COMMAND(x,...)
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
uword * vxlan6_tunnel_by_key
vlib_node_registration_t vxlan_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_encap_node)
always_inline void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
#define foreach_copy_field
static int vxlan6_rewrite(vxlan_tunnel_t *t)
#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)
always_inline void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
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
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)