FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
geneve.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 SUSE LLC.
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_vnet_geneve_h
16 #define included_vnet_geneve_h
17 
18 #include <vppinfra/error.h>
19 #include <vppinfra/hash.h>
20 #include <vnet/vnet.h>
21 
22 #include <geneve/geneve_packet.h>
23 
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/vtep.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2/l2_output.h>
28 #include <vnet/l2/l2_bd.h>
29 #include <vnet/ethernet/ethernet.h>
30 #include <vnet/ip/ip4_packet.h>
31 #include <vnet/ip/ip6_packet.h>
32 #include <vnet/udp/udp_packet.h>
33 #include <vnet/udp/udp_local.h>
34 #include <vnet/dpo/dpo.h>
35 #include <vnet/adj/adj_types.h>
36 
37 #define SUPPORT_OPTIONS_HEADER 0
38 
39 typedef CLIB_PACKED (struct
40  {
41  ip4_header_t ip4; /* 20 bytes */
42  udp_header_t udp; /* 8 bytes */
43  geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
44  }) ip4_geneve_header_t;
45 
46 typedef CLIB_PACKED (struct
47  {
48  ip6_header_t ip6; /* 40 bytes */
49  udp_header_t udp; /* 8 bytes */
50  geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
51  }) ip6_geneve_header_t;
52 
53 typedef CLIB_PACKED (struct
54  {
55  /*
56  * Key fields: ip source and geneve vni on incoming GENEVE packet
57  * all fields in NET byte order
58  */
59  union
60  {
61  struct
62  {
63  u32 remote;
64  u32 vni; /* shifted left 8 bits */
65  };
66  u64 as_u64;
67  };
68  }) geneve4_tunnel_key_t;
69 
70 typedef CLIB_PACKED (struct
71  {
72  /*
73  * Key fields: ip source and geneve vni on incoming GENEVE packet
74  * all fields in NET byte order
75  */
76  ip6_address_t remote;
77  u32 vni; /* shifted left 8 bits */
78  }) geneve6_tunnel_key_t;
79 
80 typedef struct
81 {
85 
86 typedef struct
87 {
88  /* Required for pool_get_aligned */
89  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
90 
91  /* Rewrite string. $$$$ embed vnet_rewrite header */
93 
94  /* FIB DPO for IP forwarding of GENEVE encap packet */
96 
97  /* geneve VNI in HOST byte order */
99 
100  /* geneve OPTIONS LEN in HOST byte order */
101 #if SUPPORT_OPTIONS_HEADER==1
102  u8 options_len;
103 #endif
104 
105  /* tunnel local and remote addresses */
106  ip46_address_t local;
107  ip46_address_t remote;
108 
109  /* mcast packet output intfc index (used only if remote is mcast) */
111 
112  /* decap next index */
114 
115  /* The FIB index for local/remote addresses */
117 
118  /* vnet intfc index */
121 
122  /**
123  * Linkage into the FIB object graph
124  */
126 
127  /*
128  * The FIB entry for (depending on GENEVE tunnel is unicast or mcast)
129  * sending unicast GENEVE encap packets or receiving mcast GENEVE packets
130  */
133 
134  /**
135  * The tunnel is a child of the FIB entry for its desintion. This is
136  * so it receives updates when the forwarding information for that entry
137  * changes.
138  * The tunnels sibling index on the FIB entry's dependency list.
139  */
141 
144 
145 #define foreach_geneve_input_next \
146 _(DROP, "error-drop") \
147 _(L2_INPUT, "l2-input")
148 
149 typedef enum
150 {
151 #define _(s,n) GENEVE_INPUT_NEXT_##s,
153 #undef _
156 
157 typedef enum
158 {
159 #define geneve_error(n,s) GENEVE_ERROR_##n,
160 #include <geneve/geneve_error.def>
161 #undef geneve_error
164 
165 typedef struct
166 {
167  /* vector of encap tunnel instances */
169 
170  /* lookup tunnel by key */
171  uword *geneve4_tunnel_by_key; /* keyed on ipv4.remote + vni */
172  uword *geneve6_tunnel_by_key; /* keyed on ipv6.remote + vni */
173 
174  /* local VTEP IPs ref count used by geneve-bypass node to check if
175  received GENEVE packet DIP matches any local VTEP address */
177 
178  /* mcast shared info */
179  uword *mcast_shared; /* keyed on mcast ip46 addr */
180 
181  /* Mapping from sw_if_index to tunnel index */
183 
184  /* convenience */
187 
189  /* cache for last 8 geneve tunnel */
190 #ifdef CLIB_HAVE_VEC512
191  vtep4_cache_t vtep4_u512;
192 #endif
193 
194 } geneve_main_t;
195 
197 
202 
203 u8 *format_geneve_encap_trace (u8 * s, va_list * args);
204 
205 typedef struct
206 {
208 
209  /* we normally use is_ip4, but since this adds to the
210  * structure, this seems less of abreaking change */
212  ip46_address_t local, remote;
219 
221  (vnet_geneve_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
222 
224 #endif /* included_vnet_geneve_h */
225 
226 /*
227  * fd.io coding-style-patch-verification: ON
228  *
229  * Local Variables:
230  * eval: (c-set-style "gnu")
231  * End:
232  */
geneve_tunnel_t::l3_mode
u8 l3_mode
Definition: geneve.h:142
geneve_main_t::tunnel_index_by_sw_if_index
u32 * tunnel_index_by_sw_if_index
Definition: geneve.h:182
CLIB_PACKED
typedef CLIB_PACKED(struct { ip4_header_t ip4;udp_header_t udp;geneve_header_t geneve;}) ip4_geneve_header_t
geneve_input_next_t
geneve_input_next_t
Definition: geneve.h:149
geneve_main_t::vnet_main
vnet_main_t * vnet_main
Definition: geneve.h:186
adj_types.h
geneve_tunnel_t::mcast_sw_if_index
u32 mcast_sw_if_index
Definition: geneve.h:110
geneve_main_t::geneve4_tunnel_by_key
uword * geneve4_tunnel_by_key
Definition: geneve.h:171
geneve_tunnel_t::node
fib_node_t node
Linkage into the FIB object graph.
Definition: geneve.h:125
vnet_geneve_add_del_tunnel_args_t::remote
ip46_address_t remote
Definition: geneve.h:212
geneve_tunnel_t::local
ip46_address_t local
Definition: geneve.h:106
geneve_main_t::msg_id_base
u16 msg_id_base
Definition: geneve.h:188
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
geneve_tunnel_t::rewrite
u8 * rewrite
Definition: geneve.h:92
vnet_geneve_add_del_tunnel_args_t::l3_mode
u8 l3_mode
Definition: geneve.h:217
CLIB_CACHE_LINE_ALIGN_MARK
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
geneve_packet.h
vnet_geneve_add_del_tunnel_args_t::decap_next_index
u32 decap_next_index
Definition: geneve.h:215
geneve_tunnel_t::sw_if_index
u32 sw_if_index
Definition: geneve.h:119
vni
u32 vni
Definition: flow_types.api:160
geneve_main
geneve_main_t geneve_main
Definition: geneve.c:39
geneve_encap_trace_t
Definition: geneve.h:80
u16
unsigned short u16
Definition: types.h:57
GENEVE_N_ERROR
@ GENEVE_N_ERROR
Definition: geneve.h:162
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
ethernet.h
geneve_main_t
Definition: geneve.h:165
ip6_packet.h
geneve_tunnel_t::vni
u32 vni
Definition: geneve.h:98
vnet_geneve_add_del_tunnel_args_t
Definition: geneve.h:205
error.h
dpo.h
l2_output.h
geneve4_encap_node
vlib_node_registration_t geneve4_encap_node
(constructor) VLIB_REGISTER_NODE (geneve4_encap_node)
Definition: encap.c:548
format_geneve_encap_trace
u8 * format_geneve_encap_trace(u8 *s, va_list *args)
Definition: geneve.c:42
foreach_geneve_input_next
#define foreach_geneve_input_next
Definition: geneve.h:145
geneve_tunnel_t::next_dpo
dpo_id_t next_dpo
Definition: geneve.h:95
GENEVE_INPUT_N_NEXT
@ GENEVE_INPUT_N_NEXT
Definition: geneve.h:154
udp_local.h
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
udp_packet.h
uword
u64 uword
Definition: types.h:112
geneve_tunnel_t::hw_if_index
u32 hw_if_index
Definition: geneve.h:120
vnet_int_geneve_bypass_mode
void vnet_int_geneve_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
Definition: geneve.c:933
geneve_encap_trace_t::tunnel_index
u32 tunnel_index
Definition: geneve.h:82
geneve6_encap_node
vlib_node_registration_t geneve6_encap_node
(constructor) VLIB_REGISTER_NODE (geneve6_encap_node)
Definition: encap.c:561
geneve_error.def
geneve_main_t::mcast_shared
uword * mcast_shared
Definition: geneve.h:179
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
geneve_main_t::vtep_table
vtep_table_t vtep_table
Definition: geneve.h:176
geneve4_input_node
vlib_node_registration_t geneve4_input_node
(constructor) VLIB_REGISTER_NODE (geneve4_input_node)
Definition: decap.c:816
geneve_tunnel_t::remote
ip46_address_t remote
Definition: geneve.h:107
l2_input.h
geneve_main_t::geneve6_tunnel_by_key
uword * geneve6_tunnel_by_key
Definition: geneve.h:172
ip4_packet.h
is_ip6
bool is_ip6
Definition: ip.api:43
geneve_tunnel_t::fib_entry_index
fib_node_index_t fib_entry_index
Definition: geneve.h:131
vnet_main_t
Definition: vnet.h:76
geneve_main_t::tunnels
geneve_tunnel_t * tunnels
Definition: geneve.h:168
geneve_main_t::vlib_main
vlib_main_t * vlib_main
Definition: geneve.h:185
u64
unsigned long u64
Definition: types.h:89
vnet_geneve_add_del_tunnel
int vnet_geneve_add_del_tunnel(vnet_geneve_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: geneve.c:363
ip.h
u32
unsigned int u32
Definition: types.h:88
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
as_u64
u64 as_u64
Definition: bihash_doc.h:63
vnet_geneve_add_del_tunnel_args_t::is_add
u8 is_add
Definition: geneve.h:207
vnet_geneve_add_del_tunnel_args_t::mcast_sw_if_index
u32 mcast_sw_if_index
Definition: geneve.h:213
geneve_tunnel_t
Definition: geneve.h:86
ip6_header_t
Definition: ip6_packet.h:294
vnet_geneve_add_del_tunnel_args_t::encap_fib_index
u32 encap_fib_index
Definition: geneve.h:214
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
vlib_main_t
Definition: main.h:102
vnet_geneve_add_del_tunnel_args_t::is_ip6
u8 is_ip6
Definition: geneve.h:211
hash.h
geneve_header_t
Definition: geneve_packet.h:101
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:544
vtep_table_t
Definition: vtep.h:62
vnet_geneve_add_del_tunnel_args_t::vni
u32 vni
Definition: geneve.h:216
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
geneve_encap_trace_t::vni
u32 vni
Definition: geneve.h:83
vtep.h
geneve_tunnel_t::decap_next_index
u32 decap_next_index
Definition: geneve.h:113
vnet.h
geneve_input_error_t
geneve_input_error_t
Definition: geneve.h:157
geneve_tunnel_t::encap_fib_index
u32 encap_fib_index
Definition: geneve.h:116
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
l2_bd.h
geneve_tunnel_t::sibling_index
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
Definition: geneve.h:140
geneve_tunnel_t::mcast_adj_index
adj_index_t mcast_adj_index
Definition: geneve.h:132
geneve6_input_node
vlib_node_registration_t geneve6_input_node
(constructor) VLIB_REGISTER_NODE (geneve6_input_node)
Definition: decap.c:834