40 s =
format (s,
"[%d] local: %U remote: %U ",
49 case VXLAN_GPE_PROTOCOL_IP4:
50 s =
format (s,
"next-protocol ip4");
52 case VXLAN_GPE_PROTOCOL_IP6:
53 s =
format (s,
"next-protocol ip6");
55 case VXLAN_GPE_PROTOCOL_ETHERNET:
56 s =
format (s,
"next-protocol ethernet");
58 case VXLAN_GPE_PROTOCOL_NSH:
59 s =
format (s,
"next-protocol nsh");
65 s =
format (s,
" fibs: (encap %d, decap %d)",
83 u32 dev_instance = va_arg (*args,
u32);
84 return format (s,
"vxlan_gpe_tunnel%d", dev_instance);
91 clib_warning (
"you shouldn't be here, leaking buffers...");
136 u32 dev_instance = va_arg (*args,
u32);
137 s =
format (s,
"unimplemented dev %u", dev_instance);
149 #define foreach_gpe_copy_field \ 155 #define foreach_copy_ipv4 { \ 156 _(local.ip4.as_u32) \ 157 _(remote.ip4.as_u32) \ 160 #define foreach_copy_ipv6 { \ 161 _(local.ip6.as_u64[0]) \ 162 _(local.ip6.as_u64[1]) \ 163 _(remote.ip6.as_u64[0]) \ 164 _(remote.ip6.as_u64[1]) \ 177 u8 protocol_override,
uword encap_next_node)
181 ip4_vxlan_gpe_header_t * h0;
184 len =
sizeof (*h0) + extension_size;
189 h0 = (ip4_vxlan_gpe_header_t *) rw;
203 h0->udp.src_port = clib_host_to_net_u16 (4790);
204 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
209 if (protocol_override)
211 h0->vxlan.protocol = protocol_override;
217 t->
rewrite_size =
sizeof(ip4_vxlan_gpe_header_t) + extension_size;
218 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni<<8);
234 u8 protocol_override,
uword encap_next_node)
238 ip6_vxlan_gpe_header_t * h0;
241 len =
sizeof (*h0) + extension_size;
246 h0 = (ip6_vxlan_gpe_header_t *) rw;
260 h0->udp.src_port = clib_host_to_net_u16 (4790);
261 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
266 if (protocol_override)
272 h0->vxlan.protocol = protocol_override;
274 t->
rewrite_size =
sizeof(ip4_vxlan_gpe_header_t) + extension_size;
275 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni<<8);
299 u32 hw_if_index = ~0;
300 u32 sw_if_index = ~0;
302 vxlan4_gpe_tunnel_key_t key4, *key4_copy;
303 vxlan6_gpe_tunnel_key_t key6, *key6_copy;
308 key4.local = a->
local.ip4.as_u32;
309 key4.remote = a->
remote.ip4.as_u32;
310 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
317 key6.local.as_u64[0] = a->
local.ip6.as_u64[0];
318 key6.local.as_u64[1] = a->
local.ip6.as_u64[1];
319 key6.remote.as_u64[0] = a->
remote.ip6.as_u64[0];
320 key6.remote.as_u64[1] = a->
remote.ip6.as_u64[1];
321 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
330 return VNET_API_ERROR_INVALID_VALUE;
333 memset (t, 0,
sizeof (*t));
336 #define _(x) t->x = a->x; 359 clib_memcpy (key4_copy, &key4,
sizeof (*key4_copy));
366 clib_memcpy (key6_copy, &key6,
sizeof (*key6_copy));
384 (vnm, vxlan_gpe_device_class.index, t - gm->
tunnels,
385 vxlan_gpe_hw_class.index, t - gm->
tunnels);
402 return VNET_API_ERROR_NO_SUCH_ENTRY;
414 key4_copy = (
void *)(hp->
key);
421 key6_copy = (
void *)(hp->
key);
431 *sw_if_indexp = sw_if_index;
443 ip46_address_t local, remote;
448 u32 encap_fib_index = 0;
449 u32 decap_fib_index = 0;
450 u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
465 else if (
unformat (line_input,
"local %U",
471 else if (
unformat (line_input,
"remote %U",
477 else if (
unformat (line_input,
"local %U",
483 else if (
unformat (line_input,
"remote %U",
489 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
496 if (encap_fib_index == ~0)
499 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
506 if (decap_fib_index == ~0)
509 else if (
unformat (line_input,
"vni %d", &vni))
511 else if (
unformat(line_input,
"next-ip4"))
512 protocol = VXLAN_GPE_PROTOCOL_IP4;
513 else if (
unformat(line_input,
"next-ip6"))
514 protocol = VXLAN_GPE_PROTOCOL_IP6;
515 else if (
unformat(line_input,
"next-ethernet"))
516 protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
517 else if (
unformat(line_input,
"next-nsh"))
518 protocol = VXLAN_GPE_PROTOCOL_NSH;
532 if (ipv4_set && ipv6_set)
535 if ((ipv4_set && memcmp(&local.ip4, &remote.ip4,
sizeof(local.ip4)) == 0) ||
536 (ipv6_set && memcmp(&local.ip6, &remote.ip6,
sizeof(local.ip6)) == 0))
542 memset (a, 0,
sizeof (*a));
547 #define _(x) a->x = x; 560 case VNET_API_ERROR_INVALID_DECAP_NEXT:
563 case VNET_API_ERROR_TUNNEL_EXIST:
566 case VNET_API_ERROR_NO_SUCH_ENTRY:
571 (0,
"vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
578 .path =
"create vxlan-gpe tunnel",
580 "create vxlan-gpe tunnel local <local-addr> remote <remote-addr>" 581 " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]" 582 " [encap-vrf-id <nn>] [decap-vrf-id <nn>]" 610 vlib_cli_output (vm,
"%U", format_vxlan_gpe_tunnel, t);
617 .path =
"show vxlan-gpe",
650 VXLAN_GPE_INPUT_NEXT_IP4_INPUT);
652 VXLAN_GPE_INPUT_NEXT_IP6_INPUT);
654 VXLAN_GPE_INPUT_NEXT_ETHERNET_INPUT);
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
clib_error_t * vxlan_gpe_init(vlib_main_t *vm)
Feature init function for VXLAN GPE.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define foreach_copy_ipv4
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
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).
int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv6 VXLAN GPE rewrite header.
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
#define hash_set_mem(h, key, value)
#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)
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or Del a VXLAN GPE tunnel.
#define VXLAN_GPE_FLAGS_P
format_function_t format_vnet_sw_if_index_name
vnet_main_t * vnet_main
State convenience vnet_main_t.
#define VXLAN_GPE_VERSION
#define VXLAN_GPE_FLAGS_I
#define foreach_gpe_copy_field
vnet_main_t * vnet_get_main(void)
u8 * format_vxlan_gpe_tunnel(u8 *s, va_list *args)
Tracing function for VXLAN GPE tunnel packets.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
ip46_address_t local
tunnel local address
static u8 * format_vxlan_gpe_header_with_length(u8 *s, va_list *args)
Formatting function for tracing VXLAN GPE with length.
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
#define clib_warning(format, args...)
#define hash_get_pair(h, key)
void vxlan_gpe_register_decap_protocol(u8 protocol_id, uword next_node_index)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
u8 * rewrite
Rewrite string.
#define hash_create_mem(elts, key_bytes, value_bytes)
int vxlan4_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv4 VXLAN GPE rewrite header.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define hash_unset_mem(h, key)
Struct for VXLAN GPE tunnel.
static u32 ip6_fib_index_from_table_id(u32 table_id)
#define pool_put(P, E)
Free an object E in pool P.
vxlan_gpe_main_t vxlan_gpe_main
vlib_main_t * vlib_main
State convenience vlib_main_t.
u8 protocol
encapsulated protocol
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
ip46_address_t remote
tunnel remote address
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Struct for VXLAN GPE add/del args.
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 u32 ip4_fib_index_from_table_id(u32 table_id)
static u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
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.
#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 clib_error_t * vxlan_gpe_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
CLI function for VXLAN GPE admin up/down.
u8 rewrite_size
rewrite size for dynamic plugins like iOAM
Struct for VXLAN GPE node state.
static void clib_mem_free(void *p)
static void * clib_mem_alloc(uword size)
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
#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)
CLI function for showing VXLAN GPE tunnels.
a point 2 point interface
u32 hw_if_index
vnet intfc hw_if_index
#define hash_get_mem(h, key)
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
uword encap_next_node
Next node after VxLAN-GPE encap.
u32 sw_if_index
vnet intfc sw_if_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)
#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
#define VXLAN_GPE_TUNNEL_IS_IPV4
Flags for vxlan_gpe_tunnel_t.
#define foreach_copy_ipv6
static u16 ip4_header_checksum(ip4_header_t *i)
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
static uword pool_elts(void *v)
Number of active elements in a pool.