FD.io VPP  v17.01-9-ge7dcee4
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/ethernet/ethernet.h>
30 #include <vnet/ip/ip4_packet.h>
31 #include <vnet/ip/ip6_packet.h>
32 #include <vnet/ip/udp.h>
33 
34 /**
35  * @brief VXLAN GPE header struct
36  *
37  */
38 typedef CLIB_PACKED (struct {
39  /** 20 bytes */
40  ip4_header_t ip4;
41  /** 8 bytes */
42  udp_header_t udp;
43  /** 8 bytes */
44  vxlan_gpe_header_t vxlan;
45 }) ip4_vxlan_gpe_header_t;
46 
47 typedef CLIB_PACKED (struct {
48  /** 40 bytes */
49  ip6_header_t ip6;
50  /** 8 bytes */
51  udp_header_t udp;
52  /** 8 bytes */
53  vxlan_gpe_header_t vxlan;
54 }) ip6_vxlan_gpe_header_t;
55 
56 /**
57  * @brief Key struct for IPv4 VXLAN GPE tunnel.
58  * Key fields: local remote, vni
59  * all fields in NET byte order
60  * VNI shifted 8 bits
61  */
62 typedef CLIB_PACKED(struct {
63  union {
64  struct {
65  u32 local;
66  u32 remote;
67 
68  u32 vni;
69  u32 pad;
70  };
71  u64 as_u64[2];
72  };
73 }) vxlan4_gpe_tunnel_key_t;
74 
75 /**
76  * @brief Key struct for IPv6 VXLAN GPE tunnel.
77  * Key fields: local remote, vni
78  * all fields in NET byte order
79  * VNI shifted 8 bits
80  */
81 typedef CLIB_PACKED(struct {
82  ip6_address_t local;
83  ip6_address_t remote;
84  u32 vni;
85 }) vxlan6_gpe_tunnel_key_t;
86 
87 /**
88  * @brief Struct for VXLAN GPE tunnel
89  */
90 typedef struct {
91  /** Rewrite string. $$$$ embed vnet_rewrite header */
93 
94  /** encapsulated protocol */
96 
97  /** tunnel local address */
98  ip46_address_t local;
99  /** tunnel remote address */
100  ip46_address_t remote;
101 
102  /** FIB indices - tunnel partner lookup here */
104  /** FIB indices - inner IP packet lookup here */
106 
107  /** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
109 
110  /** vnet intfc hw_if_index */
112  /** vnet intfc sw_if_index */
114 
115  /** flags */
117 
118  /** rewrite size for dynamic plugins like iOAM */
120 
121  /** Next node after VxLAN-GPE encap */
124 
125 /** Flags for vxlan_gpe_tunnel_t */
126 #define VXLAN_GPE_TUNNEL_IS_IPV4 1
127 
128 /** next nodes for VXLAN GPE input */
129 #define foreach_vxlan_gpe_input_next \
130 _(DROP, "error-drop") \
131 _(IP4_INPUT, "ip4-input") \
132 _(IP6_INPUT, "ip6-input") \
133 _(ETHERNET_INPUT, "ethernet-input")
134 
135 /** struct for next nodes for VXLAN GPE input */
136 typedef enum {
137 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
139 #undef _
142 
143 /** struct for VXLAN GPE errors */
144 typedef enum {
145 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
147 #undef vxlan_gpe_error
148  VXLAN_GPE_N_ERROR,
150 
151 /** Struct for VXLAN GPE node state */
152 typedef struct {
153  /** vector of encap tunnel instances */
155 
156  /** lookup IPv4 VXLAN GPE tunnel by key */
158  /** lookup IPv6 VXLAN GPE tunnel by key */
160 
161  /** Free vlib hw_if_indices */
163 
164  /** Mapping from sw_if_index to tunnel index */
166 
167  /** State convenience vlib_main_t */
169  /** State convenience vnet_main_t */
171 
172  /** List of next nodes for the decap indexed on protocol */
173  uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
175 
177 
181 
182 u8 * format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
183 
184 /** Struct for VXLAN GPE add/del args */
185 typedef struct {
188  ip46_address_t local, remote;
194 
195 
197 (vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 * sw_if_indexp);
198 
199 
200 int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
201  u8 protocol_override, uword encap_next_node);
202 int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
203  u8 protocol_override, uword encap_next_node);
204 
205 /**
206  * @brief Struct for defining VXLAN GPE next nodes
207  */
208 typedef enum {
214 
215 
216 void vxlan_gpe_unregister_decap_protocol (u8 protocol_id, uword next_node_index);
217 
218 void vxlan_gpe_register_decap_protocol (u8 protocol_id, uword next_node_index);
219 
220 
221 #endif /* included_vnet_vxlan_gpe_h */
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:159
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
Definition: decap.c:712
u8 pad[3]
log2 (size of the packing page block)
Definition: bihash_doc.h:61
u32 flags
flags
Definition: vxlan_gpe.h:116
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
vxlan_gpe_encap_next_t
Struct for defining VXLAN GPE next nodes.
Definition: vxlan_gpe.h:208
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: vxlan_gpe.h:165
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:170
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.h:176
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:98
unsigned long u64
Definition: types.h:89
u8 * rewrite
Rewrite string.
Definition: vxlan_gpe.h:92
VXLAN GPE packet header structure.
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
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:292
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:168
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:95
ip46_address_t remote
tunnel remote address
Definition: vxlan_gpe.h:100
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
Definition: vxlan_gpe.h:108
Struct for VXLAN GPE add/del args.
Definition: vxlan_gpe.h:185
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:233
vxlan_gpe_input_error_t
struct for VXLAN GPE errors
Definition: vxlan_gpe.h:144
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:129
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:119
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:152
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:154
u64 uword
Definition: types.h:112
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:157
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:105
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:176
VXLAN GPE Header definition.
u32 hw_if_index
vnet intfc hw_if_index
Definition: vxlan_gpe.h:111
vxlan_gpe_input_next_t
struct for next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:136
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:103
uword encap_next_node
Next node after VxLAN-GPE encap.
Definition: vxlan_gpe.h:122
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:113
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: vxlan_gpe.h:162