|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
16 #ifndef included_hdr_offset_parser_h
17 #define included_hdr_offset_parser_h
27 #define foreach_gho_flag \
39 _( 11, IPIP6_TUNNEL) \
44 #define _(bit, name) GHO_F_##name = (1 << bit),
49 #define GHO_F_TUNNEL (GHO_F_VXLAN_TUNNEL | \
50 GHO_F_GENEVE_TUNNEL | \
52 GHO_F_IPIP6_TUNNEL | \
55 #define GHO_F_OUTER_HDR (GHO_F_OUTER_IP4 | \
60 #define GHO_F_INNER_HDR (GHO_F_IP4 | \
88 s =
format (s,
"vxlan-tunnel ");
89 else if (gho->
gho_flags & GHO_F_IPIP_TUNNEL)
90 s =
format (s,
"ipip-tunnel ");
91 else if (gho->
gho_flags & GHO_F_GRE_TUNNEL)
92 s =
format (s,
"gre-tunnel ");
93 else if (gho->
gho_flags & GHO_F_GENEVE_TUNNEL)
94 s =
format (s,
"geneve-tunnel ");
97 s =
format (s,
"outer-ipv4 ");
98 else if (gho->
gho_flags & GHO_F_OUTER_IP6)
99 s =
format (s,
"outer-ipv6 ");
102 s =
format (s,
"outer-udp ");
103 else if (gho->
gho_flags & GHO_F_OUTER_TCP)
104 s =
format (s,
"outer-tcp ");
106 s =
format (s,
"outer-hdr-sz %u outer-l2-hdr-offset %d "
107 "outer-l3-hdr-offset %d outer-l4-hdr-offset %d "
108 "outer-l4-hdr-sz %u\n\t",
124 s =
format (s,
"hdr-sz %u l2-hdr-offset %d "
125 "l3-hdr-offset %d l4-hdr-offset %d "
156 if ((gho->
gho_flags & GHO_F_GENEVE_TUNNEL) == 0)
167 if ((gho->
gho_flags & GHO_F_GRE_TUNNEL) == 0)
177 if ((gho->
gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL)) == 0)
215 l4_proto =
ip4->protocol;
223 l4_proto =
ip6->protocol;
226 if (l4_proto == IP_PROTOCOL_TCP)
235 else if (l4_proto == IP_PROTOCOL_UDP)
239 l4_hdr_sz =
sizeof (*udp);
257 if ((gho->
gho_flags & GHO_F_VXLAN_TUNNEL) == 0)
293 u16 ethertype = clib_net_to_host_u16 (eh->
type);
300 ethertype = clib_net_to_host_u16 (vlan->
type);
301 l2hdr_sz +=
sizeof (*vlan);
302 if (ethertype == ETHERNET_TYPE_VLAN)
305 ethertype = clib_net_to_host_u16 (vlan->
type);
306 l2hdr_sz +=
sizeof (*vlan);
317 l4_proto =
ip4->protocol;
326 l4_proto =
ip6->protocol;
329 if (l4_proto == IP_PROTOCOL_TCP)
338 else if (l4_proto == IP_PROTOCOL_UDP)
342 l4_hdr_sz =
sizeof (*udp);
360 else if (gho->
gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL))
362 else if (gho->
gho_flags & GHO_F_GRE_TUNNEL)
364 else if (gho->
gho_flags & GHO_F_GENEVE_TUNNEL)
371 int is_l2,
int is_ip4,
int is_ip6)
384 ethertype = clib_net_to_host_u16 (eh->
type);
391 ethertype = clib_net_to_host_u16 (vlan->
type);
392 l2hdr_sz +=
sizeof (*vlan);
393 if (ethertype == ETHERNET_TYPE_VLAN)
396 ethertype = clib_net_to_host_u16 (vlan->
type);
397 l2hdr_sz +=
sizeof (*vlan);
402 l2hdr_sz =
vnet_buffer (b0)->ip.save_rewrite_length;
412 l4_proto =
ip4->protocol;
421 l4_proto =
ip6->protocol;
424 if (l4_proto == IP_PROTOCOL_TCP)
432 else if (l4_proto == IP_PROTOCOL_UDP)
436 l4_hdr_sz =
sizeof (*udp);
440 if (UDP_DST_PORT_vxlan == clib_net_to_host_u16 (udp->
dst_port))
445 else if (UDP_DST_PORT_geneve == clib_net_to_host_u16 (udp->
dst_port))
450 else if (l4_proto == IP_PROTOCOL_IP_IN_IP)
455 else if (l4_proto == IP_PROTOCOL_IPV6)
460 else if (l4_proto == IP_PROTOCOL_GRE)
static int tcp_header_bytes(tcp_header_t *t)
static_always_inline u8 * format_generic_header_offset(u8 *s, va_list *args)
static_always_inline int ethernet_frame_is_tagged(u16 type)
struct _tcp_header tcp_header_t
static_always_inline void vnet_ipip_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline void vnet_generic_outer_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho, int is_l2, int is_ip4, int is_ip6)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static_always_inline void vnet_geneve_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline void vnet_generic_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline void vnet_vxlan_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
#define static_always_inline
static_always_inline void vnet_get_outer_header(vlib_buffer_t *b0, generic_header_offset_t *gho)
description fragment has unexpected format
enum gho_flag_t_ gho_flag_t
static_always_inline void vnet_get_inner_header(vlib_buffer_t *b0, generic_header_offset_t *gho)
static_always_inline void vnet_generic_header_offset_parser(vlib_buffer_t *b0, generic_header_offset_t *gho, int is_l2, int is_ip4, int is_ip6)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void vnet_gre_inner_header_parser_inline(vlib_buffer_t *b0, generic_header_offset_t *gho)
VLIB buffer representation.