49 u32 next_index = va_arg (*args,
u32);
51 if (next_index == VXLAN_INPUT_NEXT_DROP)
54 return format (s,
"index %d", next_index);
64 "[%d] instance %d src %U dst %U vni %d fib-idx %d sw-if-idx %d ",
88 u32 dev_instance = va_arg (*args,
u32);
92 if (dev_instance == ~0)
93 return format (s,
"<cached-unused>");
96 return format (s,
"<improperly-referenced>");
125 u32 dev_instance = va_arg (*args,
u32);
126 s =
format (s,
"unimplemented dev %u", dev_instance);
160 u32 encap_index = is_ip4 ?
223 #define foreach_copy_field \ 225 _(mcast_sw_if_index) \ 227 _(decap_next_index) \ 236 ip4_vxlan_header_t h4;
237 ip6_vxlan_header_t h6;
239 int len = is_ip6 ?
sizeof h.h6 :
sizeof h.h4;
249 udp = &
h.h4.udp, vxlan = &
h.h4.vxlan;
263 udp = &
h.h6.udp, vxlan = &
h.h6.vxlan;
265 clib_host_to_net_u32 (6 << 28);
274 udp->
src_port = clib_host_to_net_u16 (4789);
275 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan);
284 u32 decap_next_index)
306 static inline mcast_shared_t
312 mcast_shared_t ret = {.as_u64 = *p };
319 mcast_shared_t new_ep = {
320 .mcast_adj_index = ai,
321 .mfib_entry_index = mfei,
355 a->
dst.ip4.as_u32 | (((
u64) a->
src.ip4.as_u32) << 32);
357 | clib_host_to_net_u32 (a->
vni << 8);
360 p = (
void *) &key4.
value;
364 key6.
key[0] = a->
dst.ip6.as_u64[0];
365 key6.
key[1] = a->
dst.ip6.as_u64[1];
367 | clib_host_to_net_u32 (a->
vni << 8);
370 p = (
void *) &key6.
value;
384 return VNET_API_ERROR_TUNNEL_EXIST;
390 return VNET_API_ERROR_INVALID_DECAP_NEXT;
395 dev_instance = t - vxm->
tunnels;
398 #define _(x) t->x = a->x; 407 if (user_instance == ~0)
408 user_instance = dev_instance;
412 return VNET_API_ERROR_INSTANCE_IN_USE;
421 (vnm, vxlan_device_class.index, dev_instance,
422 vxlan_hw_class.index, dev_instance);
426 u32 encap_index = !is_ip6 ?
457 return VNET_API_ERROR_INVALID_REGISTRATION;
512 .frp_sw_if_index = 0xffffffff,
520 .fp_len = (is_ip6 ? 128 : 32),
521 .fp_grp_addr = tun_dst_pfx.
fp_addr,
571 return VNET_API_ERROR_NO_SUCH_ENTRY;
641 u32 *result = va_arg (*args,
u32 *);
642 u32 ipv4_set = va_arg (*args,
int);
649 *result = VXLAN_INPUT_NEXT_L2_INPUT;
652 else if (
unformat (input,
"%d", &tmp))
674 u32 encap_fib_index = 0;
676 u32 decap_next_index = VXLAN_INPUT_NEXT_L2_INPUT;
691 else if (
unformat (line_input,
"instance %d", &instance))
693 else if (
unformat (line_input,
"src %U",
699 else if (
unformat (line_input,
"dst %U",
705 else if (
unformat (line_input,
"group %U %U",
710 grp_set = dst_set = 1;
713 else if (
unformat (line_input,
"encap-vrf-id %d", &table_id))
719 &decap_next_index, ipv4_set))
721 else if (
unformat (line_input,
"vni %d", &vni))
736 if (encap_fib_index == ~0)
751 if (grp_set && mcast_sw_if_index == ~0)
754 if (ipv4_set && ipv6_set)
760 if (decap_next_index == ~0)
778 u32 tunnel_sw_if_index;
789 case VNET_API_ERROR_TUNNEL_EXIST:
792 case VNET_API_ERROR_NO_SUCH_ENTRY:
795 case VNET_API_ERROR_INSTANCE_IN_USE:
800 (0,
"vnet_vxlan_add_del_tunnel returned %d", rv);
832 .path =
"create vxlan tunnel",
834 "create vxlan tunnel src <local-vtep-addr>" 835 " {dst <remote-vtep-addr>|group <mcast-vtep-addr> <intf-name>} vni <nn>" 837 " [encap-vrf-id <nn>] [decap-next [l2|node <name>]] [del]",
866 vlib_cli_output (vm,
"%U", format_vxlan_tunnel, t);
894 .path =
"show vxlan tunnel",
895 .short_help =
"show vxlan tunnel [raw]",
910 is_enable = ! !is_enable;
918 sw_if_index, is_enable, 0, 0);
921 sw_if_index, is_enable);
930 sw_if_index, is_enable, 0, 0);
933 sw_if_index, is_enable);
959 else if (
unformat (line_input,
"del"))
968 if (~0 == sw_if_index)
1034 .path =
"set interface ip vxlan-bypass",
1036 .short_help =
"set interface ip vxlan-bypass <interface> [del]",
1091 .path =
"set interface ip6 vxlan-bypass",
1093 .short_help =
"set interface ip6 vxlan-bypass <interface> [del]",
1110 VNET_FLOW_ACTION_REDIRECT_TO_NODE | VNET_FLOW_ACTION_MARK |
1111 VNET_FLOW_ACTION_BUFFER_ADVANCE,
1115 .
type = VNET_FLOW_TYPE_IP4_VXLAN,
1117 .protocol.prot = IP_PROTOCOL_UDP,
1118 .src_addr.addr = t->
dst.ip4,
1119 .dst_addr.addr = t->
src.ip4,
1120 .src_addr.mask.as_u32 = ~0,
1121 .dst_addr.mask.as_u32 = ~0,
1122 .dst_port.port = UDP_DST_PORT_vxlan,
1123 .dst_port.mask = 0xFF,
1157 u32 rx_sw_if_index = ~0;
1158 u32 hw_if_index = ~0;
1178 if (rx_sw_if_index == ~0)
1180 if (hw_if_index == ~0)
1205 is_add ?
"enabling" :
"disabling");
1212 .path =
"set flow-offload vxlan",
1214 "set flow-offload vxlan hw <interface-name> rx <tunnel-name> [del]",
1219 #define VXLAN_HASH_NUM_BUCKETS (2 * 1024) 1220 #define VXLAN_HASH_MEMORY_SIZE (1 << 20) 1243 sizeof (ip46_address_t),
1244 sizeof (mcast_shared_t));
unformat_function_t unformat_vnet_hw_interface
#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 ...
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
uword vtep_addr_ref(vtep_table_t *t, u32 fib_index, ip46_address_t *ip)
u32 sibling_index
The tunnel is a child of the FIB entry for its destination.
static uword ip46_address_is_multicast(const ip46_address_t *a)
int vnet_flow_get_range(vnet_main_t *vnm, char *owner, u32 count, u32 *start)
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
clib_bihash_24_8_t vxlan6_tunnel_by_key
A representation of a path as described by a route producer.
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
clib_error_t * vxlan_init(vlib_main_t *vm)
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.
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
static clib_error_t * set_ip6_vxlan_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
typedef CLIB_PACKED(union { struct { fib_node_index_t mfib_entry_index;adj_index_t mcast_adj_index;};u64 as_u64;})
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)
#define vnet_rewrite_set_data(rw, data, data_bytes)
static void mcast_shared_remove(ip46_address_t *dst)
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.
static clib_error_t * set_ip4_vxlan_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_registration_t vxlan4_flow_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_flow_input_node)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Contribute an object that is to be used to forward IP4 packets.
#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 * fib_index_by_sw_if_index
Table index indexed by software interface.
unformat_function_t unformat_vnet_sw_interface
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
int vnet_flow_disable(vnet_main_t *vnm, u32 flow_index, u32 hw_if_index)
static vxlan_tunnel_t * vxlan_tunnel_from_fib_node(fib_node_t *node)
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * show_vxlan_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static fib_node_back_walk_rc_t vxlan_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 DIP to encap n...
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
vnet_flood_class_t flood_class
VNET_DEVICE_CLASS(vxlan_device_class, static)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
u32 frp_sw_if_index
The interface.
#define VLIB_INIT_FUNCTION(x)
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)
vl_api_interface_index_t mcast_sw_if_index
Aggregate type for a prefix.
static void vxlan_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
#define ALWAYS_ASSERT(truth)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static clib_error_t * vxlan_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_node_t node
Linkage into the FIB object graph.
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
vl_api_fib_path_type_t type
int vnet_flow_del(vnet_main_t *vnm, u32 flow_index)
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.
static clib_error_t * vxlan_offload_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword * bm_ip6_bypass_enabled_by_sw_if
static clib_error_t * vxlan_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
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)
load-balancing over a choice of [un]equal cost paths
#define pool_put(P, E)
Free an object E in pool P.
vnet_sw_interface_flags_t flags
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
format_function_t format_ip46_address
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
int vnet_vxlan_add_del_rx_flow(u32 hw_if_index, u32 t_index, int is_add)
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
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.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void vnet_set_vni_and_flags(vxlan_header_t *h, u32 vni)
u32 adj_index_t
An index for adjacencies.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
static uword unformat_decap_next(unformat_input_t *input, va_list *args)
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.
Aggregate 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 placeholder) rewrite.
vlib_main_t vlib_node_runtime_t * node
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
static u8 * format_vxlan_header_with_length(u8 *s, va_list *args)
static void vxlan_tunnel_restack_dpo(vxlan_tunnel_t *t)
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,...)
static void mcast_shared_add(ip46_address_t *dst, fib_node_index_t mfei, adj_index_t ai)
static fib_node_t * vxlan_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
static load_balance_t * load_balance_get(index_t lbi)
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
format_function_t format_flow_enabled_hw
static void hash_unset_mem_free(uword **h, const void *key)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static uword get_decap_next_for_node(u32 node_index, u32 ipv4_set)
u32 vnet_vxlan_get_tunnel_index(u32 sw_if_index)
int vnet_flow_add(vnet_main_t *vnm, vnet_flow_t *flow, u32 *flow_index)
static void vxlan_rewrite(vxlan_tunnel_t *t, bool is_ip6)
static vtep_table_t vtep_table_create()
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_elt(v, i)
Get vector value at index i.
#define foreach_copy_field
fib_protocol_t fp_proto
protocol type
index_t dpoi_index
the index of objects of that type
void vnet_int_vxlan_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
bool udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static fib_protocol_t fib_ip_proto(bool is_ip6)
Convert from boolean is_ip6 to FIB protocol.
uword * bm_ip4_bypass_enabled_by_sw_if
static clib_error_t * set_ip_vxlan_bypass(u32 is_ip6, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
fib_node_index_t fib_entry_index
vnet_sw_interface_t * sw_interfaces
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
int vnet_flow_enable(vnet_main_t *vnm, u32 flow_index, u32 hw_if_index)
unformat_function_t unformat_vlib_node
u32 * tunnel_index_by_sw_if_index
#define hash_get_mem(h, key)
A FIB graph nodes virtual function table.
static u8 * format_decap_next(u8 *s, va_list *args)
vlib_node_registration_t vxlan4_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan4_encap_node)
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
clib_bihash_16_8_t vxlan4_tunnel_by_key
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.
vlib_node_registration_t vxlan6_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan6_encap_node)
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)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
VNET_HW_INTERFACE_CLASS(vxlan_hw_class)
#define VXLAN_HASH_NUM_BUCKETS
#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 bool vxlan_decap_next_is_valid(vxlan_main_t *vxm, u32 is_ip6, u32 decap_next_index)
static u16 ip4_header_checksum(ip4_header_t *i)
#define ip46_address_initializer
#define VXLAN_HASH_MEMORY_SIZE
const ip46_address_t zero_addr
vl_api_interface_index_t sw_if_index
u8 * format_vxlan_tunnel(u8 *s, va_list *args)
static u8 * format_vxlan_name(u8 *s, va_list *args)
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)
static uword pool_elts(void *v)
Number of active elements in a pool.