39 s =
format (s,
"[%d] local: %U remote: %U ",
48 case VXLAN_GPE_PROTOCOL_IP4:
49 s =
format (s,
"next-protocol ip4");
51 case VXLAN_GPE_PROTOCOL_IP6:
52 s =
format (s,
"next-protocol ip6");
54 case VXLAN_GPE_PROTOCOL_ETHERNET:
55 s =
format (s,
"next-protocol ethernet");
57 case VXLAN_GPE_PROTOCOL_NSH:
58 s =
format (s,
"next-protocol nsh");
64 s =
format (s,
" fibs: (encap %d, decap %d)",
82 u32 dev_instance = va_arg (*args,
u32);
83 return format (s,
"vxlan_gpe_tunnel%d", dev_instance);
90 clib_warning (
"you shouldn't be here, leaking buffers...");
128 uword max_rewrite_bytes)
145 u32 dev_instance = va_arg (*args,
u32);
146 s =
format (s,
"unimplemented dev %u", dev_instance);
157 #define foreach_gpe_copy_field \ 163 #define foreach_copy_ipv4 { \ 164 _(local.ip4.as_u32) \ 165 _(remote.ip4.as_u32) \ 168 #define foreach_copy_ipv6 { \ 169 _(local.ip6.as_u64[0]) \ 170 _(local.ip6.as_u64[1]) \ 171 _(remote.ip6.as_u64[0]) \ 172 _(remote.ip6.as_u64[1]) \ 188 ip4_vxlan_gpe_header_t * h0;
195 h0 = (ip4_vxlan_gpe_header_t *) rw;
209 h0->udp.src_port = clib_host_to_net_u16 (4790);
210 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
215 h0->vxlan.protocol = VXLAN_GPE_PROTOCOL_IP4;
216 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni<<8);
234 ip6_vxlan_gpe_header_t * h0;
241 h0 = (ip6_vxlan_gpe_header_t *) rw;
255 h0->udp.src_port = clib_host_to_net_u16 (4790);
256 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
261 h0->vxlan.protocol = VXLAN_GPE_PROTOCOL_IP4;
262 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni<<8);
285 u32 hw_if_index = ~0;
286 u32 sw_if_index = ~0;
288 vxlan4_gpe_tunnel_key_t key4, *key4_copy;
289 vxlan6_gpe_tunnel_key_t key6, *key6_copy;
294 key4.local = a->
local.ip4.as_u32;
295 key4.remote = a->
remote.ip4.as_u32;
296 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
303 key6.local.as_u64[0] = a->
local.ip6.as_u64[0];
304 key6.local.as_u64[1] = a->
local.ip6.as_u64[1];
305 key6.remote.as_u64[0] = a->
remote.ip6.as_u64[0];
306 key6.remote.as_u64[1] = a->
remote.ip6.as_u64[1];
307 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
316 return VNET_API_ERROR_INVALID_VALUE;
319 memset (t, 0,
sizeof (*t));
322 #define _(x) t->x = a->x; 345 clib_memcpy (key4_copy, &key4,
sizeof (*key4_copy));
352 clib_memcpy (key6_copy, &key6,
sizeof (*key6_copy));
370 (vnm, vxlan_gpe_device_class.index, t - gm->
tunnels,
371 vxlan_gpe_hw_class.index, t - gm->
tunnels);
388 return VNET_API_ERROR_NO_SUCH_ENTRY;
400 key4_copy = (
void *)(hp->
key);
407 key6_copy = (
void *)(hp->
key);
417 *sw_if_indexp = sw_if_index;
479 ip46_address_t local, remote;
484 u32 encap_fib_index = 0;
485 u32 decap_fib_index = 0;
486 u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
501 else if (
unformat (line_input,
"local %U",
507 else if (
unformat (line_input,
"remote %U",
513 else if (
unformat (line_input,
"local %U",
519 else if (
unformat (line_input,
"remote %U",
525 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
532 if (encap_fib_index == ~0)
535 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
543 if (decap_fib_index == ~0)
546 else if (
unformat (line_input,
"vni %d", &vni))
548 else if (
unformat(line_input,
"next-ip4"))
549 protocol = VXLAN_GPE_PROTOCOL_IP4;
550 else if (
unformat(line_input,
"next-ip6"))
551 protocol = VXLAN_GPE_PROTOCOL_IP6;
552 else if (
unformat(line_input,
"next-ethernet"))
553 protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
554 else if (
unformat(line_input,
"next-nsh"))
555 protocol = VXLAN_GPE_PROTOCOL_NSH;
569 if (ipv4_set && ipv6_set)
572 if ((ipv4_set && memcmp(&local.ip4, &remote.ip4,
sizeof(local.ip4)) == 0) ||
573 (ipv6_set && memcmp(&local.ip6, &remote.ip6,
sizeof(local.ip6)) == 0))
579 memset (a, 0,
sizeof (*a));
584 #define _(x) a->x = x; 597 case VNET_API_ERROR_INVALID_DECAP_NEXT:
600 case VNET_API_ERROR_TUNNEL_EXIST:
603 case VNET_API_ERROR_NO_SUCH_ENTRY:
608 (0,
"vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
615 .path =
"create vxlan-gpe tunnel",
617 "create vxlan-gpe tunnel local <local-addr> remote <remote-addr>" 618 " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]" 619 " [encap-vrf-id <nn>] [decap-vrf-id <nn>]" 647 vlib_cli_output (vm,
"%U", format_vxlan_gpe_tunnel, t);
654 .path =
"show vxlan-gpe",
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)
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).
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.
static int vxlan4_gpe_rewrite(vxlan_gpe_tunnel_t *t)
Calculate IPv4 VXLAN GPE rewrite header.
static u32 fib4_index_from_fib_id(u32 fib_id)
Find the IPv4 FIB index from the FIB ID.
#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)
u8 * rewrite
Rewrite string.
#define hash_create_mem(elts, key_bytes, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define hash_unset_mem(h, key)
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Struct for VXLAN GPE tunnel.
#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.
uword * fib_index_by_table_id
#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 u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
static clib_error_t * vxlan_gpe_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI function for Add/Del of IPv4/IPv6 VXLAN GPE tunnel.
#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.
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.
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
static u32 fib6_index_from_fib_id(u32 fib_id)
Find the IPv4 FIB index from the FIB ID.
#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.
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.
ip4_main_t ip4_main
Global ip4 main structure.
static int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t)
Calculate IPv6 VXLAN GPE rewrite header.
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.