27 #define foreach_ipsec_gre_input_next \ 28 _(PUNT, "error-punt") \ 29 _(DROP, "error-drop") \ 30 _(L2_INPUT, "l2-input") 33 #define _(s,n) IPSEC_GRE_INPUT_NEXT_##s, 52 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
91 u32 n_left_from, next_index, * from, * to_next;
92 u64 cached_tunnel_key = (
u64) ~0;
93 u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index;
94 u32 tun_src0, tun_dst0;
95 u32 tun_src1, tun_dst1;
98 n_left_from = from_frame->n_vectors;
100 next_index = node->cached_next_index;
102 while (n_left_from > 0)
107 to_next, n_left_to_next);
109 while (n_left_from >= 4 && n_left_to_next >= 2)
114 u16 version0, version1, protocol0, protocol1;
161 protocol0 = clib_net_to_host_u16 (h0->
protocol);
162 protocol1 = clib_net_to_host_u16 (h1->
protocol);
165 next0 = IPSEC_GRE_INPUT_NEXT_L2_INPUT;
166 b0->
error = node->errors[IPSEC_GRE_ERROR_NONE];
170 b0->
error = node->errors[IPSEC_GRE_ERROR_UNKNOWN_PROTOCOL];
171 next0 = IPSEC_GRE_INPUT_NEXT_DROP;
175 next1 = IPSEC_GRE_INPUT_NEXT_L2_INPUT;
176 b1->
error = node->errors[IPSEC_GRE_ERROR_NONE];
180 b1->
error = node->errors[IPSEC_GRE_ERROR_UNKNOWN_PROTOCOL];
181 next1 = IPSEC_GRE_INPUT_NEXT_DROP;
189 b0->
error = verr0 ? node->errors[IPSEC_GRE_ERROR_UNSUPPORTED_VERSION]
191 next0 = verr0 ? IPSEC_GRE_INPUT_NEXT_DROP : next0;
192 b1->
error = verr1 ? node->errors[IPSEC_GRE_ERROR_UNSUPPORTED_VERSION]
194 next1 = verr1 ? IPSEC_GRE_INPUT_NEXT_DROP : next1;
197 if (
PREDICT_TRUE(next0 == IPSEC_GRE_INPUT_NEXT_L2_INPUT))
201 if (cached_tunnel_key != key)
210 next0 = IPSEC_GRE_INPUT_NEXT_DROP;
211 b0->
error = node->errors[IPSEC_GRE_ERROR_NO_SUCH_TUNNEL];
218 cached_tunnel_sw_if_index = tunnel_sw_if_index;
222 tunnel_sw_if_index = cached_tunnel_sw_if_index;
229 if (
PREDICT_TRUE(next1 == IPSEC_GRE_INPUT_NEXT_L2_INPUT))
233 if (cached_tunnel_key != key)
242 next1 = IPSEC_GRE_INPUT_NEXT_DROP;
243 b1->
error = node->errors[IPSEC_GRE_ERROR_NO_SUCH_TUNNEL];
250 cached_tunnel_sw_if_index = tunnel_sw_if_index;
254 tunnel_sw_if_index = cached_tunnel_sw_if_index;
284 to_next, n_left_to_next,
285 bi0, bi1, next0, next1);
288 while (n_left_from > 0 && n_left_to_next > 0)
294 u16 version0, protocol0;
297 u32 tun_src0, tun_dst0;
316 protocol0 = clib_net_to_host_u16 (h0->
protocol);
319 next0 = IPSEC_GRE_INPUT_NEXT_L2_INPUT;
320 b0->
error = node->errors[IPSEC_GRE_ERROR_NONE];
324 b0->
error = node->errors[IPSEC_GRE_ERROR_UNKNOWN_PROTOCOL];
325 next0 = IPSEC_GRE_INPUT_NEXT_DROP;
330 b0->
error = verr0 ? node->errors[IPSEC_GRE_ERROR_UNSUPPORTED_VERSION]
332 next0 = verr0 ? IPSEC_GRE_INPUT_NEXT_DROP : next0;
335 if (
PREDICT_TRUE(next0 == IPSEC_GRE_INPUT_NEXT_L2_INPUT))
339 if (cached_tunnel_key != key)
348 next0 = IPSEC_GRE_INPUT_NEXT_DROP;
349 b0->
error = node->errors[IPSEC_GRE_ERROR_NO_SUCH_TUNNEL];
356 cached_tunnel_sw_if_index = tunnel_sw_if_index;
360 tunnel_sw_if_index = cached_tunnel_sw_if_index;
379 to_next, n_left_to_next,
386 IPSEC_GRE_ERROR_PKTS_DECAP, from_frame->n_vectors);
387 return from_frame->n_vectors;
391 #define ipsec_gre_error(n,s) s, 393 #undef ipsec_gre_error 397 .name =
"ipsec-gre-input",
399 .vector_size =
sizeof (
u32),
406 #define _(s,n) [IPSEC_GRE_INPUT_NEXT_##s] = n, u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vlib_node_registration_t ipsec_gre_input_node
(constructor) VLIB_REGISTER_NODE (ipsec_gre_input_node)
L2-GRE over IPSec packet processing.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VLIB_NODE_FN(node)
static clib_error_t * ipsec_gre_init(vlib_main_t *vm)
ipsec_gre_tunnel_t * tunnels
pool of tunnel instances
#define foreach_ipsec_gre_input_next
#define VLIB_INIT_FUNCTION(x)
ipsec_gre_main_t ipsec_gre_main
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vlib_call_init_function(vm, x)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
uword * tunnel_by_key
hash mapping src/dst addr pair to tunnel
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static clib_error_t * ipsec_gre_input_init(vlib_main_t *vm)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u8 * format_ipsec_gre_rx_trace(u8 *s, va_list *args)
#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 void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
L2-GRE over IPSec errors.
#define CLIB_PREFETCH(addr, size, type)
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.
IPSec-GRE tunnel parameters.
static char * ipsec_gre_error_strings[]
#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.
vnet_main_t * vnet_main
convenience
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.