24 #define foreach_gre_input_next \ 25 _(PUNT, "error-punt") \ 26 _(DROP, "error-drop") \ 27 _(ETHERNET_INPUT, "ethernet-input") \ 28 _(IP4_INPUT, "ip4-input") \ 29 _(IP6_INPUT, "ip6-input") \ 30 _(MPLS_INPUT, "mpls-input") 34 #define _(s,n) GRE_INPUT_NEXT_##s, 56 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
75 __attribute__ ((unused))
u32 n_left_from, next_index, *from, *to_next;
78 u32 cached_tunnel_sw_if_index = ~0, tunnel_sw_if_index = ~0;
86 sizeof (cached_tunnel_key.
gtk_v4));
89 sizeof (cached_tunnel_key.
gtk_v6));
96 while (n_left_from > 0)
102 while (n_left_from >= 4 && n_left_to_next >= 2)
107 u16 version0, version1;
109 u32 i0, i1, next0, next1, protocol0, protocol1;
186 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
188 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
189 b1->
error = verr1 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
191 next1 = verr1 ? GRE_INPUT_NEXT_DROP : next1;
230 next0 = GRE_INPUT_NEXT_DROP;
231 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
237 cached_tunnel_sw_if_index = tunnel_sw_if_index;
249 tunnel_sw_if_index = cached_tunnel_sw_if_index;
254 next0 = GRE_INPUT_NEXT_DROP;
303 next1 = GRE_INPUT_NEXT_DROP;
304 b1->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
310 cached_tunnel_sw_if_index = tunnel_sw_if_index;
322 tunnel_sw_if_index = cached_tunnel_sw_if_index;
327 next1 = GRE_INPUT_NEXT_DROP;
387 to_next, n_left_to_next,
388 bi0, bi1, next0, next1);
391 while (n_left_from > 0 && n_left_to_next > 0)
412 ip6_0 = (
void *) ip4_0;
431 ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE];
435 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
437 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
479 next0 = GRE_INPUT_NEXT_DROP;
480 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
486 cached_tunnel_sw_if_index = tunnel_sw_if_index;
498 tunnel_sw_if_index = cached_tunnel_sw_if_index;
503 next0 = GRE_INPUT_NEXT_DROP;
541 to_next, n_left_to_next,
558 return gre_input (vm, node, from_frame, 0);
565 return gre_input (vm, node, from_frame, 1);
569 #define gre_error(n,s) s, 577 .name =
"gre4-input",
579 .vector_size =
sizeof (
u32),
586 #define _(s,n) [GRE_INPUT_NEXT_##s] = n, 598 .name =
"gre6-input",
600 .vector_size =
sizeof (
u32),
609 #define _(s,n) [GRE_INPUT_NEXT_##s] = n, 648 clib_host_to_net_u16 (protocol));
692 ASSERT (mpls_unicast_input);
uword * tunnel_by_key6
Hash mapping to tunnels with ipv6 src/dst addr.
format_function_t format_gre_header_with_length
static uword gre4_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Transparent Ethernet Bridging - the tunnel is in L2 mode.
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
void ip6_register_protocol(u32 protocol, u32 node_index)
vnet_interface_main_t interface_main
A GRE payload protocol registration.
void ip4_register_protocol(u32 protocol, u32 node_index)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static pg_node_t * pg_get_node(uword node_index)
enum gre_tunnel_type_t_ gre_tunnel_type_t
The GRE tunnel type.
vlib_node_registration_t gre6_input_node
(constructor) VLIB_REGISTER_NODE (gre6_input_node)
static void gre_setup_node(vlib_main_t *vm, u32 node_index)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define foreach_gre_input_next
static char * gre_error_strings[]
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
#define sparse_vec_validate(v, i)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
gre_tunnel_type_t tunnel_type
GRE tunnel type.
static uword gre_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ipv6)
static void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
unformat_function_t unformat_gre_header
#define vlib_call_init_function(vm, x)
u8 * format_gre_rx_trace(u8 *s, va_list *args)
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
uword * tunnel_by_key4
Hash mapping to tunnels with ipv4 src/dst addr.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
A representation of a GRE tunnel.
static int gre_match_key4(const gre_tunnel_key4_t *key1, const gre_tunnel_key4_t *key2)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 node_index
Node which handles this type.
format_function_t * format_buffer
#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.
static int gre_match_key6(const gre_tunnel_key6_t *key1, const gre_tunnel_key6_t *key2)
#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).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static clib_error_t * gre_input_init(vlib_main_t *vm)
static clib_error_t * gre_init(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
void gre_register_input_protocol(vlib_main_t *vm, gre_protocol_t protocol, u32 node_index, gre_tunnel_type_t tunnel_type)
unformat_function_t * unformat_buffer
static void gre_mk_key4(ip4_address_t src, ip4_address_t dst, u32 fib_index, u8 ttype, u16 session_id, gre_tunnel_key4_t *key)
unformat_function_t * unformat_edit
vlib_node_registration_t gre4_input_node
(constructor) VLIB_REGISTER_NODE (gre4_input_node)
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.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static uword sparse_vec_index(void *v, uword sparse_index)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u32 next_index
Next index for this type.
gre_tunnel_t * tunnels
pool of tunnel instances
#define clib_error_report(e)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
next_info_t * next_by_protocol
Union of the two possible key types.
static void gre_mk_key6(const ip6_address_t *src, const ip6_address_t *dst, u32 fib_index, u8 ttype, u16 session_id, gre_tunnel_key6_t *key)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
unformat_function_t unformat_pg_gre_header
#define hash_get_mem(h, key)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static uword gre6_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define SPARSE_VEC_INVALID_INDEX