24 #define foreach_lisp_gpe_tx_next \ 25 _(DROP, "error-drop") \ 26 _(IP4_LOOKUP, "ip4-lookup") \ 27 _(IP6_LOOKUP, "ip6-lookup") 31 #define _(sym,str) LISP_GPE_TX_NEXT_##sym, 57 u32 adj_index0, tunnel_index0;
78 ASSERT (
sizeof (ip4_udp_lisp_gpe_header_t) == 36);
79 ASSERT (
sizeof (ip6_udp_lisp_gpe_header_t) == 56);
91 next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
96 next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
108 u32 adj_index0, adj_index1, tunnel_index0, tunnel_index1;
141 ASSERT (
sizeof (ip4_udp_lisp_gpe_header_t) == 36);
142 ASSERT (
sizeof (ip6_udp_lisp_gpe_header_t) == 56);
162 next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
168 next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
177 next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
178 next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
184 next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
185 next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
194 #define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40 200 u32 n_left_from, next_index, *from, *to_next;
208 while (n_left_from > 0)
214 while (n_left_from >= 4 && n_left_to_next >= 2)
220 u8 is_v4_eid0, is_v4_eid1;
222 next0 = next1 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
280 n_left_to_next, bi0, bi1, next0,
284 while (n_left_from > 0 && n_left_to_next > 0)
287 u32 bi0, next0 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
312 n_left_to_next, bi0, next0);
324 u32 dev_instance = va_arg (*args,
u32);
325 return format (s,
"lisp_gpe%d", dev_instance);
334 .no_flatten_output_chains = 1,
340 void *dst_address,
void *rewrite,
uword max_rewrite_bytes)
349 u32 max_header_bytes = va_arg (*args,
u32);
352 header_bytes =
sizeof (h[0]);
353 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
354 return format (s,
"lisp-gpe header truncated");
356 s =
format (s,
"flags: ");
357 #define _(n,v) if (h->flags & v) s = format (s, "%s ", #n); 361 s =
format (s,
"\n ver_res %d res %d next_protocol %d iid %d(%x)",
363 clib_net_to_host_u32 (h->
iid), clib_net_to_host_u32 (h->
iid));
387 memset (&a, 0,
sizeof (a));
419 memset (&a, 0,
sizeof (a));
435 if (adj_index[0] == 0)
456 memset (&adj, 0,
sizeof (adj));
463 adj.rewrite_header.sw_if_index = ~0;
466 memset (&prefix, 0,
sizeof (prefix));
504 #define foreach_l2_lisp_gpe_tx_next \ 505 _(DROP, "error-drop") \ 506 _(IP4_LOOKUP, "ip4-lookup") \ 507 _(IP6_LOOKUP, "ip6-lookup") \ 508 _(LISP_CP_LOOKUP, "lisp-cp-lookup") 512 #define _(sym,str) L2_LISP_GPE_TX_NEXT_##sym, 539 next0[0] = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
544 next0[0] = L2_LISP_GPE_TX_NEXT_DROP;
564 uword is_ip, eh_size;
568 eh_type = clib_net_to_host_u16 (eh->
type);
571 is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
617 ASSERT (0 != t0 && 0 != t1);
656 u32 n_left_from, next_index, *from, *to_next;
664 while (n_left_from > 0)
670 while (n_left_from >= 4 && n_left_to_next >= 2)
674 u32 next0, next1, ti0, ti1;
678 next0 = next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
722 if ((
u32) ~ 0 != ti0)
728 next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
731 else if ((
u32) ~ 0 != ti1)
737 next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
743 next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
745 next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
764 n_left_to_next, bi0, bi1, next0,
768 while (n_left_from > 0 && n_left_to_next > 0)
771 u32 bi0, ti0, next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
795 next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
806 n_left_to_next, bi0, next0);
818 u32 dev_instance = va_arg (*args,
u32);
819 return format (s,
"l2_lisp_gpe%d", dev_instance);
824 .name =
"L2_LISP_GPE",
828 .no_flatten_output_chains = 1,
838 u32 hw_if_index = ~0;
853 new_name =
format (0,
"%U", dev_class->format_device_name, vni);
876 lisp_gpe_hw_class.index, 0);
924 u32 lookup_next_index4, lookup_next_index6;
946 &lisp_gpe_device_class, l3_ifaces);
965 #define _(sym,str) vlib_node_add_named_next_with_slot (vnm->vlib_main, \ 966 hi->tx_node_index, str, LISP_GPE_TX_NEXT_##sym); 1028 &l2_lisp_gpe_device_class, &lgm->
l2_ifaces);
1035 #define _(sym,str) vlib_node_add_named_next_with_slot (vnm->vlib_main, \ 1036 hi->tx_node_index, str, L2_LISP_GPE_TX_NEXT_##sym); 1049 clib_warning (
"The interface for bridge domain %d doesn't exist",
1068 return VNET_API_ERROR_LISP_DISABLED;
1085 u32 table_id, vni, bd_id;
1086 u8 vni_is_set = 0, vrf_is_set = 0, bd_index_is_set = 0;
1098 else if (
unformat (line_input,
"del"))
1100 else if (
unformat (line_input,
"vrf %d", &table_id))
1104 else if (
unformat (line_input,
"vni %d", &vni))
1108 else if (
unformat (line_input,
"bd %d", &bd_id))
1110 bd_index_is_set = 1;
1119 if (vrf_is_set && bd_index_is_set)
1121 "Cannot set both vrf and brdige domain index!");
1126 if (!vrf_is_set && !bd_index_is_set)
1130 a->
dp_table = vrf_is_set ? table_id : bd_id;
1132 a->
is_l2 = bd_index_is_set;
1138 is_add ?
"add" :
"delete");
1146 .path =
"lisp gpe iface",
1147 .short_help =
"lisp gpe iface add/del vni <vni> vrf <vrf>",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
ip4_fib_t * find_ip4_fib_by_table_index_or_id(ip4_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv4 fib.
u32 * free_tunnel_hw_if_indices
static void add_del_lisp_gpe_default_route(u32 table_id, u8 is_v4, u8 is_add)
static u32 l2_flow_hash(vlib_buffer_t *b0)
#define hash_set(h, key, value)
u32 ip4_lookup_next_lgpe_ip4_lookup
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define foreach_l2_lisp_gpe_tx_next
#define hash_unset(h, key)
u8 vnet_lisp_gpe_enable_disable_status(void)
#define foreach_lisp_gpe_tx_next
u16 n_adj
Number of adjecencies in block.
vnet_interface_main_t interface_main
ip_lookup_next_t lookup_next_index
lisp_gpe_tunnel_t * tunnels
#define ethernet_buffer_header_size(b)
Determine the size of the Ethernet headers of the current frame in the buffer.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define ip_prefix_len(_a)
static clib_error_t * lisp_gpe_add_del_iface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u8 * format_lisp_gpe_name(u8 *s, va_list *args)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define VNET_HW_INTERFACE_FLAG_LINK_UP
uword * lgpe_ip6_lookup_next_index_by_table_id
struct _vnet_device_class vnet_device_class_t
uword * vni_by_sw_if_index
#define ip_prefix_version(_a)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static vnet_hw_interface_t * create_lisp_gpe_iface(lisp_gpe_main_t *lgm, u32 vni, u32 dp_table, vnet_device_class_t *dev_class, tunnel_lookup_t *tuns)
u8 * format_lisp_gpe_tx_trace(u8 *s, va_list *args)
u8 * format_l2_lisp_gpe_tx_trace(u8 *s, va_list *args)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vlib_combined_counter_main_t * combined_sw_if_counters
ip6_fib_t * find_ip6_fib_by_table_index_or_id(ip6_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv6 fib.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static foreach_gid_address_type_fcns u64 mac_to_u64(u8 *m)
#define clib_warning(format, args...)
u32 table_index_or_table_id
static int lisp_gpe_add_del_l3_iface(lisp_gpe_main_t *lgm, vnet_lisp_gpe_add_del_iface_args_t *a)
static int lisp_gpe_add_del_l2_iface(lisp_gpe_main_t *lgm, vnet_lisp_gpe_add_del_iface_args_t *a)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
u8 * format_lisp_gpe_header_with_length(u8 *s, va_list *args)
void ip6_add_del_route(ip6_main_t *im, ip6_add_del_route_args_t *args)
static void l2_process_one(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, u32 ti0, u32 *next0)
static void lisp_gpe_iface_set_table(u32 sw_if_index, u32 table_id, u8 is_ip4)
ip6_address_t dst_address
#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 u16 counters, and the shared vlib_counter_t...
u32 lisp_l2_fib_lookup(lisp_gpe_main_t *lgm, u16 bd_index, u8 src_mac[6], u8 dst_mac[6])
void * ip4_get_route(ip4_main_t *im, u32 fib_index_or_table_id, u32 flags, u8 *address, u32 address_length)
static u32 ip6_compute_flow_hash(ip6_header_t *ip, u32 flow_hash_config)
u32 ip6_lookup_next_lgpe_ip6_lookup
static void get_two_tunnels_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, vlib_buffer_t *b1, lisp_gpe_tunnel_t **t0, lisp_gpe_tunnel_t **t1, u8 is_v4)
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)
u32 ip6_get_route(ip6_main_t *im, u32 fib_index_or_table_id, u32 flags, ip6_address_t *address, u32 address_length)
static void encap_two_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, vlib_buffer_t *b1, lisp_gpe_tunnel_t *t0, lisp_gpe_tunnel_t *t1, u32 *next0, u32 *next1)
vlib_simple_counter_main_t * sw_if_counters
static void ip_udp_encap_one(vlib_main_t *vm, vlib_buffer_t *b0, u8 *ec0, word ec_len, u8 is_ip4)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
uword * sw_if_index_by_vni
clib_error_t * vnet_rename_interface(vnet_main_t *vnm, u32 hw_if_index, char *new_name)
static void get_one_tunnel_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, lisp_gpe_tunnel_t **t0, u8 is_v4)
u32 sub_tunnels_lbv_count
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
#define hash_mix64(a0, b0, c0)
vlib_node_registration_t lgpe_ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip4_lookup_node)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
static void l2_process_tunnel_action(vlib_buffer_t *b0, u8 action, u32 *next0)
tunnel_lookup_t l2_ifaces
#define IP6_ROUTE_FLAG_DEL
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
int vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
lisp_gpe_main_t lisp_gpe_main
#define IP4_ROUTE_FLAG_DEL
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
ip4_address_t dst_address
#define IP4_ROUTE_FLAG_ADD
uword * hw_if_index_by_dp_table
vlib_node_registration_t lgpe_ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip6_lookup_node)
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.
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
int add_del_ip_prefix_route(ip_prefix_t *dst_prefix, u32 table_id, ip_adjacency_t *add_adj, u8 is_add, u32 *adj_index)
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static u32 ip_flow_hash(void *data)
static uword l2_lisp_gpe_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
tunnel_lookup_t l3_ifaces
static void l2_process_two(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, vlib_buffer_t *b1, u32 ti0, u32 ti1, u32 *next0, u32 *next1)
static void encap_one_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, lisp_gpe_tunnel_t *t0, u32 *next0)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 table_index_or_table_id
static u32 ip4_compute_flow_hash(ip4_header_t *ip, u32 flow_hash_config)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static uword lisp_gpe_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
ip4_main_t ip4_main
Global ip4 main structure.
#define IP4_ROUTE_FLAG_TABLE_ID
#define IP6_ROUTE_FLAG_ADD
u32 if_address_index
Interface address index for this local/arp adjacency.
static void remove_lisp_gpe_iface(lisp_gpe_main_t *lgm, u32 hi_index, u32 dp_table, tunnel_lookup_t *tuns)
i16 explicit_fib_index
Force re-lookup in a different FIB.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static u8 * format_l2_lisp_gpe_name(u8 *s, va_list *args)
#define clib_error_return(e, args...)
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
#define IP6_ROUTE_FLAG_TABLE_ID
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *args)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
u32 * fib_index_by_sw_if_index
uword * lgpe_ip4_lookup_next_index_by_table_id
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
lisp_gpe_sub_tunnel_t * sub_tunnels