|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
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,
50 #ifndef CLIB_MARCH_VARIANT
58 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
84 tr->
src.ip6.as_u64[0] =
ip6->src_address.as_u64[0];
85 tr->
src.ip6.as_u64[1] =
ip6->src_address.as_u64[1];
86 tr->
dst.ip6.as_u64[0] =
ip6->dst_address.as_u64[0];
87 tr->
dst.ip6.as_u64[1] =
ip6->dst_address.as_u64[1];
92 tr->
src.as_u64[0] = tr->
src.as_u64[1] = 0;
93 tr->
dst.as_u64[0] = tr->
dst.as_u64[1] = 0;
94 tr->
src.ip4.as_u32 =
ip4->src_address.as_u32;
95 tr->
dst.ip4.as_u32 =
ip4->dst_address.as_u32;
110 *
next = GRE_INPUT_NEXT_DROP;
111 b->
error =
node->errors[GRE_ERROR_NO_SUCH_TUNNEL];
112 *tun_sw_if_index = ~0;
118 *cached_tun_sw_if_index = *tun_sw_if_index =
tun->sw_if_index;
135 u16 cached_protocol = ~0;
137 u32 cached_tun_sw_if_index = ~0;
161 u32 tun_sw_if_index[2];
176 gre[0] = (
void *) (
ip6[0] + 1);
177 gre[1] = (
void *) (
ip6[1] + 1);
186 gre[0] = (
void *) (
ip4[0] + 1);
187 gre[1] = (
void *) (
ip4[1] + 1);
194 nidx[0] = cached_next_index;
198 cached_next_index = nidx[0] =
204 nidx[1] = cached_next_index;
208 cached_next_index = nidx[1] =
213 ni[0] =
vec_elt (
gm->next_by_protocol, nidx[0]);
214 ni[1] =
vec_elt (
gm->next_by_protocol, nidx[1]);
221 ?
node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
222 :
node->errors[GRE_ERROR_NONE];
224 ?
node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
225 :
node->errors[GRE_ERROR_NONE];
227 version[0] = clib_net_to_host_u16 (gre[0]->flags_and_version);
228 version[1] = clib_net_to_host_u16 (gre[1]->flags_and_version);
233 ?
node->errors[GRE_ERROR_UNSUPPORTED_VERSION] :
b[0]->
error;
236 ?
node->errors[GRE_ERROR_UNSUPPORTED_VERSION] :
b[1]->
error;
248 type[0], TUNNEL_MODE_P2P, 0, &
key[0].gtk_v6);
252 type[1], TUNNEL_MODE_P2P, 0, &
key[1].gtk_v6);
261 type[0], TUNNEL_MODE_P2P, 0, &
key[0].gtk_v4);
265 type[1], TUNNEL_MODE_P2P, 0, &
key[1].gtk_v4);
270 tun_sw_if_index[0] = cached_tun_sw_if_index;
271 tun_sw_if_index[1] = cached_tun_sw_if_index;
274 &tun_sw_if_index[0], &cached_tun_sw_if_index,
278 &tun_sw_if_index[1], &cached_tun_sw_if_index,
284 interface_main.combined_sw_if_counters
295 interface_main.combined_sw_if_counters
331 u32 tun_sw_if_index[1];
343 gre[0] = (
void *) (
ip6[0] + 1);
350 gre[0] = (
void *) (
ip4[0] + 1);
356 nidx[0] = cached_next_index;
360 cached_next_index = nidx[0] =
365 ni[0] =
vec_elt (
gm->next_by_protocol, nidx[0]);
370 ?
node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
371 :
node->errors[GRE_ERROR_NONE];
373 version[0] = clib_net_to_host_u16 (gre[0]->flags_and_version);
377 ?
node->errors[GRE_ERROR_UNSUPPORTED_VERSION] :
b[0]->
error;
387 type[0], TUNNEL_MODE_P2P, 0, &
key[0].gtk_v6);
395 type[0], TUNNEL_MODE_P2P, 0, &
key[0].gtk_v4);
399 tun_sw_if_index[0] = cached_tun_sw_if_index;
402 &tun_sw_if_index[0], &cached_tun_sw_if_index,
408 interface_main.combined_sw_if_counters
435 return frame->n_vectors;
453 #define gre_error(n,s) s,
460 .name =
"gre4-input",
462 .vector_size =
sizeof (
u32),
469 #define _(s,n) [GRE_INPUT_NEXT_##s] = n,
480 .name =
"gre6-input",
482 .vector_size =
sizeof (
u32),
491 #define _(s,n) [GRE_INPUT_NEXT_##s] = n,
502 #ifndef CLIB_MARCH_VARIANT
548 vlib_node_t *ethernet_input, *ip4_input, *ip6_input, *mpls_unicast_input;
561 (
sizeof (
gm->next_by_protocol[0]),
572 ASSERT (mpls_unicast_input);
575 ethernet_input->
index, GRE_TUNNEL_TYPE_TEB);
578 ip4_input->
index, GRE_TUNNEL_TYPE_L3);
581 ip6_input->
index, GRE_TUNNEL_TYPE_L3);
584 mpls_unicast_input->
index, GRE_TUNNEL_TYPE_L3);
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_get_buffers(vm, from, b, n_left_from)
vlib_main_t vlib_node_runtime_t * node
static void gre_mk_key6(const ip6_address_t *src, const ip6_address_t *dst, u32 fib_index, gre_tunnel_type_t ttype, tunnel_mode_t tmode, u16 session_id, gre_tunnel_key6_t *key)
A GRE payload protocol registration.
void gre_register_input_protocol(vlib_main_t *vm, gre_protocol_t protocol, u32 node_index, gre_tunnel_type_t tunnel_type)
#define vlib_call_init_function(vm, x)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static uword gre_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, const int is_ipv6)
static int gre_match_key6(const gre_tunnel_key6_t *key1, const gre_tunnel_key6_t *key2)
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
u8 * format_gre_rx_trace(u8 *s, va_list *args)
#define clib_error_report(e)
unformat_function_t unformat_pg_gre_header
unformat_function_t * unformat_buffer
#define SPARSE_VEC_INVALID_INDEX
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
unformat_function_t unformat_gre_header
static void gre_tunnel_get(const gre_main_t *gm, vlib_node_runtime_t *node, vlib_buffer_t *b, u16 *next, const gre_tunnel_key_t *key, gre_tunnel_key_t *cached_key, u32 *tun_sw_if_index, u32 *cached_tun_sw_if_index, int is_ipv6)
static int gre_match_key4(const gre_tunnel_key4_t *key1, const gre_tunnel_key4_t *key2)
#define vec_elt(v, i)
Get vector value at index i.
vlib_node_registration_t gre4_input_node
(constructor) VLIB_REGISTER_NODE (gre4_input_node)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
format_function_t * format_buffer
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static clib_error_t * gre_init(vlib_main_t *vm)
#define sparse_vec_validate(v, i)
#define VLIB_NODE_FN(node)
enum gre_tunnel_type_t_ gre_tunnel_type_t
The GRE tunnel type.
unformat_function_t * unformat_edit
gre_tunnel_type_t tunnel_type
GRE tunnel type.
static void gre_setup_node(vlib_main_t *vm, u32 node_index)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static char * gre_error_strings[]
static pg_node_t * pg_get_node(uword node_index)
static uword sparse_vec_index(void *v, uword sparse_index)
A representation of a GRE tunnel.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define foreach_gre_input_next
u32 node_index
Node which handles this type.
@ VNET_INTERFACE_COUNTER_RX
struct _vlib_node_registration vlib_node_registration_t
u32 next_index
Next index for this type.
#define hash_get_mem(h, key)
next_info_t * next_by_protocol
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static void gre_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, u32 tun_sw_if_index, const ip6_header_t *ip6, const ip4_header_t *ip4, int is_ipv6)
description fragment has unexpected format
static clib_error_t * gre_input_init(vlib_main_t *vm)
format_function_t format_ip46_address
#define VLIB_INIT_FUNCTION(x)
vl_api_ip_proto_t protocol
vlib_node_registration_t gre6_input_node
(constructor) VLIB_REGISTER_NODE (gre6_input_node)
static void gre_mk_key4(ip4_address_t src, ip4_address_t dst, u32 fib_index, gre_tunnel_type_t ttype, tunnel_mode_t tmode, u16 session_id, gre_tunnel_key4_t *key)
Union of the two possible key types.
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
u16 nexts[VLIB_FRAME_SIZE]
vl_api_address_union_t src_address
vl_api_gbp_endpoint_tun_t tun
vl_api_fib_path_type_t type
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
#define vlib_prefetch_buffer_data(b, type)
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
vl_api_wireguard_peer_flags_t flags
format_function_t format_gre_header_with_length