FD.io VPP  v19.08.3-2-gbabecb413
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 #include <vnet/ip/ip.h>
22 #include <vnet/l2/l2_input.h>
23 #include <vnet/l2/l2_output.h>
24 #include <vnet/l2/l2_bd.h>
25 #include <vnet/ethernet/ethernet.h>
27 #include <vnet/ip/ip4_packet.h>
28 #include <vnet/ip/ip6_packet.h>
29 #include <vnet/udp/udp.h>
30 #include <vnet/dpo/dpo.h>
31 #include <vnet/adj/adj_types.h>
32 
33 #define SUPPORT_OPTIONS_HEADER 0
34 
35 typedef CLIB_PACKED (struct
36  {
37  ip4_header_t ip4; /* 20 bytes */
38  udp_header_t udp; /* 8 bytes */
39  geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
40  }) ip4_geneve_header_t;
41 
42 typedef CLIB_PACKED (struct
43  {
44  ip6_header_t ip6; /* 40 bytes */
45  udp_header_t udp; /* 8 bytes */
46  geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
47  }) ip6_geneve_header_t;
48 
49 typedef CLIB_PACKED (struct
50  {
51  /*
52  * Key fields: ip source and geneve vni on incoming GENEVE packet
53  * all fields in NET byte order
54  */
55  union
56  {
57  struct
58  {
59  u32 remote;
60  u32 vni; /* shifted left 8 bits */
61  };
62  u64 as_u64;
63  };
64  }) geneve4_tunnel_key_t;
65 
66 typedef CLIB_PACKED (struct
67  {
68  /*
69  * Key fields: ip source and geneve vni on incoming GENEVE packet
70  * all fields in NET byte order
71  */
72  ip6_address_t remote;
73  u32 vni; /* shifted left 8 bits */
74  }) geneve6_tunnel_key_t;
75 
76 typedef struct
77 {
81 
82 typedef struct
83 {
84  /* Required for pool_get_aligned */
85  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
86 
87  /* Rewrite string. $$$$ embed vnet_rewrite header */
89 
90  /* FIB DPO for IP forwarding of GENEVE encap packet */
92 
93  /* geneve VNI in HOST byte order */
95 
96  /* geneve OPTIONS LEN in HOST byte order */
97 #if SUPPORT_OPTIONS_HEADER==1
98  u8 options_len;
99 #endif
100 
101  /* tunnel local and remote addresses */
102  ip46_address_t local;
103  ip46_address_t remote;
104 
105  /* mcast packet output intfc index (used only if remote is mcast) */
107 
108  /* decap next index */
110 
111  /* The FIB index for local/remote addresses */
113 
114  /* vnet intfc index */
117 
118  /**
119  * Linkage into the FIB object graph
120  */
122 
123  /*
124  * The FIB entry for (depending on GENEVE tunnel is unicast or mcast)
125  * sending unicast GENEVE encap packets or receiving mcast GENEVE packets
126  */
129 
130  /**
131  * The tunnel is a child of the FIB entry for its desintion. This is
132  * so it receives updates when the forwarding information for that entry
133  * changes.
134  * The tunnels sibling index on the FIB entry's dependency list.
135  */
138 
139 #define foreach_geneve_input_next \
140 _(DROP, "error-drop") \
141 _(L2_INPUT, "l2-input")
142 
143 typedef enum
144 {
145 #define _(s,n) GENEVE_INPUT_NEXT_##s,
147 #undef _
150 
151 typedef enum
152 {
153 #define geneve_error(n,s) GENEVE_ERROR_##n,
155 #undef geneve_error
158 
159 typedef struct
160 {
161  /* vector of encap tunnel instances */
163 
164  /* lookup tunnel by key */
165  uword *geneve4_tunnel_by_key; /* keyed on ipv4.remote + vni */
166  uword *geneve6_tunnel_by_key; /* keyed on ipv6.remote + vni */
167 
168  /* local VTEP IPs ref count used by geneve-bypass node to check if
169  received GENEVE packet DIP matches any local VTEP address */
170  uword *vtep4; /* local ip4 VTEPs keyed on their ip4 addr */
171  uword *vtep6; /* local ip6 VTEPs keyed on their ip6 addr */
172 
173  /* mcast shared info */
174  uword *mcast_shared; /* keyed on mcast ip46 addr */
175 
176  /* Free vlib hw_if_indices */
178 
179  /* Mapping from sw_if_index to tunnel index */
181 
182  /* convenience */
185 } geneve_main_t;
186 
188 
193 
194 u8 *format_geneve_encap_trace (u8 * s, va_list * args);
195 
196 typedef struct
197 {
199 
200  /* we normally use is_ip4, but since this adds to the
201  * structure, this seems less of abreaking change */
203  ip46_address_t local, remote;
209 
211  (vnet_geneve_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
212 
213 void vnet_int_geneve_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable);
214 #endif /* included_vnet_geneve_h */
215 
216 /*
217  * fd.io coding-style-patch-verification: ON
218  *
219  * Local Variables:
220  * eval: (c-set-style "gnu")
221  * End:
222  */
vlib_main_t * vlib_main
Definition: geneve.h:183
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
u32 hw_if_index
Definition: geneve.h:116
a
Definition: bitmap.h:538
u64 as_u64
Definition: bihash_doc.h:63
u32 * free_geneve_tunnel_hw_if_indices
Definition: geneve.h:177
unsigned long u64
Definition: types.h:89
void vnet_int_geneve_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
Definition: geneve.c:940
u32 decap_next_index
Definition: geneve.h:109
geneve_input_error_t
Definition: geneve.h:151
fib_node_t node
Linkage into the FIB object graph.
Definition: geneve.h:121
u8 * format_geneve_encap_trace(u8 *s, va_list *args)
Definition: geneve.c:42
u32 mcast_sw_if_index
Definition: geneve.h:106
uword * vtep6
Definition: geneve.h:171
dpo_id_t next_dpo
Definition: geneve.h:91
uword * mcast_shared
Definition: geneve.h:174
u32 * tunnel_index_by_sw_if_index
Definition: geneve.h:180
unsigned char u8
Definition: types.h:56
geneve_tunnel_t * tunnels
Definition: geneve.h:162
geneve_input_next_t
Definition: geneve.h:143
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
u8 * rewrite
Definition: geneve.h:88
#define foreach_geneve_input_next
Definition: geneve.h:139
unsigned int u32
Definition: types.h:88
vlib_node_registration_t geneve6_encap_node
(constructor) VLIB_REGISTER_NODE (geneve6_encap_node)
Definition: encap.c:561
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:170
u32 encap_fib_index
Definition: geneve.h:112
An node in the FIB graph.
Definition: fib_node.h:295
uword * vtep4
Definition: geneve.h:170
ip46_address_t local
Definition: geneve.h:102
vlib_node_registration_t geneve4_input_node
(constructor) VLIB_REGISTER_NODE (geneve4_input_node)
Definition: decap.c:816
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
uword * geneve4_tunnel_by_key
Definition: geneve.h:165
u32 sw_if_index
Definition: geneve.h:115
adj_index_t mcast_adj_index
Definition: geneve.h:128
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
Definition: geneve.h:136
vnet_main_t * vnet_main
Definition: geneve.h:184
struct _vlib_node_registration vlib_node_registration_t
ip46_address_t remote
Definition: geneve.h:103
vlib_node_registration_t geneve4_encap_node
(constructor) VLIB_REGISTER_NODE (geneve4_encap_node)
Definition: encap.c:548
int vnet_geneve_add_del_tunnel(vnet_geneve_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: geneve.c:368
u64 uword
Definition: types.h:112
uword * geneve6_tunnel_by_key
Definition: geneve.h:166
vlib_node_registration_t geneve6_input_node
(constructor) VLIB_REGISTER_NODE (geneve6_input_node)
Definition: decap.c:834
fib_node_index_t fib_entry_index
Definition: geneve.h:127
u32 vni
Definition: vxlan_gbp.api:42
geneve_main_t geneve_main
Definition: geneve.c:39
typedef CLIB_PACKED(struct { ip4_header_t ip4;udp_header_t udp;geneve_header_t geneve;}) ip4_geneve_header_t