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;
68 tunnel_index0 = adj0->rewrite_header.node_index;
78 ASSERT(
sizeof(ip4_udp_lisp_gpe_header_t) == 36);
79 ASSERT(
sizeof(ip6_udp_lisp_gpe_header_t) == 56);
84 next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
90 next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
99 u32 adj_index0, adj_index1, tunnel_index0, tunnel_index1;
117 tunnel_index0 = adj0->rewrite_header.node_index;
118 tunnel_index1 = adj1->rewrite_header.node_index;
130 u32 * next1,
u8 is_v4)
132 ASSERT(
sizeof(ip4_udp_lisp_gpe_header_t) == 36);
133 ASSERT(
sizeof(ip6_udp_lisp_gpe_header_t) == 56);
139 next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
145 next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
149 #define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40 155 u32 n_left_from, next_index, * from, * to_next;
157 u32 pkts_encapsulated = 0;
164 while (n_left_from > 0)
169 to_next, n_left_to_next);
171 while (n_left_from >= 4 && n_left_to_next >= 2)
177 u8 is_v4_eid0, is_v4_eid1;
179 next0 = next1 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
252 pkts_encapsulated += 2;
255 n_left_to_next, bi0, bi1, next0,
259 while (n_left_from > 0 && n_left_to_next > 0)
262 u32 bi0, next0 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
293 n_left_to_next, bi0, next0);
299 LISP_GPE_ERROR_ENCAPSULATED, pkts_encapsulated);
306 u32 dev_instance = va_arg (*args,
u32);
307 return format (s,
"lisp_gpe%d", dev_instance);
315 .no_flatten_output_chains = 1,
320 void * dst_address,
void * rewrite,
uword max_rewrite_bytes)
329 u32 max_header_bytes = va_arg (*args,
u32);
332 header_bytes =
sizeof (h[0]);
333 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
334 return format (s,
"lisp-gpe header truncated");
336 s =
format (s,
"flags: ");
337 #define _(n,v) if (h->flags & v) s = format (s, "%s ", #n); 341 s =
format (s,
"\n ver_res %d res %d next_protocol %d iid %d(%x)",
343 clib_net_to_host_u32 (h->
iid),
344 clib_net_to_host_u32 (h->
iid));
366 memset(&a, 0,
sizeof(a));
398 memset(&a, 0,
sizeof(a));
414 if (adj_index[0] == 0)
435 memset (&adj, 0,
sizeof(adj));
442 adj.rewrite_header.sw_if_index = ~0;
445 memset(&prefix, 0,
sizeof(prefix));
490 u32 hw_if_index = ~0, lookup_next_index4, lookup_next_index6, flen;
513 lisp_gpe_device_class.index,
515 lisp_gpe_hw_class.index, 0);
543 #define _(sym,str) vlib_node_add_named_next_with_slot (vnm->vlib_main, \ 544 hi->tx_node_index, str, LISP_GPE_TX_NEXT_##sym); 602 else if (
unformat (line_input,
"del"))
604 else if (
unformat (line_input,
"vrf %d", &table_id))
620 .path =
"lisp gpe iface",
621 .short_help =
"lisp gpe iface add/del table-index <table_index> 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)
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.
static void add_del_lisp_gpe_default_route(u32 table_id, u8 is_v4, u8 is_add)
#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 hash_unset(h, key)
#define foreach_lisp_gpe_tx_next
uword * tunnel_term_sw_if_index_by_vni
ip_lookup_next_t lookup_next_index
lisp_gpe_tunnel_t * tunnels
#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
#define VNET_HW_INTERFACE_FLAG_LINK_UP
uword * lgpe_ip6_lookup_next_index_by_table_id
always_inline void get_one_tunnel_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, lisp_gpe_tunnel_t **t0, u8 is_v4)
#define ip_prefix_version(_a)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u8 * format_lisp_gpe_tx_trace(u8 *s, va_list *args)
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 clib_warning(format, args...)
u32 table_index_or_table_id
void vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
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)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
void ip6_add_del_route(ip6_main_t *im, ip6_add_del_route_args_t *args)
#define ip_addr_version(_a)
u32 * free_lisp_gpe_tunnel_hw_if_indices
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)
uword * lisp_gpe_hw_if_index_by_table_id
void * ip4_get_route(ip4_main_t *im, u32 fib_index_or_table_id, u32 flags, u8 *address, u32 address_length)
u32 ip6_lookup_next_lgpe_ip6_lookup
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)
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
uword * vni_by_tunnel_term_sw_if_index
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
vlib_node_registration_t lgpe_ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip4_lookup_node)
#define CLIB_PREFETCH(addr, size, type)
always_inline 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)
#define IP6_ROUTE_FLAG_DEL
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
lisp_gpe_main_t lisp_gpe_main
#define IP4_ROUTE_FLAG_DEL
#define VLIB_CLI_COMMAND(x,...)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
ip4_address_t dst_address
#define IP4_ROUTE_FLAG_ADD
vlib_node_registration_t lgpe_ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip6_lookup_node)
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)
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define VLIB_BUFFER_IS_TRACED
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 table_index_or_table_id
always_inline void encap_one_inline(lisp_gpe_main_t *lgm, vlib_buffer_t *b0, lisp_gpe_tunnel_t *t0, u32 *next0, u8 is_v4)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#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)
#define IP4_ROUTE_FLAG_TABLE_ID
#define IP6_ROUTE_FLAG_ADD
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
#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)
always_inline void ip_udp_encap_one(vlib_main_t *vm, vlib_buffer_t *b0, u8 *ec0, word ec_len, u8 is_ip4)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
u32 * fib_index_by_sw_if_index
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
uword * lgpe_ip4_lookup_next_index_by_table_id
always_inline 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, u8 is_v4)