FD.io VPP
v18.01.2-1-g9b554f3
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
vxlan_gpe_ioam_util.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
#ifndef __included_vxlan_gpe_ioam_util_h__
16
#define __included_vxlan_gpe_ioam_util_h__
17
18
#include <
vnet/vxlan-gpe/vxlan_gpe.h
>
19
#include <
vnet/vxlan-gpe/vxlan_gpe_packet.h
>
20
#include <
vnet/ip/ip.h
>
21
22
23
typedef
struct
24
{
25
u32
tunnel_index
;
26
ioam_trace_t
fmt_trace
;
27
}
vxlan_gpe_ioam_v4_trace_t
;
28
29
30
static
u8
*
31
format_vxlan_gpe_ioam_v4_trace
(
u8
* s, va_list * args)
32
{
33
CLIB_UNUSED
(
vlib_main_t
*
vm
) = va_arg (*args,
vlib_main_t
*);
34
CLIB_UNUSED
(
vlib_node_t
* node) = va_arg (*args,
vlib_node_t
*);
35
vxlan_gpe_ioam_v4_trace_t
*t1 = va_arg (*args,
vxlan_gpe_ioam_v4_trace_t
*);
36
ioam_trace_t
*t = &(t1->
fmt_trace
);
37
vxlan_gpe_ioam_option_t
*fmt_trace0;
38
vxlan_gpe_ioam_option_t
*opt0, *limit0;
39
vxlan_gpe_ioam_main_t
*hm = &
vxlan_gpe_ioam_main
;
40
41
u8
type0;
42
43
fmt_trace0 = (
vxlan_gpe_ioam_option_t
*) t->
option_data
;
44
45
s =
format
(s,
"VXLAN-GPE-IOAM: next_index %d len %d traced %d"
,
46
t->
next_index
, fmt_trace0->
length
, t->
trace_len
);
47
48
opt0 = (
vxlan_gpe_ioam_option_t
*) (fmt_trace0 + 1);
49
limit0 = (
vxlan_gpe_ioam_option_t
*) ((
u8
*) fmt_trace0) + t->
trace_len
;
50
51
while (opt0 < limit0)
52
{
53
type0 = opt0->
type
;
54
switch
(type0)
55
{
56
case
0:
/* Pad, just stop */
57
opt0 = (
vxlan_gpe_ioam_option_t
*) ((
u8
*) opt0) + 1;
58
break
;
59
60
default
:
61
if
(hm->
trace
[type0])
62
{
63
s = (*hm->
trace
[type0]) (s, opt0);
64
}
65
else
66
{
67
s =
68
format
(s,
"\n unrecognized option %d length %d"
, type0,
69
opt0->
length
);
70
}
71
opt0 =
72
(
vxlan_gpe_ioam_option_t
*) (((
u8
*) opt0) + opt0->
length
+
73
sizeof
(
vxlan_gpe_ioam_option_t
));
74
break
;
75
}
76
}
77
78
s =
format
(s,
"VXLAN-GPE-IOAM: tunnel %d"
, t1->
tunnel_index
);
79
return
s;
80
}
81
82
83
always_inline
void
84
vxlan_gpe_encap_decap_ioam_v4_one_inline
(
vlib_main_t
*
vm
,
85
vlib_node_runtime_t
* node,
86
vlib_buffer_t
* b0,
87
u32
* next0,
u32
drop_node_val,
88
u8
use_adj)
89
{
90
ip4_header_t
*ip0;
91
udp_header_t
*udp_hdr0;
92
vxlan_gpe_header_t
*gpe_hdr0;
93
vxlan_gpe_ioam_hdr_t
*gpe_ioam0;
94
vxlan_gpe_ioam_option_t
*opt0;
95
vxlan_gpe_ioam_option_t
*limit0;
96
vxlan_gpe_ioam_main_t
*hm = &
vxlan_gpe_ioam_main
;
97
98
/* Populate the iOAM header */
99
ip0 =
vlib_buffer_get_current
(b0);
100
udp_hdr0 = (
udp_header_t
*) (ip0 + 1);
101
gpe_hdr0 = (
vxlan_gpe_header_t
*) (udp_hdr0 + 1);
102
gpe_ioam0 = (
vxlan_gpe_ioam_hdr_t
*) (gpe_hdr0 + 1);
103
opt0 = (
vxlan_gpe_ioam_option_t
*) (gpe_ioam0 + 1);
104
limit0 = (
vxlan_gpe_ioam_option_t
*) ((
u8
*) gpe_ioam0 + gpe_ioam0->
length
);
105
106
/*
107
* Basic validity checks
108
*/
109
if
(gpe_ioam0->
length
> clib_net_to_host_u16 (ip0->
length
))
110
{
111
*next0 = drop_node_val;
112
return
;
113
}
114
115
/* Scan the set of h-b-h options, process ones that we understand */
116
while
(opt0 < limit0)
117
{
118
u8
type0;
119
type0 = opt0->
type
;
120
switch
(type0)
121
{
122
case
0:
/* Pad1 */
123
opt0 = (
vxlan_gpe_ioam_option_t
*) ((
u8
*) opt0) + 1;
124
continue
;
125
case
1:
/* PadN */
126
break
;
127
default
:
128
if
(hm->
options
[type0])
129
{
130
if
((*hm->
options
[type0]) (b0, opt0, 1
/* is_ipv4 */
,
131
use_adj) < 0)
132
{
133
*next0 = drop_node_val;
134
return
;
135
}
136
}
137
break
;
138
}
139
opt0 =
140
(
vxlan_gpe_ioam_option_t
*) (((
u8
*) opt0) + opt0->
length
+
141
sizeof (
vxlan_gpe_ioam_hdr_t
));
142
}
143
144
145
if
(
PREDICT_FALSE
(b0->
flags
&
VLIB_BUFFER_IS_TRACED
))
146
{
147
vxlan_gpe_ioam_v4_trace_t
*t =
148
vlib_add_trace
(vm, node, b0,
sizeof
(*t));
149
u32
trace_len = gpe_ioam0->
length
;
150
t->
fmt_trace
.
next_index
= *next0;
151
/* Capture the ioam option verbatim */
152
trace_len =
153
trace_len <
154
ARRAY_LEN
(t->
fmt_trace
.
155
option_data) ? trace_len :
ARRAY_LEN
(t->
fmt_trace
.
156
option_data);
157
t->
fmt_trace
.
trace_len
= trace_len;
158
clib_memcpy
(&(t->
fmt_trace
.
option_data
), gpe_ioam0, trace_len);
159
}
160
return
;
161
}
162
163
164
#endif
165
166
/*
167
* fd.io coding-style-patch-verification: ON
168
*
169
* Local Variables:
170
* eval: (c-set-style "gnu")
171
* End:
172
*/
ioam_trace_t::option_data
u8 option_data[256]
Definition:
vxlan_gpe_ioam.h:115
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition:
clib.h:79
vxlan_gpe.h
VXLAN GPE definitions.
format
u8 * format(u8 *s, const char *fmt,...)
Definition:
format.c:419
ip.h
udp_header_t
Definition:
udp_packet.h:43
vlib_node_runtime_t
Definition:
node.h:409
always_inline
#define always_inline
Definition:
clib.h:92
vxlan_gpe_ioam_main
vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main
Definition:
vxlan_gpe_ioam.c:23
vxlan_gpe_ioam_v4_trace_t::fmt_trace
ioam_trace_t fmt_trace
Definition:
vxlan_gpe_ioam_util.h:26
vxlan_gpe_packet.h
VXLAN GPE packet header structure.
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition:
buffer.h:195
ioam_trace_t::trace_len
u32 trace_len
Definition:
vxlan_gpe_ioam.h:114
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition:
clib.h:105
format_vxlan_gpe_ioam_v4_trace
static u8 * format_vxlan_gpe_ioam_v4_trace(u8 *s, va_list *args)
Definition:
vxlan_gpe_ioam_util.h:31
ip4_header_t::length
u16 length
Definition:
ip4_packet.h:138
vxlan_gpe_encap_decap_ioam_v4_one_inline
static void vxlan_gpe_encap_decap_ioam_v4_one_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b0, u32 *next0, u32 drop_node_val, u8 use_adj)
Definition:
vxlan_gpe_ioam_util.h:84
vxlan_gpe_ioam_main_
Definition:
vxlan_gpe_ioam.h:38
vm
vlib_main_t * vm
Definition:
buffer.c:283
vxlan_gpe_ioam_option_t::length
u8 length
Definition:
vxlan_gpe_ioam_packet.h:48
VLIB_BUFFER_IS_TRACED
#define VLIB_BUFFER_IS_TRACED
Definition:
buffer.h:93
vlib_buffer_t
Definition:
buffer.h:62
clib_memcpy
#define clib_memcpy(a, b, c)
Definition:
string.h:75
ARRAY_LEN
#define ARRAY_LEN(x)
Definition:
clib.h:59
ioam_trace_t::next_index
u32 next_index
Definition:
vxlan_gpe_ioam.h:113
u32
unsigned int u32
Definition:
types.h:88
vxlan_gpe_ioam_v4_trace_t::tunnel_index
u32 tunnel_index
Definition:
vxlan_gpe_ioam_util.h:25
vxlan_gpe_ioam_option_t
Definition:
vxlan_gpe_ioam_packet.h:43
vxlan_gpe_ioam_main_::options
int(* options[256])(vlib_buffer_t *b, vxlan_gpe_ioam_option_t *opt, u8 is_ipv4, u8 use_adj)
Definition:
vxlan_gpe_ioam.h:72
vlib_add_trace
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition:
trace_funcs.h:55
vxlan_gpe_ioam_option_t::type
u8 type
Definition:
vxlan_gpe_ioam_packet.h:46
vxlan_gpe_ioam_v4_trace_t
Definition:
vxlan_gpe_ioam_util.h:23
u8
unsigned char u8
Definition:
types.h:56
vxlan_gpe_ioam_hdr_t::length
u8 length
Definition:
vxlan_gpe_ioam_packet.h:33
vlib_main_t
Definition:
main.h:59
vlib_node_t
Definition:
node.h:215
vxlan_gpe_ioam_hdr_t
VXLAN GPE Extension (iOAM) Header definition.
Definition:
vxlan_gpe_ioam_packet.h:30
vxlan_gpe_header_t
VXLAN GPE Header definition.
Definition:
vxlan_gpe_packet.h:94
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition:
buffer.h:75
ip4_header_t
Definition:
ip4_packet.h:126
ioam_trace_t
Definition:
vxlan_gpe_ioam.h:111
vxlan_gpe_ioam_main_::trace
u8 *(* trace[256])(u8 *s, vxlan_gpe_ioam_option_t *opt)
Definition:
vxlan_gpe_ioam.h:74
src
plugins
ioam
lib-vxlan-gpe
vxlan_gpe_ioam_util.h
Generated on Wed Sep 5 2018 06:02:01 for FD.io VPP by
1.8.11