|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
25 #ifndef CLIB_MARCH_VARIANT
64 #ifndef CLIB_MARCH_VARIANT
72 s =
format (s,
"GRE: tunnel %d len %d src %U dst %U",
89 s =
format (s,
"0x%04x", p);
99 u32 max_header_bytes = va_arg (*args,
u32);
101 u32 indent, header_bytes;
103 header_bytes =
sizeof (
h[0]);
104 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
105 return format (s,
"gre header truncated");
111 if (max_header_bytes != 0 && header_bytes < max_header_bytes)
115 if (
node->format_buffer)
118 node->format_buffer, (
void *) (
h + 1),
119 max_header_bytes - header_bytes);
137 u16 *result = va_arg (*args,
u16 *);
143 gm->protocol_info_by_name, &
i))
157 u16 *result = va_arg (*args,
u16 *);
160 *result = clib_host_to_net_u16 ((
u16) * result);
167 u8 **result = va_arg (*args,
u8 **);
174 h->protocol = clib_host_to_net_u16 (p);
194 return (GRE_PROTOCOL_ip4);
196 return (GRE_PROTOCOL_ip6);
198 return (GRE_PROTOCOL_mpls_unicast);
200 return (GRE_PROTOCOL_teb);
202 return (GRE_PROTOCOL_arp);
208 return (GRE_PROTOCOL_ip4);
217 const ip46_address_t *
dst;
218 ip4_and_gre_header_t *h4;
219 ip6_and_gre_header_t *h6;
240 h4 = (ip4_and_gre_header_t *)
rewrite;
242 h4->ip4.ip_version_and_header_length = 0x45;
246 h4->ip4.src_address.as_u32 = t->
tunnel_src.ip4.as_u32;
247 h4->ip4.dst_address.as_u32 =
dst->ip4.as_u32;
253 h6 = (ip6_and_gre_header_t *)
rewrite;
255 h6->ip6.ip_version_traffic_class_and_flow_label =
256 clib_host_to_net_u32 (6 << 28);
257 h6->ip6.hop_limit = 255;
258 h6->ip6.protocol = IP_PROTOCOL_GRE;
260 h6->ip6.src_address.as_u64[0] = t->
tunnel_src.ip6.as_u64[0];
261 h6->ip6.src_address.as_u64[1] = t->
tunnel_src.ip6.as_u64[1];
262 h6->ip6.dst_address.as_u64[0] =
dst->ip6.as_u64[0];
263 h6->ip6.dst_address.as_u64[1] =
dst->ip6.as_u64[1];
268 gre->
protocol = clib_host_to_net_u16 (GRE_PROTOCOL_erspan);
283 ip4_and_gre_header_t *ip0;
301 ip4_and_gre_header_t *ip0;
333 ip6_and_gre_header_t *ip0;
340 ip0->ip6.payload_length =
351 ip6_and_gre_header_t *ip0;
358 ip0->ip6.payload_length =
368 ip6_and_gre_header_t *ip0;
374 ip0->ip6.payload_length =
420 if (!(t->
flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
449 if (!(
ctx->t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
551 gt[0] = &
gm->tunnels[
hi->dev_instance];
560 gt[1] = &
gm->tunnels[
hi->dev_instance];
567 if (
type == GRE_TUNNEL_TYPE_ERSPAN)
577 h0->seq_num = clib_host_to_net_u32 (seq_num);
579 h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[0]->
session_id);
581 if (
type == GRE_TUNNEL_TYPE_ERSPAN)
591 h0->seq_num = clib_host_to_net_u32 (seq_num);
593 h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[1]->
session_id);
628 gt[0] = &
gm->tunnels[
hi->dev_instance];
634 if (
type == GRE_TUNNEL_TYPE_ERSPAN)
640 ASSERT (gt[0]->
type == GRE_TUNNEL_TYPE_ERSPAN);
645 h0->seq_num = clib_host_to_net_u32 (seq_num);
647 h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[0]->
session_id);
669 GRE_ERROR_PKTS_ENCAP,
frame->n_vectors);
671 return frame->n_vectors;
675 #define gre_error(n,s) s,
697 .name =
"gre-teb-encap",
698 .vector_size =
sizeof (
u32),
710 .name =
"gre-erspan-encap",
711 .vector_size =
sizeof (
u32),
723 #ifndef CLIB_MARCH_VARIANT
727 u32 dev_instance = va_arg (*args,
u32);
731 if (dev_instance >=
vec_len (
gm->tunnels))
732 return format (s,
"<improperly-referenced>");
741 u32 dev_instance = va_arg (*args,
u32);
744 s =
format (s,
"GRE tunnel: id %d\n", dev_instance);
750 ip46_address_t *
src, ip46_address_t *
dst,
u8 * is_l2)
766 *is_l2 = t->
type == GRE_TUNNEL_TYPE_TEB;
773 .name =
"GRE tunnel device",
811 i = pi -
gm->protocol_infos;
813 pi->
name = protocol_name;
856 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
@ ADJ_FLAG_MIDCHAIN_NO_COUNT
static u8 * format_gre_tunnel_name(u8 *s, va_list *args)
vnet_interface_main_t * im
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
#define hash_set(h, key, value)
teib_entry_t * teib_entry_find_46(u32 sw_if_index, fib_protocol_t fproto, const ip46_address_t *peer)
Key for a IPv6 GRE Tunnel We use a different type so that the V4 key hash is as small as possible.
char * name
Name (a c string).
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
enum tunnel_encap_decap_flags_t_ tunnel_encap_decap_flags_t
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u8 * format_gre_tx_trace(u8 *s, va_list *args)
void mgre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
#define clib_memcpy(d, s, n)
static uword pointer_to_uword(const void *p)
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define GRE_FLAGS_SEQUENCE
void(* adj_midchain_fixup_t)(vlib_main_t *vm, const struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
A function type for post-rewrite fixups on midchain adjacency.
vlib_get_buffers(vm, from, b, n_left_from)
@ VLIB_NODE_TYPE_INTERNAL
static u8 * gre_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
vlib_main_t vlib_node_runtime_t * node
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
#define hash_create_string(elts, value_bytes)
format_function_t * format_header
adj_walk_rc_t mgre_mk_incomplete_walk(adj_index_t ai, void *data)
A GRE payload protocol registration.
#define hash_set_mem(h, key, value)
gre_protocol_t protocol
GRE protocol type in host byte order.
tunnel_encap_decap_flags_t flags
#define vlib_call_init_function(vm, x)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static_always_inline void tunnel_encap_fixup_6o4(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip4_header_t *outer)
uword unformat_gre_protocol_net_byte_order(unformat_input_t *input, va_list *args)
static void gre66_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
unformat_function_t unformat_pg_gre_header
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
const fib_prefix_t * teib_entry_get_nh(const teib_entry_t *te)
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
fib_prefix_t tunnel_dst
The tunnel's destination/remote address.
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
static adj_midchain_fixup_t gre_get_fixup(fib_protocol_t fproto, vnet_link_t lt)
return the appropriate fixup function given the overlay (link-type) and underlay (fproto) combination
static_always_inline void vlib_buffer_enqueue_to_single_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 next_index, u32 count)
static_always_inline void tunnel_encap_fixup_6o6(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip6_header_t *outer)
adj_walk_rc_t mgre_mk_complete_walk(adj_index_t ai, void *data)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define hash_create_mem(elts, key_bytes, value_bytes)
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * gre_init(vlib_main_t *vm)
adj_index_t l2_adj_index
an L2 tunnel always rquires an L2 midchain.
#define VLIB_NODE_FN(node)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
enum gre_tunnel_type_t_ gre_tunnel_type_t
The GRE tunnel type.
ip6_and_gre_header_t ip6_and_gre
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vnet_main_t * vnet_get_main(void)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define static_always_inline
static clib_error_t * ip4_lookup_init(vlib_main_t *vm)
u8 * format_gre_protocol(u8 *s, va_list *args)
A representation of a GRE tunnel.
u8 * format_gre_header_with_length(u8 *s, va_list *args)
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.
u32 node_index
Node which handles this type.
static_always_inline u32 gre_encap_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, gre_tunnel_type_t type)
TX function.
uword unformat_gre_header(unformat_input_t *input, va_list *args)
static_always_inline void tunnel_encap_fixup_4o4(tunnel_encap_decap_flags_t flags, const ip4_header_t *inner, ip4_header_t *outer)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip46_address_t tunnel_src
The tunnel's source/local address.
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
vlib_node_registration_t gre_teb_encap_node
(constructor) VLIB_REGISTER_NODE (gre_teb_encap_node)
Key for a IPv4 GRE Tunnel.
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
clib_error_t * ip_main_init(vlib_main_t *vm)
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
struct _vlib_node_registration vlib_node_registration_t
static void grex6_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
#define clib_atomic_fetch_add(a, b)
u32 next_index
Next index for this type.
union ip_adjacency_t_::@144 sub_type
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
vnet_hw_interface_class_t gre_hw_interface_class
static int gre_proto_from_vnet_link(vnet_link_t link)
static int gre_tunnel_desc(u32 sw_if_index, ip46_address_t *src, ip46_address_t *dst, u8 *is_l2)
description fragment has unexpected format
static clib_error_t * gre_input_init(vlib_main_t *vm)
format_function_t format_ip46_address
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
#define VLIB_INIT_FUNCTION(x)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vl_api_address_family_t af
vl_api_ip_proto_t protocol
static char * gre_error_strings[]
static void grex4_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
fib_protocol_t fp_proto
protocol type
u32 adj_index_t
An index for adjacencies.
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)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void gre46_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u16 ip4_header_checksum(ip4_header_t *i)
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define uword_to_pointer(u, type)
void teib_entry_adj_stack(const teib_entry_t *te, adj_index_t ai)
struct ip_adjacency_t_::@144::@145 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
@ VNET_HW_INTERFACE_CLASS_FLAG_P2P
a point 2 point interface
@ GRE_ENCAP_NEXT_L2_MIDCHAIN
VNET_HW_INTERFACE_CLASS(gre_hw_interface_class)
static void gre64_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
static u8 * format_gre_device(u8 *s, va_list *args)
@ VNET_HW_INTERFACE_CLASS_FLAG_NBMA
a non-broadcast multiple access interface
Hash key for GRE header seq number generation for ERSPAN encap.
static void gre44_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
static_always_inline void tunnel_encap_fixup_4o6(tunnel_encap_decap_flags_t flags, const vlib_buffer_t *b, const ip4_header_t *inner, ip6_header_t *outer)
VNET_DEVICE_CLASS(gre_device_class)
vlib_node_registration_t gre_erspan_encap_node
(constructor) VLIB_REGISTER_NODE (gre_erspan_encap_node)
u8 * format_gre_header(u8 *s, va_list *args)
ip4_and_gre_header_t ip4_and_gre
vl_api_interface_index_t sw_if_index
#define hash_create(elts, value_bytes)
unformat_function_t * unformat_pg_edit
vnet_hw_interface_class_t mgre_hw_interface_class
@ ADJ_FLAG_MIDCHAIN_IP_STACK
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
vl_api_fib_path_type_t type
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
vnet_device_class_t gre_device_class
vl_api_wireguard_peer_flags_t flags