FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
vxlan_gpe.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 /**
16  * @file
17  * @brief VXLAN GPE definitions
18  *
19 */
20 #ifndef included_vnet_vxlan_gpe_h
21 #define included_vnet_vxlan_gpe_h
22 
23 #include <vppinfra/error.h>
24 #include <vppinfra/hash.h>
25 #include <vnet/vnet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/l2/l2_output.h>
29 #include <vnet/l2/l2_bd.h>
30 #include <vnet/ethernet/ethernet.h>
32 #include <vnet/ip/ip4_packet.h>
33 #include <vnet/ip/ip6_packet.h>
34 #include <vnet/udp/udp.h>
35 #include <vnet/dpo/dpo.h>
36 #include <vnet/adj/adj_types.h>
37 
38 /**
39  * @brief VXLAN GPE header struct
40  *
41  */
42 typedef CLIB_PACKED (struct {
43  /** 20 bytes */
44  ip4_header_t ip4;
45  /** 8 bytes */
46  udp_header_t udp;
47  /** 8 bytes */
48  vxlan_gpe_header_t vxlan;
49 }) ip4_vxlan_gpe_header_t;
50 
51 typedef CLIB_PACKED (struct {
52  /** 40 bytes */
53  ip6_header_t ip6;
54  /** 8 bytes */
55  udp_header_t udp;
56  /** 8 bytes */
57  vxlan_gpe_header_t vxlan;
58 }) ip6_vxlan_gpe_header_t;
59 
60 /**
61  * @brief Key struct for IPv4 VXLAN GPE tunnel.
62  * Key fields: local remote, vni
63  * all fields in NET byte order
64  * VNI shifted 8 bits
65  */
66 typedef CLIB_PACKED(struct {
67  union {
68  struct {
69  u32 local;
70  u32 remote;
71 
72  u32 vni;
73  u32 pad;
74  };
75  u64 as_u64[2];
76  };
77 }) vxlan4_gpe_tunnel_key_t;
78 
79 /**
80  * @brief Key struct for IPv6 VXLAN GPE tunnel.
81  * Key fields: local remote, vni
82  * all fields in NET byte order
83  * VNI shifted 8 bits
84  */
85 typedef CLIB_PACKED(struct {
86  ip6_address_t local;
87  ip6_address_t remote;
88  u32 vni;
89 }) vxlan6_gpe_tunnel_key_t;
90 
91 /**
92  * @brief Struct for VXLAN GPE tunnel
93  */
94 typedef struct {
95  /** Rewrite string. $$$$ embed vnet_rewrite header */
97 
98  /** encapsulated protocol */
100 
101  /* FIB DPO for IP forwarding of VXLAN-GPE encap packet */
103  /** tunnel local address */
104  ip46_address_t local;
105  /** tunnel remote address */
106  ip46_address_t remote;
107 
108  /* mcast packet output intfc index (used only if dst is mcast) */
110 
111  /** FIB indices - tunnel partner lookup here */
113  /** FIB indices - inner IP packet lookup here */
115 
116  /** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
118 
119  /** vnet intfc hw_if_index */
121  /** vnet intfc sw_if_index */
123 
124  /** flags */
126 
127  /** rewrite size for dynamic plugins like iOAM */
129 
130  /** Next node after VxLAN-GPE encap */
132 
133  /**
134  * Linkage into the FIB object graph
135  */
137 
138  /*
139  * The FIB entry for (depending on VXLAN-GPE tunnel is unicast or mcast)
140  * sending unicast VXLAN-GPE encap packets or receiving mcast VXLAN-GPE packets
141  */
144 
145  /**
146  * The tunnel is a child of the FIB entry for its desintion. This is
147  * so it receives updates when the forwarding information for that entry
148  * changes.
149  * The tunnels sibling index on the FIB entry's dependency list.
150  */
152 
154 
155 /** Flags for vxlan_gpe_tunnel_t */
156 #define VXLAN_GPE_TUNNEL_IS_IPV4 1
157 
158 /** next nodes for VXLAN GPE input */
159 #define foreach_vxlan_gpe_input_next \
160 _(DROP, "error-drop") \
161 _(IP4_INPUT, "ip4-input") \
162 _(IP6_INPUT, "ip6-input") \
163 _(ETHERNET_INPUT, "ethernet-input")
164 
165 /** struct for next nodes for VXLAN GPE input */
166 typedef enum {
167 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
169 #undef _
172 
173 /** struct for VXLAN GPE errors */
174 typedef enum {
175 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
177 #undef vxlan_gpe_error
180 
181 /** Struct for VXLAN GPE node state */
182 typedef struct {
183  /** vector of encap tunnel instances */
185 
186  /** lookup IPv4 VXLAN GPE tunnel by key */
188  /** lookup IPv6 VXLAN GPE tunnel by key */
190 
191  /* local VTEP IPs ref count used by vxlan-bypass node to check if
192  received VXLAN packet DIP matches any local VTEP address */
193  uword * vtep4; /* local ip4 VTEPs keyed on their ip4 addr */
194  uword * vtep6; /* local ip6 VTEPs keyed on their ip6 addr */
195  /* mcast shared info */
196  uword * mcast_shared; /* keyed on mcast ip46 addr */
197  /** Free vlib hw_if_indices */
199 
200  /** Mapping from sw_if_index to tunnel index */
202 
203  /** State convenience vlib_main_t */
205  /** State convenience vnet_main_t */
207 
208  /** List of next nodes for the decap indexed on protocol */
209  uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
211 
213 
217 
218 u8 * format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
219 
220 /** Struct for VXLAN GPE add/del args */
221 typedef struct {
224  ip46_address_t local, remote;
231 
232 
234 (vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 * sw_if_indexp);
235 
236 
237 int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
238  u8 protocol_override, uword encap_next_node);
239 int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
240  u8 protocol_override, uword encap_next_node);
241 
242 /**
243  * @brief Struct for defining VXLAN GPE next nodes
244  */
245 typedef enum {
251 
252 
253 void vxlan_gpe_unregister_decap_protocol (u8 protocol_id, uword next_node_index);
254 
255 void vxlan_gpe_register_decap_protocol (u8 protocol_id, uword next_node_index);
256 
257 void vnet_int_vxlan_gpe_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable);
258 
259 #endif /* included_vnet_vxlan_gpe_h */
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:189
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
Definition: decap.c:712
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
Definition: vxlan_gpe.h:151
u8 pad[3]
log2 (size of the packing page block)
Definition: bihash_doc.h:61
u32 flags
flags
Definition: vxlan_gpe.h:125
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
Definition: encap.c:370
a
Definition: bitmap.h:516
u64 as_u64
Definition: bihash_doc.h:63
adj_index_t mcast_adj_index
Definition: vxlan_gpe.h:143
vxlan_gpe_encap_next_t
Struct for defining VXLAN GPE next nodes.
Definition: vxlan_gpe.h:245
uword * mcast_shared
Definition: vxlan_gpe.h:196
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: vxlan_gpe.h:201
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
Definition: encap.c:66
struct _vlib_node_registration vlib_node_registration_t
vnet_main_t * vnet_main
State convenience vnet_main_t.
Definition: vxlan_gpe.h:206
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.h:212
typedef CLIB_PACKED(struct{ip4_header_t ip4;udp_header_t udp;vxlan_gpe_header_t vxlan;}) ip4_vxlan_gpe_header_t
VXLAN GPE header struct.
ip46_address_t local
tunnel local address
Definition: vxlan_gpe.h:104
unsigned long u64
Definition: types.h:89
fib_node_index_t fib_entry_index
Definition: vxlan_gpe.h:142
u8 * rewrite
Rewrite string.
Definition: vxlan_gpe.h:96
VXLAN GPE packet header structure.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:150
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:94
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or Del a VXLAN GPE tunnel.
Definition: vxlan_gpe.c:480
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
Definition: decap.c:689
vlib_main_t * vlib_main
State convenience vlib_main_t.
Definition: vxlan_gpe.h:204
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:99
An node in the FIB graph.
Definition: fib_node.h:279
ip46_address_t remote
tunnel remote address
Definition: vxlan_gpe.h:106
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
Definition: vxlan_gpe.h:117
void vnet_int_vxlan_gpe_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
Definition: vxlan_gpe.c:1030
Struct for VXLAN GPE add/del args.
Definition: vxlan_gpe.h:221
int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv6 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:327
fib_node_t node
Linkage into the FIB object graph.
Definition: vxlan_gpe.h:136
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
vxlan_gpe_input_error_t
struct for VXLAN GPE errors
Definition: vxlan_gpe.h:174
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
void vxlan_gpe_unregister_decap_protocol(u8 protocol_id, uword next_node_index)
Definition: decap.c:653
#define foreach_vxlan_gpe_input_next
next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:159
void vxlan_gpe_register_decap_protocol(u8 protocol_id, uword next_node_index)
Definition: decap.c:645
unsigned int u32
Definition: types.h:88
u8 rewrite_size
rewrite size for dynamic plugins like iOAM
Definition: vxlan_gpe.h:128
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:182
dpo_id_t next_dpo
Definition: vxlan_gpe.h:102
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:184
u64 uword
Definition: types.h:112
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:187
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:114
unsigned char u8
Definition: types.h:56
int vxlan4_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv4 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:270
VXLAN GPE Header definition.
u32 hw_if_index
vnet intfc hw_if_index
Definition: vxlan_gpe.h:120
vxlan_gpe_input_next_t
struct for next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:166
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:112
uword encap_next_node
Next node after VxLAN-GPE encap.
Definition: vxlan_gpe.h:131
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:122
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: vxlan_gpe.h:198