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",
65 __attribute__((unused))
u32 n_left_from, next_index, * from, * to_next;
66 u64 cached_tunnel_key = (
u64) ~0;
67 u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index = 0;
78 while (n_left_from > 0)
83 to_next, n_left_to_next);
85 while (n_left_from >= 4 && n_left_to_next >= 2)
90 u16 version0, version1;
92 u32 i0, i1, next0, next1, protocol0, protocol1;
153 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
155 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
156 b1->
error = verr1 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
158 next1 = verr1 ? GRE_INPUT_NEXT_DROP : next1;
163 || next0 == GRE_INPUT_NEXT_IP6_INPUT
164 || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
165 || next0 == GRE_INPUT_NEXT_MPLS_INPUT))
170 if (cached_tunnel_key != key)
179 next0 = GRE_INPUT_NEXT_DROP;
180 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
188 cached_tunnel_sw_if_index = tunnel_sw_if_index;
192 tunnel_sw_if_index = cached_tunnel_sw_if_index;
197 next0 = GRE_INPUT_NEXT_DROP;
212 || next1 == GRE_INPUT_NEXT_IP6_INPUT
213 || next1 == GRE_INPUT_NEXT_ETHERNET_INPUT
214 || next1 == GRE_INPUT_NEXT_MPLS_INPUT))
219 if (cached_tunnel_key != key)
228 next1 = GRE_INPUT_NEXT_DROP;
229 b1->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
237 cached_tunnel_sw_if_index = tunnel_sw_if_index;
241 tunnel_sw_if_index = cached_tunnel_sw_if_index;
246 next1 = GRE_INPUT_NEXT_DROP;
284 to_next, n_left_to_next,
285 bi0, bi1, next0, next1);
288 while (n_left_from > 0 && n_left_to_next > 0)
320 ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE];
324 b0->
error = verr0 ? node->
errors[GRE_ERROR_UNSUPPORTED_VERSION]
326 next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
334 || next0 == GRE_INPUT_NEXT_IP6_INPUT
335 || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT
336 || next0 == GRE_INPUT_NEXT_MPLS_INPUT))
341 if (cached_tunnel_key != key)
350 next0 = GRE_INPUT_NEXT_DROP;
351 b0->
error = node->
errors[GRE_ERROR_NO_SUCH_TUNNEL];
359 cached_tunnel_sw_if_index = tunnel_sw_if_index;
363 tunnel_sw_if_index = cached_tunnel_sw_if_index;
368 next0 = GRE_INPUT_NEXT_DROP;
395 to_next, n_left_to_next,
402 GRE_ERROR_PKTS_DECAP, from_frame->
n_vectors);
407 #define gre_error(n,s) s, 416 .vector_size =
sizeof (
u32),
423 #define _(s,n) [GRE_INPUT_NEXT_##s] = n, 458 clib_host_to_net_u16 (protocol));
499 ASSERT(mpls_unicast_input);
502 ethernet_input->
index);
511 mpls_unicast_input->
index);
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.
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.
A GRE payload protocol registration.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
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)
static void gre_setup_node(vlib_main_t *vm, u32 node_index)
#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.
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 pool_elt_at_index(p, i)
Returns pointer to element at given index.
A representation of a GRE tunnel.
uword os_get_cpu_number(void)
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.
#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).
static uword gre_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
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 CLIB_PREFETCH(addr, size, type)
#define VLIB_BUFFER_IS_TRACED
unformat_function_t * unformat_buffer
unformat_function_t * unformat_edit
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.
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
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.
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.
void gre_register_input_protocol(vlib_main_t *vm, gre_protocol_t protocol, u32 node_index)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
unformat_function_t unformat_pg_gre_header
static uword ethernet_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#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)
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
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.
VLIB_NODE_FUNCTION_MULTIARCH(ethernet_input_not_l2_node, ethernet_input_not_l2)
#define SPARSE_VEC_INVALID_INDEX