62 s =
format (s,
"[%d] local: %U remote: %U ",
71 case VXLAN_GPE_PROTOCOL_IP4:
72 s =
format (s,
"next-protocol ip4");
74 case VXLAN_GPE_PROTOCOL_IP6:
75 s =
format (s,
"next-protocol ip6");
77 case VXLAN_GPE_PROTOCOL_ETHERNET:
78 s =
format (s,
"next-protocol ethernet");
80 case VXLAN_GPE_PROTOCOL_NSH:
81 s =
format (s,
"next-protocol nsh");
90 s =
format (s,
" fibs: (encap %d, decap %d)",
108 u32 dev_instance = va_arg (*args,
u32);
109 return format (s,
"vxlan_gpe_tunnel%d", dev_instance);
155 u32 dev_instance = va_arg (*args,
u32);
156 s =
format (s,
"unimplemented dev %u", dev_instance);
238 #define foreach_gpe_copy_field \ 241 _(mcast_sw_if_index) \ 245 #define foreach_copy_ipv4 { \ 246 _(local.ip4.as_u32) \ 247 _(remote.ip4.as_u32) \ 250 #define foreach_copy_ipv6 { \ 251 _(local.ip6.as_u64[0]) \ 252 _(local.ip6.as_u64[1]) \ 253 _(remote.ip6.as_u64[0]) \ 254 _(remote.ip6.as_u64[1]) \ 268 u8 protocol_override,
uword encap_next_node)
272 ip4_vxlan_gpe_header_t *h0;
275 len =
sizeof (*h0) + extension_size;
280 h0 = (ip4_vxlan_gpe_header_t *) rw;
294 h0->udp.src_port = clib_host_to_net_u16 (4790);
295 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
300 if (protocol_override)
302 h0->vxlan.protocol = protocol_override;
308 t->
rewrite_size =
sizeof (ip4_vxlan_gpe_header_t) + extension_size;
309 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni << 8);
326 u8 protocol_override,
uword encap_next_node)
330 ip6_vxlan_gpe_header_t *h0;
333 len =
sizeof (*h0) + extension_size;
338 h0 = (ip6_vxlan_gpe_header_t *) rw;
343 clib_host_to_net_u32 (6 << 28);
353 h0->udp.src_port = clib_host_to_net_u16 (4790);
354 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
359 if (protocol_override)
365 h0->vxlan.protocol = protocol_override;
367 t->
rewrite_size =
sizeof (ip4_vxlan_gpe_header_t) + extension_size;
368 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni << 8);
414 static inline mcast_shared_t
415 mcast_shared_get (ip46_address_t * ip)
420 return (mcast_shared_t)
429 mcast_shared_t new_ep = {
430 .mcast_adj_index = ai,
431 .mfib_entry_index = mfei,
440 mcast_shared_t ep = mcast_shared_get (remote);
471 u32 hw_if_index = ~0;
472 u32 sw_if_index = ~0;
474 vxlan4_gpe_tunnel_key_t key4, *key4_copy;
475 vxlan6_gpe_tunnel_key_t key6, *key6_copy;
480 key4.local = a->
local.ip4.as_u32;
481 key4.remote = a->
remote.ip4.as_u32;
482 key4.vni = clib_host_to_net_u32 (a->
vni << 8);
489 key6.local.as_u64[0] = a->
local.ip6.as_u64[0];
490 key6.local.as_u64[1] = a->
local.ip6.as_u64[1];
491 key6.remote.as_u64[0] = a->
remote.ip6.as_u64[0];
492 key6.remote.as_u64[1] = a->
remote.ip6.as_u64[1];
493 key6.vni = clib_host_to_net_u32 (a->
vni << 8);
504 return VNET_API_ERROR_TUNNEL_EXIST;
507 memset (t, 0,
sizeof (*t));
511 #define _(x) t->x = a->x; 541 clib_memcpy (key4_copy, &key4,
sizeof (*key4_copy));
548 clib_memcpy (key6_copy, &key6,
sizeof (*key6_copy));
580 (vnm, vxlan_gpe_device_class.index, t - ngm->
tunnels,
581 vxlan_gpe_hw_class.index, t - ngm->
tunnels);
642 .frp_sw_if_index = 0xffffffff,
649 .fp_len = (is_ip6 ? 128 : 32),
650 .fp_grp_addr = tun_remote_pfx.
fp_addr,
685 mcast_shared_t ep = mcast_shared_get (&t->
remote);
703 return VNET_API_ERROR_NO_SUCH_ENTRY;
739 *sw_if_indexp = sw_if_index;
751 ip46_address_t local, remote;
757 u32 mcast_sw_if_index = ~0;
758 u32 encap_fib_index = 0;
759 u32 decap_fib_index = 0;
760 u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
777 else if (
unformat (line_input,
"local %U",
783 else if (
unformat (line_input,
"remote %U",
789 else if (
unformat (line_input,
"local %U",
795 else if (
unformat (line_input,
"remote %U",
801 else if (
unformat (line_input,
"group %U %U",
806 grp_set = remote_set = 1;
809 else if (
unformat (line_input,
"group %U %U",
814 grp_set = remote_set = 1;
817 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
824 if (encap_fib_index == ~0)
831 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
838 if (decap_fib_index == ~0)
845 else if (
unformat (line_input,
"vni %d", &vni))
847 else if (
unformat (line_input,
"next-ip4"))
848 protocol = VXLAN_GPE_PROTOCOL_IP4;
849 else if (
unformat (line_input,
"next-ip6"))
850 protocol = VXLAN_GPE_PROTOCOL_IP6;
851 else if (
unformat (line_input,
"next-ethernet"))
852 protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
853 else if (
unformat (line_input,
"next-nsh"))
854 protocol = VXLAN_GPE_PROTOCOL_NSH;
887 if (grp_set && mcast_sw_if_index == ~0)
892 if (ipv4_set && ipv6_set)
898 if ((ipv4_set && memcmp (&local.ip4, &remote.ip4, sizeof (local.ip4)) == 0)
900 && memcmp (&local.ip6, &remote.ip6, sizeof (local.ip6)) == 0))
912 memset (a, 0,
sizeof (*a));
918 #define _(x) a->x = x; 935 case VNET_API_ERROR_INVALID_DECAP_NEXT:
939 case VNET_API_ERROR_TUNNEL_EXIST:
943 case VNET_API_ERROR_NO_SUCH_ENTRY:
949 (0,
"vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
980 .path =
"create vxlan-gpe tunnel",
982 "create vxlan-gpe tunnel local <local-addr> " 983 " {remote <remote-addr>|group <mcast-addr> <intf-name>}" 984 " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]" 985 " [encap-vrf-id <nn>] [decap-vrf-id <nn>] [del]\n",
1014 vlib_cli_output (vm,
"%U", format_vxlan_gpe_tunnel, t);
1032 .path =
"show vxlan-gpe",
1042 sw_if_index, is_enable, 0, 0);
1045 sw_if_index, is_enable, 0, 0);
1056 u32 sw_if_index, is_enable;
1069 else if (
unformat (line_input,
"del"))
1078 if (~0 == sw_if_index)
1144 .path =
"set interface ip vxlan-gpe-bypass",
1146 .short_help =
"set interface ip vxlan-gpe-bypass <interface> [del]",
1201 .path =
"set interface ip6 vxlan-gpe-bypass",
1203 .short_help =
"set interface ip vxlan-gpe-bypass <interface> [del]",
1210 .arc_name =
"ip4-unicast",
1211 .node_name =
"ip4-vxlan-gpe-bypass",
1217 .arc_name =
"ip6-unicast",
1218 .node_name =
"ip6-vxlan-gpe-bypass",
1247 sizeof (ip46_address_t),
1248 sizeof (mcast_shared_t));
1258 VXLAN_GPE_INPUT_NEXT_IP4_INPUT);
1260 VXLAN_GPE_INPUT_NEXT_IP6_INPUT);
1262 VXLAN_GPE_INPUT_NEXT_L2_INPUT);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vnet_set_interface_output_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Set interface output node - for interface registered without its output/tx nodes created because its ...
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
Recursive resolution source.
Contribute an object that is to be used to forward IP6 packets.
#define hash_set(h, key, value)
l2_input_config_t * configs
static fib_node_back_walk_rc_t vxlan_gpe_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node - Here we will restack the new dpo of VXLAN_GPE DIP to enc...
static void vxlan_gpe_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
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)
#define hash_unset(h, key)
static uword ip46_address_is_multicast(ip46_address_t *a)
A representation of a path as described by a route producer.
vnet_main_t * vnet_get_main(void)
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
vnet_interface_main_t interface_main
void fib_node_init(fib_node_t *node, fib_node_type_t type)
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
#define foreach_copy_ipv4
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_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)
typedef CLIB_PACKED(union{struct{fib_node_index_t mfib_entry_index;adj_index_t mcast_adj_index;};u64 as_u64;})
Contribute an object that is to be used to forward IP4 packets.
#define hash_set_mem(h, key, value)
#define STRUCT_OFFSET_OF(t, f)
void fib_node_deinit(fib_node_t *node)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
dpo_proto_t frp_proto
The protocol of the address below.
unformat_function_t unformat_vnet_sw_interface
#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.
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define VXLAN_GPE_VERSION
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
#define VXLAN_GPE_FLAGS_I
#define foreach_gpe_copy_field
vnet_flood_class_t flood_class
static fib_node_t * vxlan_gpe_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
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.
u32 frp_sw_if_index
The interface.
#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.
void mfib_table_entry_delete_index(fib_node_index_t mfib_entry_index, mfib_source_t source)
Delete a FIB entry.
vlib_combined_counter_main_t * combined_sw_if_counters
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
static uword vtep_addr_unref(ip46_address_t *ip)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Add n paths to an entry (aka route) in the FIB.
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static fib_protocol_t fib_ip_proto(bool is_ip6)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
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)
fib_node_index_t fib_entry_index
u8 * rewrite
Rewrite string.
VNET_FEATURE_INIT(ip4_vxlan_gpe_bypass, static)
static uword vtep_addr_ref(ip46_address_t *ip)
void vnet_int_vxlan_gpe_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#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.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Struct for VXLAN GPE tunnel.
#define pool_put(P, E)
Free an object E in pool P.
static void mcast_shared_remove(ip46_address_t *remote)
vxlan_gpe_main_t vxlan_gpe_main
static vxlan_gpe_tunnel_t * vxlan_gpe_tunnel_from_fib_node(fib_node_t *node)
vlib_main_t * vlib_main
State convenience vlib_main_t.
u8 protocol
encapsulated protocol
vlib_simple_counter_main_t * sw_if_counters
static clib_error_t * set_ip4_vxlan_gpe_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
ip46_address_t remote
tunnel remote address
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
#define ip46_address_is_ip4(ip46)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
static clib_error_t * set_ip6_vxlan_gpe_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Struct for VXLAN GPE add/del args.
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
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 void vnet_interface_counter_unlock(vnet_interface_main_t *im)
fib_node_t node
Linkage into the FIB object graph.
#define VNET_SW_INTERFACE_FLAG_HIDDEN
u32 fib_node_index_t
A typedef of a node index.
u32 adj_index_t
An index for adjacencies.
static u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Aggregrate type for a prefix.
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.
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
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.
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_route_path_flags_t frp_flags
flags on the path
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.
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static void * clib_mem_alloc(uword size)
#define VNET_FEATURES(...)
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
fib_protocol_t fp_proto
protocol type
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.
static void hash_set_mem_alloc(uword **h, void *key, uword v)
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
u32 hw_if_index
vnet intfc hw_if_index
static void vxlan_gpe_tunnel_restack_dpo(vxlan_gpe_tunnel_t *t)
#define hash_get_mem(h, key)
static void hash_unset_mem_free(uword **h, void *key)
A FIB graph nodes virtual function table.
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
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
static void mcast_shared_add(ip46_address_t *remote, fib_node_index_t mfei, adj_index_t ai)
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)
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
static uword ip6_vxlan_gpe_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#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.
static uword ip4_vxlan_gpe_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static clib_error_t * set_ip_vxlan_gpe_bypass(u32 is_ip6, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_copy_ipv6
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static u16 ip4_header_checksum(ip4_header_t *i)
const ip46_address_t zero_addr
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
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.