|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
56 case VXLAN_GPE_PROTOCOL_IP4:
59 case VXLAN_GPE_PROTOCOL_IP6:
62 case VXLAN_GPE_PROTOCOL_ETHERNET:
63 s =
format (s,
"protocol ethernet");
65 case VXLAN_GPE_PROTOCOL_NSH:
66 s =
format (s,
"protocol nsh");
90 s =
format (s,
"[%d] lcl %U rmt %U vni %d fib-idx %d sw-if-idx %d ",
121 u32 dev_instance = va_arg (*args,
u32);
122 return format (s,
"vxlan_gpe_tunnel%d", dev_instance);
168 u32 dev_instance = va_arg (*args,
u32);
169 s =
format (s,
"unimplemented dev %u", dev_instance);
251 #define foreach_gpe_copy_field \
254 _(mcast_sw_if_index) \
258 #define foreach_copy_ipv4 { \
259 _(local.ip4.as_u32) \
260 _(remote.ip4.as_u32) \
263 #define foreach_copy_ipv6 { \
264 _(local.ip6.as_u64[0]) \
265 _(local.ip6.as_u64[1]) \
266 _(remote.ip6.as_u64[0]) \
267 _(remote.ip6.as_u64[1]) \
281 u8 protocol_override,
uword encap_next_node)
285 ip4_vxlan_gpe_header_t *h0;
288 len =
sizeof (*h0) + extension_size;
293 h0 = (ip4_vxlan_gpe_header_t *) rw;
307 h0->udp.src_port = clib_host_to_net_u16 (4790);
308 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
313 if (protocol_override)
315 h0->vxlan.protocol = protocol_override;
321 t->
rewrite_size =
sizeof (ip4_vxlan_gpe_header_t) + extension_size;
322 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni << 8);
339 u8 protocol_override,
uword encap_next_node)
343 ip6_vxlan_gpe_header_t *h0;
346 len =
sizeof (*h0) + extension_size;
351 h0 = (ip6_vxlan_gpe_header_t *) rw;
356 clib_host_to_net_u32 (6 << 28);
366 h0->udp.src_port = clib_host_to_net_u16 (4790);
367 h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
372 if (protocol_override)
378 h0->vxlan.protocol = protocol_override;
380 t->
rewrite_size =
sizeof (ip4_vxlan_gpe_header_t) + extension_size;
381 h0->vxlan.vni_res = clib_host_to_net_u32 (t->
vni << 8);
398 static inline mcast_shared_t
404 return (mcast_shared_t)
413 mcast_shared_t new_ep = {
414 .mcast_adj_index = ai,
415 .mfib_entry_index = mfei,
449 u32 hw_if_index = ~0;
452 vxlan4_gpe_tunnel_key_t key4, *key4_copy;
453 vxlan6_gpe_tunnel_key_t key6, *key6_copy;
458 key4.local =
a->local.ip4.as_u32;
459 key4.remote =
a->remote.ip4.as_u32;
460 key4.vni = clib_host_to_net_u32 (
a->vni << 8);
467 key6.local.as_u64[0] =
a->local.ip6.as_u64[0];
468 key6.local.as_u64[1] =
a->local.ip6.as_u64[1];
469 key6.remote.as_u64[0] =
a->remote.ip6.as_u64[0];
470 key6.remote.as_u64[1] =
a->remote.ip6.as_u64[1];
471 key6.vni = clib_host_to_net_u32 (
a->vni << 8);
482 return VNET_API_ERROR_TUNNEL_EXIST;
489 #define _(x) t->x = a->x;
540 hi->hw_instance =
hi->dev_instance;
558 (vnm, vxlan_gpe_device_class.index, t - ngm->
tunnels,
559 vxlan_gpe_hw_class.index, t - ngm->
tunnels);
620 .frp_sw_if_index = 0xffffffff,
628 .fp_len = (
is_ip6 ? 128 : 32),
629 .fp_grp_addr = tun_remote_pfx.
fp_addr,
641 path.frp_sw_if_index =
a->mcast_sw_if_index;
654 a->mcast_sw_if_index);
681 return VNET_API_ERROR_NO_SUCH_ENTRY;
740 ip46_address_t local, remote;
747 u32 encap_fib_index = 0;
748 u32 decap_fib_index = 0;
766 else if (
unformat (line_input,
"local %U",
772 else if (
unformat (line_input,
"remote %U",
778 else if (
unformat (line_input,
"local %U",
784 else if (
unformat (line_input,
"remote %U",
790 else if (
unformat (line_input,
"group %U %U",
795 grp_set = remote_set = 1;
798 else if (
unformat (line_input,
"group %U %U",
803 grp_set = remote_set = 1;
806 else if (
unformat (line_input,
"encap-vrf-id %d", &
tmp))
813 if (encap_fib_index == ~0)
820 else if (
unformat (line_input,
"decap-vrf-id %d", &
tmp))
827 if (decap_fib_index == ~0)
836 else if (
unformat (line_input,
"next-ip4"))
838 else if (
unformat (line_input,
"next-ip6"))
840 else if (
unformat (line_input,
"next-ethernet"))
841 protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
842 else if (
unformat (line_input,
"next-nsh"))
881 if (ipv4_set && ipv6_set)
887 if ((ipv4_set && memcmp (&local.ip4, &remote.ip4, sizeof (local.ip4)) == 0)
889 && memcmp (&local.ip6, &remote.ip6, sizeof (local.ip6)) == 0))
904 a->is_ip6 = ipv6_set;
907 #define _(x) a->x = x;
924 case VNET_API_ERROR_INVALID_DECAP_NEXT:
928 case VNET_API_ERROR_TUNNEL_EXIST:
932 case VNET_API_ERROR_NO_SUCH_ENTRY:
938 (0,
"vnet_vxlan_gpe_add_del_tunnel returned %d",
rv);
969 .path =
"create vxlan-gpe tunnel",
971 "create vxlan-gpe tunnel local <local-addr> "
972 " {remote <remote-addr>|group <mcast-addr> <intf-name>}"
973 " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]"
974 " [encap-vrf-id <nn>] [decap-vrf-id <nn>] [del]\n",
1021 .path =
"show vxlan-gpe",
1058 else if (
unformat (line_input,
"del"))
1133 .path =
"set interface ip vxlan-gpe-bypass",
1135 .short_help =
"set interface ip vxlan-gpe-bypass <interface> [del]",
1190 .path =
"set interface ip6 vxlan-gpe-bypass",
1192 .short_help =
"set interface ip6 vxlan-gpe-bypass <interface> [del]",
1199 .arc_name =
"ip4-unicast",
1200 .node_name =
"ip4-vxlan-gpe-bypass",
1206 .arc_name =
"ip6-unicast",
1207 .node_name =
"ip6-vxlan-gpe-bypass",
1236 sizeof (ip46_address_t),
1237 sizeof (mcast_shared_t));
1242 VXLAN_GPE_INPUT_NEXT_IP4_INPUT);
1244 VXLAN_GPE_INPUT_NEXT_IP6_INPUT);
1246 VXLAN_GPE_INPUT_NEXT_L2_INPUT);
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
vnet_interface_main_t * im
static u8 * format_decap_next(u8 *s, va_list *args)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
index_t dpoi_index
the index of objects of that type
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
u32 sibling_index
The tunnel is a child of the FIB entry for its destination.
static vtep_table_t vtep_table_create()
static fib_protocol_t fib_ip_proto(bool is_ip6)
Convert from boolean is_ip6 to FIB protocol.
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
static clib_error_t * set_ip6_vxlan_gpe_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
const ip46_address_t zero_addr
#include <vnet/feature/feature.h>
@ VNET_INTERFACE_COUNTER_TX
static uword ip46_address_is_multicast(const ip46_address_t *a)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
const static fib_node_vft_t vxlan_gpe_vft
void fib_entry_untrack(fib_node_index_t fei, u32 sibling)
Stop tracking a FIB entry.
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
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.
Aggregate type for a prefix.
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
vlib_main_t vlib_node_runtime_t * node
A FIB graph nodes virtual function table.
void mfib_table_entry_delete_index(fib_node_index_t mfib_entry_index, mfib_source_t source)
Delete a FIB entry.
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
#define clib_error_return(e, args...)
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.
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static void mcast_shared_add(ip46_address_t *remote, fib_node_index_t mfei, adj_index_t ai)
u8 rewrite_size
rewrite size for dynamic plugins like iOAM
Struct for VXLAN GPE node state.
#define hash_set_mem(h, key, value)
static u8 * format_vxlan_gpe_header_with_length(u8 *s, va_list *args)
Formatting function for tracing VXLAN GPE with length.
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
#define pool_put(P, E)
Free an object E in pool P.
#define foreach_copy_ipv4
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vnet_main_t * vnet_main
State convenience vnet_main_t.
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
@ VNET_HW_INTERFACE_FLAG_LINK_UP
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
static vxlan_gpe_tunnel_t * vxlan_gpe_tunnel_from_fib_node(fib_node_t *node)
vlib_simple_counter_main_t * sw_if_counters
u8 protocol
encapsulated protocol
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
static clib_error_t * set_ip4_vxlan_gpe_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
fib_node_t node
Linkage into the FIB object graph.
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.
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
#define hash_unset(h, key)
uword vtep_addr_ref(vtep_table_t *t, u32 fib_index, ip46_address_t *ip)
vnet_sw_interface_flags_t flags
#define foreach_copy_ipv6
@ VNET_FLOOD_CLASS_TUNNEL_NORMAL
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP4
Contribute an object that is to be used to forward IP4 packets.
static void hash_set_mem_alloc(uword **h, const void *key, uword v)
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 ...
fib_node_index_t fib_entry_track(u32 fib_index, const fib_prefix_t *prefix, fib_node_type_t child_type, index_t child_index, u32 *sibling)
Trackers are used on FIB entries by objects that which to track the changing state of the entry.
#define STRUCT_OFFSET_OF(t, f)
#define pool_foreach(VAR, POOL)
Iterate through pool.
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
u8 * format_vxlan_gpe_tunnel(u8 *s, va_list *args)
Format function for VXLAN GPE tunnel.
#define hash_create_mem(elts, key_bytes, value_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static mcast_shared_t mcast_shared_get(ip46_address_t *ip)
#define VXLAN_GPE_TUNNEL_IS_IPV4
Flags for vxlan_gpe_tunnel_t.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vxlan_gpe_main_t vxlan_gpe_main
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
u8 * rewrite
Rewrite string.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
ip46_address_t local
tunnel local address
vnet_flood_class_t flood_class
u32 fib_node_index_t
A typedef of a node 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.
static clib_error_t * vxlan_gpe_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_node_index_t fib_entry_index
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
Struct for VXLAN GPE tunnel.
@ VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
typedef CLIB_PACKED(union { struct { fib_node_index_t mfib_entry_index;adj_index_t mcast_adj_index;};u64 as_u64;})
Struct for VXLAN GPE add/del args.
#define VLIB_CLI_COMMAND(x,...)
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.
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u8 udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
#define ALWAYS_ASSERT(truth)
@ VNET_INTERFACE_COUNTER_RX
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
#define CLIB_CACHE_LINE_BYTES
@ VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP
static u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
fib_protocol_t fp_proto
protocol type
@ FIB_NODE_BACK_WALK_CONTINUE
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_combined_counter_main_t * combined_sw_if_counters
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
uword vtep_addr_unref(vtep_table_t *t, u32 fib_index, ip46_address_t *ip)
uword encap_next_node
Next node after VxLAN-GPE encap.
vl_api_interface_index_t mcast_sw_if_index
void vnet_int_vxlan_gpe_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
#define VXLAN_GPE_VERSION
#define hash_get_mem(h, key)
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.
#define vec_free(V)
Free vector's memory (no header).
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
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.
format_function_t format_vnet_sw_if_index_name
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
unformat_function_t unformat_vnet_sw_interface
description fragment has unexpected format
#define VXLAN_GPE_FLAGS_P
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.
u32 sw_if_index
vnet intfc sw_if_index
VNET_FEATURE_INIT(ip4_vxlan_gpe_bypass, static)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
@ FIB_NODE_TYPE_VXLAN_GPE_TUNNEL
clib_error_t * vxlan_gpe_init(vlib_main_t *vm)
Feature init function for VXLAN GPE.
format_function_t format_ip46_address
@ FIB_ROUTE_PATH_FLAG_NONE
ip46_address_t remote
tunnel remote address
#define VLIB_INIT_FUNCTION(x)
static vlib_cli_command_t set_interface_ip_vxlan_gpe_bypass_command
(constructor) VLIB_CLI_COMMAND (set_interface_ip_vxlan_gpe_bypass_command)
vl_api_ip_proto_t protocol
A representation of a path as described by a route producer.
#define VXLAN_GPE_FLAGS_I
VNET_HW_INTERFACE_CLASS(vxlan_gpe_hw_class)
static vlib_cli_command_t show_vxlan_gpe_tunnel_command
(constructor) VLIB_CLI_COMMAND (show_vxlan_gpe_tunnel_command)
static uword pool_elts(void *v)
Number of active elements in a pool.
u32 hw_if_index
vnet intfc hw_if_index
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)
An node in the FIB graph.
static void hash_unset_mem_free(uword **h, const void *key)
u32 adj_index_t
An index for adjacencies.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t * vlib_main
State convenience vlib_main_t.
@ VNET_SW_INTERFACE_FLAG_HIDDEN
void fib_node_init(fib_node_t *node, fib_node_type_t type)
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 vlib_cli_command_t set_interface_ip6_vxlan_gpe_bypass_command
(constructor) VLIB_CLI_COMMAND (set_interface_ip6_vxlan_gpe_bypass_command)
#define VNET_FEATURES(...)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
static void vxlan_gpe_tunnel_restack_dpo(vxlan_gpe_tunnel_t *t)
VNET_DEVICE_CLASS(vxlan_gpe_device_class, static)
static u16 ip4_header_checksum(ip4_header_t *i)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
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)
Add n paths to an entry (aka route) in the FIB.
void vxlan_gpe_register_decap_protocol(u8 protocol_id, uword next_node_index)
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
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 placeholder) rewrite.
Context passed between object during a back walk.
@ VNET_FLOOD_CLASS_TUNNEL_MASTER
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
void fib_node_deinit(fib_node_t *node)
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP6
Contribute an object that is to be used to forward IP6 packets.
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.
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
static void mcast_shared_remove(ip46_address_t *remote)
l2_input_config_t * configs
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
vl_api_interface_index_t sw_if_index
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.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
static void * clib_mem_alloc(uword size)
Aggregate type for a prefix.
@ FIB_ROUTE_PATH_LOCAL
A for-us/local path.
@ VNET_INTERFACE_COUNTER_DROP
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
vnet_interface_main_t interface_main
static vlib_cli_command_t create_vxlan_gpe_tunnel_command
(constructor) VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command)
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 clib_error_t * set_ip_vxlan_gpe_bypass(u32 is_ip6, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_gpe_copy_field
vl_api_wireguard_peer_flags_t flags