48 s =
format (s,
"GENEVE encap to geneve_tunnel%d vni %d",
56 u32 next_index = va_arg (*args,
u32);
60 case GENEVE_INPUT_NEXT_DROP:
62 case GENEVE_INPUT_NEXT_L2_INPUT:
65 return format (s,
"index %d", next_index);
76 s =
format (s,
"[%d] lcl %U rmt %U vni %d fib-idx %d sw-if-idx %d ",
95 u32 dev_instance = va_arg (*args,
u32);
96 return format (s,
"geneve_tunnel%d", dev_instance);
130 u32 dev_instance = va_arg (*args,
u32);
131 s =
format (s,
"unimplemented dev %u", dev_instance);
226 #define foreach_copy_field \ 228 _(mcast_sw_if_index) \ 230 _(decap_next_index) \ 240 ip4_geneve_header_t *h4;
241 ip6_geneve_header_t *h6;
246 int len = is_ip6 ?
sizeof *r.h6 :
sizeof *r.h4;
247 #if SUPPORT_OPTIONS_HEADER==1 248 len += t->options_len;
259 udp = &r.h4->udp, geneve = &r.h4->geneve;
273 udp = &r.h6->udp, geneve = &r.h6->geneve;
275 clib_host_to_net_u32 (6 << 28);
284 udp->
src_port = clib_host_to_net_u16 (5251);
285 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_geneve);
289 #if SUPPORT_OPTIONS_HEADER==1 308 u32 decap_next_index)
326 } __clib_packed mcast_shared_t;
328 static inline mcast_shared_t
334 return (mcast_shared_t)
343 mcast_shared_t new_ep = {
344 .mcast_adj_index = ai,
345 .mfib_entry_index = mfei,
369 u32 hw_if_index = ~0;
372 geneve4_tunnel_key_t key4;
373 geneve6_tunnel_key_t key6;
378 key4.remote = a->
remote.ip4.as_u32;
384 key6.remote = a->
remote.ip6;
395 return VNET_API_ERROR_TUNNEL_EXIST;
401 return VNET_API_ERROR_INVALID_DECAP_NEXT;
407 #define _(x) t->x = a->x; 430 { 0xd0, 0x0b, 0xee, 0xd0, (
u8) (t_idx >> 8), (
u8) t_idx };
434 address, &hw_if_index, 0);
438 return VNET_API_ERROR_INVALID_REGISTRATION;
444 (vnm, geneve_device_class.index, t - vxm->
tunnels,
445 geneve_hw_class.index, t - vxm->
tunnels);
451 u32 encap_index = !is_ip6 ?
510 .frp_sw_if_index = 0xffffffff,
518 .fp_len = (is_ip6 ? 128 : 32),
519 .fp_grp_addr = tun_remote_pfx.
fp_addr,
569 return VNET_API_ERROR_NO_SUCH_ENTRY;
641 u32 *result = va_arg (*args,
u32 *);
642 u32 ipv4_set = va_arg (*args,
int);
649 *result = GENEVE_INPUT_NEXT_L2_INPUT;
652 else if (
unformat (input,
"%d", &tmp))
665 ip46_address_t local, remote;
673 u32 encap_fib_index = 0;
675 u32 decap_next_index = GENEVE_INPUT_NEXT_L2_INPUT;
680 u32 tunnel_sw_if_index;
697 else if (
unformat (line_input,
"local %U",
703 else if (
unformat (line_input,
"remote %U",
709 else if (
unformat (line_input,
"local %U",
715 else if (
unformat (line_input,
"remote %U",
721 else if (
unformat (line_input,
"group %U %U",
726 grp_set = remote_set = 1;
729 else if (
unformat (line_input,
"group %U %U",
734 grp_set = remote_set = 1;
737 else if (
unformat (line_input,
"encap-vrf-id %d", &tmp))
740 if (encap_fib_index == ~0)
748 &decap_next_index, ipv4_set))
750 else if (
unformat (line_input,
"vni %d", &vni))
758 else if (
unformat (line_input,
"l3-mode"))
794 if (grp_set && mcast_sw_if_index == ~0)
800 if (ipv4_set && ipv6_set)
813 if (decap_next_index == ~0)
830 #define _(x) a->x = x; 844 case VNET_API_ERROR_TUNNEL_EXIST:
848 case VNET_API_ERROR_NO_SUCH_ENTRY:
854 (0,
"vnet_geneve_add_del_tunnel returned %d", rv);
886 .path =
"create geneve tunnel",
888 "create geneve tunnel local <local-vtep-addr>" 889 " {remote <remote-vtep-addr>|group <mcast-vtep-addr> <intf-name>} vni <nn>" 890 " [encap-vrf-id <nn>] [decap-next [l2|node <name>]] [l3-mode] [del]",
925 .path =
"show geneve tunnel",
926 .short_help =
"show geneve tunnel",
937 sw_if_index, is_enable, 0, 0);
940 sw_if_index, is_enable, 0, 0);
964 else if (
unformat (line_input,
"del"))
973 if (~0 == sw_if_index)
1039 .path =
"set interface ip geneve-bypass",
1041 .short_help =
"set interface ip geneve-bypass <interface> [del]",
1096 .path =
"set interface ip6 geneve-bypass",
1098 .short_help =
"set interface ip6 geneve-bypass <interface> [del]",
1112 sizeof (geneve6_tunnel_key_t),
1116 sizeof (ip46_address_t),
1117 sizeof (mcast_shared_t));
#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 ...
static void vnet_geneve_hdr_1word_hton(geneve_header_t *h)
static clib_error_t * set_ip6_geneve_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u16 lb_n_buckets
number of buckets in the load-balance.
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.
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...
Contribute an object that is to be used to forward IP6 packets.
#define hash_set(h, key, value)
l2_input_config_t * configs
static u8 * format_geneve_header_with_length(u8 *s, va_list *args)
uword vtep_addr_ref(vtep_table_t *t, u32 fib_index, ip46_address_t *ip)
static uword ip46_address_is_multicast(const ip46_address_t *a)
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
A representation of a path as described by a route producer.
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
static void mcast_shared_add(ip46_address_t *remote, fib_node_index_t mfei, adj_index_t ai)
#define pool_foreach(VAR, POOL)
Iterate through pool.
void fib_node_init(fib_node_t *node, fib_node_type_t type)
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.
u32 frp_mitf_flags
MFIB interface flags.
static mcast_shared_t mcast_shared_get(ip46_address_t *ip)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
fib_node_t node
Linkage into the FIB object graph.
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 dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
#define foreach_copy_field
static geneve_tunnel_t * geneve_tunnel_from_fib_node(fib_node_t *node)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Contribute an object that is to be used to forward IP4 packets.
static clib_error_t * geneve_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#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)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
unformat_function_t unformat_vnet_sw_interface
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
int vnet_geneve_add_del_tunnel(vnet_geneve_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
u32 * tunnel_index_by_sw_if_index
u8 * format_geneve_encap_trace(u8 *s, va_list *args)
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
geneve_tunnel_t * tunnels
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
static clib_error_t * show_geneve_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_HW_INTERFACE_CLASS(geneve_hw_class)
vnet_flood_class_t flood_class
clib_error_t * geneve_init(vlib_main_t *vm)
u32 frp_sw_if_index
The interface.
static fib_node_back_walk_rc_t geneve_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 GENEVE DIP to encap ...
#define VLIB_INIT_FUNCTION(x)
static void vnet_set_geneve_oamframe_bit(geneve_header_t *h, u8 oam)
void mfib_table_entry_delete_index(fib_node_index_t mfib_entry_index, mfib_source_t source)
Delete a FIB entry.
static int ip46_address_cmp(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
description fragment has unexpected format
vlib_node_registration_t geneve4_encap_node
(constructor) VLIB_REGISTER_NODE (geneve4_encap_node)
vl_api_interface_index_t mcast_sw_if_index
Aggregate type for a prefix.
#define clib_error_return(e, args...)
static void vnet_set_geneve_options_len(geneve_header_t *h, u8 len)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
#define ALWAYS_ASSERT(truth)
static clib_error_t * set_ip_geneve_bypass(u32 is_ip6, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static void vnet_set_geneve_vni(geneve_header_t *h, u32 vni)
#define GENEVE_ETH_PROTOCOL
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)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword vtep_addr_unref(vtep_table_t *t, u32 fib_index, ip46_address_t *ip)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
dpo_type_t dpoi_type
the type
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
static clib_error_t * set_ip4_geneve_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
load-balancing over a choice of [un]equal cost paths
u8 * format_geneve_tunnel(u8 *s, va_list *args)
#define pool_put(P, E)
Free an object E in pool P.
static void vnet_set_geneve_version(geneve_header_t *h, u8 version)
vlib_node_registration_t geneve6_input_node
(constructor) VLIB_REGISTER_NODE (geneve6_input_node)
vnet_sw_interface_flags_t flags
static u8 * format_geneve_name(u8 *s, va_list *args)
static void vnet_set_geneve_protocol(geneve_header_t *h, u16 protocol)
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
static void geneve_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_ip46_address
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
u32 fib_node_index_t
A typedef of a node index.
u32 adj_index_t
An index for adjacencies.
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.
uword * geneve4_tunnel_by_key
Aggregate type for a prefix.
vlib_main_t vlib_node_runtime_t * node
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
VNET_DEVICE_CLASS(geneve_device_class, static)
void fib_entry_untrack(fib_node_index_t fei, u32 sibling)
Stop tracking a FIB entry.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
manual_print typedef address
static clib_error_t * geneve_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
static load_balance_t * load_balance_get(index_t lbi)
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
static fib_node_t * geneve_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
fib_route_path_flags_t frp_flags
flags on the path
static void geneve_tunnel_restack_dpo(geneve_tunnel_t *t)
#define clib_error_report(e)
static void hash_unset_mem_free(uword **h, const void *key)
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static int geneve_rewrite(geneve_tunnel_t *t, bool is_ip6)
vlib_node_registration_t geneve6_encap_node
(constructor) VLIB_REGISTER_NODE (geneve6_encap_node)
static vtep_table_t vtep_table_create()
static void vnet_set_geneve_critical_bit(geneve_header_t *h, u8 critical_opts)
static clib_error_t * geneve_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
fib_protocol_t fp_proto
protocol type
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.
index_t dpoi_index
the index of objects of that type
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
static fib_protocol_t fib_ip_proto(bool is_ip6)
Convert from boolean is_ip6 to FIB protocol.
uword * geneve6_tunnel_by_key
fib_node_index_t fib_entry_index
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
static uword get_decap_next_for_node(u32 node_index, u32 ipv4_set)
static void mcast_shared_remove(ip46_address_t *remote)
unformat_function_t unformat_vlib_node
#define hash_get_mem(h, key)
A FIB graph nodes virtual function table.
static u8 * format_decap_next(u8 *s, va_list *args)
geneve_main_t geneve_main
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
static bool geneve_decap_next_is_valid(geneve_main_t *vxm, u32 is_ip6, u32 decap_next_index)
static uword unformat_decap_next(unformat_input_t *input, va_list *args)
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 hash_set_mem_alloc(uword **h, const void *key, uword v)
manual_print typedef u8 mac_address[6]
#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
static u16 ip4_header_checksum(ip4_header_t *i)
const ip46_address_t zero_addr
#include <vnet/feature/feature.h>
vl_api_interface_index_t sw_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)
vlib_node_registration_t geneve4_input_node
(constructor) VLIB_REGISTER_NODE (geneve4_input_node)
void vnet_int_geneve_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
static uword pool_elts(void *v)
Number of active elements in a pool.