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") 33 #define _(s,n) GRE_INPUT_NEXT_##s, 52 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
72 __attribute__((unused))
u32 n_left_from, next_index, * from, * to_next;
73 u64 cached_tunnel_key = (
u64) ~0;
74 u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index = 0;
85 while (n_left_from > 0)
90 to_next, n_left_to_next);
92 while (n_left_from >= 4 && n_left_to_next >= 2)
97 u16 version0, version1;
99 u32 i0, i1, next0, next1, protocol0, protocol1;
160 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
162 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
163 b1->
error = verr1 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
165 next1 = verr1 ? GRE_INPUT_NEXT_DROP : next1;
170 || next0 == GRE_INPUT_NEXT_IP6_INPUT
171 || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
172 || next0 == GRE_INPUT_NEXT_MPLS_INPUT))
177 if (cached_tunnel_key != key)
186 next0 = GRE_INPUT_NEXT_DROP;
187 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
195 cached_tunnel_sw_if_index = tunnel_sw_if_index;
199 tunnel_sw_if_index = cached_tunnel_sw_if_index;
204 next0 = GRE_INPUT_NEXT_DROP;
219 || next1 == GRE_INPUT_NEXT_IP6_INPUT
220 || next1 == GRE_INPUT_NEXT_ETHERNET_INPUT
221 || next1 == GRE_INPUT_NEXT_MPLS_INPUT))
226 if (cached_tunnel_key != key)
235 next1 = GRE_INPUT_NEXT_DROP;
236 b1->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
244 cached_tunnel_sw_if_index = tunnel_sw_if_index;
248 tunnel_sw_if_index = cached_tunnel_sw_if_index;
253 next1 = GRE_INPUT_NEXT_DROP;
291 to_next, n_left_to_next,
292 bi0, bi1, next0, next1);
295 while (n_left_from > 0 && n_left_to_next > 0)
327 ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE];
331 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
333 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
341 || next0 == GRE_INPUT_NEXT_IP6_INPUT
342 || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
343 || next0 == GRE_INPUT_NEXT_MPLS_INPUT))
348 if (cached_tunnel_key != key)
357 next0 = GRE_INPUT_NEXT_DROP;
358 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
366 cached_tunnel_sw_if_index = tunnel_sw_if_index;
370 tunnel_sw_if_index = cached_tunnel_sw_if_index;
375 next0 = GRE_INPUT_NEXT_DROP;
402 to_next, n_left_to_next,
409 GRE_ERROR_PKTS_DECAP, from_frame->
n_vectors);
414 #define gre_error(n,s) s, 423 .vector_size =
sizeof (
u32),
427 .n_errors = GRE_N_ERROR,
432 #define _(s,n) [GRE_INPUT_NEXT_##s] = n, 469 clib_host_to_net_u16 (protocol));
512 ASSERT(mpls_unicast_input);
515 ethernet_input->
index);
524 mpls_unicast_input->
index);
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.
format_function_t format_gre_header_with_length
vnet_interface_main_t interface_main
uword * tunnel_by_key
Hash mapping src/dst addr pair to tunnel.
A GRE payload protocol registration.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_error_report(e)
void ip4_register_protocol(u32 protocol, u32 node_index)
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)
#define VLIB_INIT_FUNCTION(x)
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
#define sparse_vec_validate(v, i)
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)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
A representation of a GRE tunnel.
static uword gre_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
uword os_get_cpu_number(void)
u32 node_index
Node which handles this type.
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
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.
#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).
void gre_register_input_protocol(vlib_main_t *vm, gre_protocol_t protocol, u32 node_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 char * gre_error_strings[]
static clib_error_t * gre_init(vlib_main_t *vm)
static uword ethernet_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define CLIB_PREFETCH(addr, size, type)
u8 * format_gre_rx_trace(u8 *s, va_list *args)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
unformat_function_t * unformat_buffer
unformat_function_t * unformat_edit
static void gre_setup_node(vlib_main_t *vm, u32 node_index)
static clib_error_t * gre_input_init(vlib_main_t *vm)
static uword sparse_vec_index(void *v, uword sparse_index)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
#define foreach_gre_input_next
u32 next_index
Next index for this type.
gre_tunnel_t * tunnels
pool of tunnel instances
VLIB_NODE_FUNCTION_MULTIARCH(dpdk_input_node, dpdk_input)
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
#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)
#define vec_elt(v, i)
Get vector value at index i.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
unformat_function_t unformat_pg_gre_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
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_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