24 s =
format (s,
"[%d] local: %U remote: %U ",
31 case VXLAN_GPE_PROTOCOL_IP4:
32 s =
format (s,
"next-protocol ip4");
34 case VXLAN_GPE_PROTOCOL_IP6:
35 s =
format (s,
"next-protocol ip6");
37 case VXLAN_GPE_PROTOCOL_ETHERNET:
38 s =
format (s,
"next-protocol ethernet");
40 case VXLAN_GPE_PROTOCOL_NSH:
41 s =
format (s,
"next-protocol nsh");
47 s =
format (s,
" fibs: (encap %d, decap %d)",
60 u32 show_dev_instance = ~0;
65 if (show_dev_instance != ~0)
66 i = show_dev_instance;
68 return format (s,
"vxlan_gpe_tunnel%d", i);
87 clib_warning (
"you shouldn't be here, leaking buffers...");
96 uword max_rewrite_bytes)
111 u32 dev_instance = va_arg (*args,
u32);
112 s =
format (s,
"unimplemented dev %u", dev_instance);
123 #define foreach_gpe_copy_field \ 131 #define foreach_copy_field \ 145 ip4_vxlan_gpe_header_t * h0;
152 h0 = (ip4_vxlan_gpe_header_t *) rw;
166 h0->udp.src_port = clib_host_to_net_u16 (4790);
167 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
172 h0->vxlan.protocol = VXLAN_GPE_PROTOCOL_IP4;
173 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni<<8);
187 u32 hw_if_index = ~0;
188 u32 sw_if_index = ~0;
190 vxlan_gpe_tunnel_key_t key, *key_copy;
195 key.vni = clib_host_to_net_u32 (a->
vni << 8);
204 return VNET_API_ERROR_INVALID_VALUE;
207 return VNET_API_ERROR_INVALID_DECAP_NEXT;
210 memset (t, 0,
sizeof (*t));
213 #define _(x) t->x = a->x; 244 (vnm, vxlan_gpe_device_class.index, t - gm->
tunnels,
245 vxlan_gpe_hw_class.index, t - gm->
tunnels);
260 return VNET_API_ERROR_NO_SUCH_ENTRY;
268 key_copy = (
void *)(hp->
key);
277 *sw_if_indexp = sw_if_index;
296 u32 * result = va_arg (*args,
u32 *);
300 *result = VXLAN_GPE_INPUT_NEXT_DROP;
302 *result = VXLAN_GPE_INPUT_NEXT_IP4_INPUT;
304 *result = VXLAN_GPE_INPUT_NEXT_IP6_INPUT;
305 else if (
unformat (input,
"ethernet"))
306 *result = VXLAN_GPE_INPUT_NEXT_ETHERNET_INPUT;
307 else if (
unformat (input,
"%d", &tmp))
324 u32 encap_fib_index = 0;
325 u32 decap_fib_index = 0;
326 u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
327 u32 decap_next_index = VXLAN_GPE_INPUT_NEXT_IP4_INPUT;
341 else if (
unformat (line_input,
"local %U",
344 else if (
unformat (line_input,
"remote %U",
347 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
350 if (encap_fib_index == ~0)
353 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
356 if (decap_fib_index == ~0)
362 else if (
unformat (line_input,
"vni %d", &vni))
364 else if (
unformat(line_input,
"next-ip4"))
365 protocol = VXLAN_GPE_PROTOCOL_IP4;
366 else if (
unformat(line_input,
"next-ip6"))
367 protocol = VXLAN_GPE_PROTOCOL_IP6;
368 else if (
unformat(line_input,
"next-ethernet"))
369 protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
370 else if (
unformat(line_input,
"next-nsh"))
371 protocol = VXLAN_GPE_PROTOCOL_NSH;
388 memset (a, 0,
sizeof (*a));
392 #define _(x) a->x = x; 402 case VNET_API_ERROR_INVALID_DECAP_NEXT:
405 case VNET_API_ERROR_TUNNEL_EXIST:
408 case VNET_API_ERROR_NO_SUCH_ENTRY:
413 (0,
"vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
420 .path =
"create vxlan-gpe tunnel",
422 "create vxlan-gpe tunnel local <ip4-addr> remote <ip4-addr>" 423 " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]" 424 " [encap-vrf-id <nn>] [decap-vrf-id <nn>]" 442 vlib_cli_output (vm,
"%U", format_vxlan_gpe_tunnel, t);
449 .path =
"show vxlan-gpe",
sll srl srl sll sra u16x4 i
clib_error_t * vxlan_gpe_init(vlib_main_t *vm)
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline void clib_mem_free(void *p)
vlib_node_registration_t vxlan_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_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)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define hash_set_mem(h, key, value)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
#define VXLAN_GPE_FLAGS_P
#define VXLAN_GPE_VERSION
#define VXLAN_GPE_FLAGS_I
#define foreach_gpe_copy_field
vnet_main_t * vnet_get_main(void)
static int vxlan_gpe_rewrite(vxlan_gpe_tunnel_t *t)
u8 * format_vxlan_gpe_tunnel(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
static u8 * format_vxlan_gpe_header_with_length(u8 *s, va_list *args)
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
always_inline uword pool_elts(void *v)
#define clib_warning(format, args...)
#define hash_get_pair(h, key)
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 int vxlan_gpe_name_renumber(vnet_hw_interface_t *hi, u32 new_dev_instance)
vxlan_gpe_main_t vxlan_gpe_main
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
always_inline u16 ip4_header_checksum(ip4_header_t *i)
#define pool_get_aligned(P, E, A)
always_inline void * clib_mem_alloc(uword size)
VNET_DEVICE_CLASS(vxlan_gpe_device_class, static)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
static u8 * format_vxlan_gpe_name(u8 *s, 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 clib_error_t * vxlan_gpe_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
VNET_HW_INTERFACE_CLASS(vxlan_gpe_hw_class)
static u32 fib_index_from_fib_id(u32 fib_id)
vxlan_gpe_tunnel_t * tunnels
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * show_vxlan_gpe_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword * vxlan_gpe_tunnel_by_key
#define hash_get_mem(h, key)
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)
#define clib_error_return(e, args...)
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
#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 * free_vxlan_gpe_tunnel_hw_if_indices
static uword unformat_gpe_decap_next(unformat_input_t *input, va_list *args)