FD.io VPP
v16.09
Vector Packet Processing
Main Page
Related Pages
Data Structures
Source
Files
Symbols
vxlan.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_vnet_vxlan_h
16
#define included_vnet_vxlan_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
>
26
#include <
vnet/vxlan/vxlan_packet.h
>
27
#include <
vnet/ip/ip4_packet.h
>
28
#include <
vnet/ip/ip6_packet.h
>
29
#include <
vnet/ip/udp.h
>
30
31
typedef
CLIB_PACKED
(
struct
{
32
ip4_header_t
ip4;
/* 20 bytes */
33
udp_header_t
udp;
/* 8 bytes */
34
vxlan_header_t
vxlan;
/* 8 bytes */
35
}) ip4_vxlan_header_t;
36
37
typedef
CLIB_PACKED
(
struct
{
38
ip6_header_t
ip6;
/* 40 bytes */
39
udp_header_t
udp;
/* 8 bytes */
40
vxlan_header_t
vxlan;
/* 8 bytes */
41
}) ip6_vxlan_header_t;
42
43
typedef
CLIB_PACKED
(
struct
{
44
/*
45
* Key fields: ip src and vxlan vni on incoming VXLAN packet
46
* all fields in NET byte order
47
*/
48
union
{
49
struct
{
50
u32
src;
51
u32
vni;
/* shifted left 8 bits */
52
};
53
u64
as_u64
;
54
};
55
}) vxlan4_tunnel_key_t;
56
57
typedef
CLIB_PACKED
(
struct
{
58
/*
59
* Key fields: ip src and vxlan vni on incoming VXLAN packet
60
* all fields in NET byte order
61
*/
62
ip6_address_t
src;
63
u32
vni;
/* shifted left 8 bits */
64
}) vxlan6_tunnel_key_t;
65
66
typedef
struct
{
67
/* Rewrite string. $$$$ embed vnet_rewrite header */
68
u8
*
rewrite
;
69
70
/* tunnel src and dst addresses */
71
ip46_address_t
src
;
72
ip46_address_t
dst
;
73
74
/* vxlan VNI in HOST byte order */
75
u32
vni
;
76
77
/* decap next index */
78
u32
decap_next_index
;
79
80
/* L3 FIB index and L2 BD ID */
81
u16
encap_fib_index
;
/* tunnel partner IP lookup here */
82
83
/* vnet intfc hw/sw_if_index */
84
u16
hw_if_index
;
85
u32
sw_if_index
;
86
87
union
{
/* storage for the hash key */
88
vxlan4_tunnel_key_t *
key4
;
89
vxlan6_tunnel_key_t *
key6
;
90
};
91
92
/* flags */
93
u32
flags
;
94
}
vxlan_tunnel_t
;
95
96
/* Flags for vxlan_tunnel_t.flags */
97
#define VXLAN_TUNNEL_IS_IPV4 1
98
99
#define foreach_vxlan_input_next \
100
_(DROP, "error-drop") \
101
_(L2_INPUT, "l2-input") \
102
_(IP4_INPUT, "ip4-input") \
103
_(IP6_INPUT, "ip6-input")
104
105
typedef
enum
{
106
#define _(s,n) VXLAN_INPUT_NEXT_##s,
107
foreach_vxlan_input_next
108
#undef _
109
VXLAN_INPUT_N_NEXT
,
110
}
vxlan_input_next_t
;
111
112
typedef
enum
{
113
#define vxlan_error(n,s) VXLAN_ERROR_##n,
114
#include <
vnet/vxlan/vxlan_error.def
>
115
#undef vxlan_error
116
VXLAN_N_ERROR,
117
}
vxlan_input_error_t
;
118
119
typedef
struct
{
120
/* vector of encap tunnel instances */
121
vxlan_tunnel_t
*
tunnels
;
122
123
/* lookup tunnel by key */
124
uword
*
vxlan4_tunnel_by_key
;
/* keyed on ipv4.dst + vni */
125
uword
*
vxlan6_tunnel_by_key
;
/* keyed on ipv6.dst + vni */
126
127
/* Free vlib hw_if_indices */
128
u32
*
free_vxlan_tunnel_hw_if_indices
;
129
130
/* Mapping from sw_if_index to tunnel index */
131
u32
*
tunnel_index_by_sw_if_index
;
132
133
/* convenience */
134
vlib_main_t
*
vlib_main
;
135
vnet_main_t
*
vnet_main
;
136
}
vxlan_main_t
;
137
138
vxlan_main_t
vxlan_main
;
139
140
extern
vlib_node_registration_t
vxlan4_input_node
;
141
extern
vlib_node_registration_t
vxlan6_input_node
;
142
extern
vlib_node_registration_t
vxlan_encap_node
;
143
144
u8
*
format_vxlan_encap_trace
(
u8
* s, va_list * args);
145
146
typedef
struct
{
147
u8
is_add
;
148
149
/* we normally use is_ip4, but since this adds to the
150
* structure, this seems less of abreaking change */
151
u8
is_ip6
;
152
ip46_address_t
src
, dst;
153
u32
encap_fib_index
;
154
u32
decap_next_index
;
155
u32
vni
;
156
}
vnet_vxlan_add_del_tunnel_args_t
;
157
158
int
vnet_vxlan_add_del_tunnel
159
(
vnet_vxlan_add_del_tunnel_args_t
*
a
,
u32
* sw_if_indexp);
160
161
#endif
/* included_vnet_vxlan_h */
vnet_vxlan_add_del_tunnel_args_t::src
ip46_address_t src
Definition:
vxlan.h:152
vnet_vxlan_add_del_tunnel_args_t::is_ip6
u8 is_ip6
Definition:
vxlan.h:151
vnet_vxlan_add_del_tunnel_args_t::encap_fib_index
u32 encap_fib_index
Definition:
vxlan.h:153
vnet_vxlan_add_del_tunnel
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition:
vxlan.c:213
a
a
Definition:
bitmap.h:516
vnet_vxlan_add_del_tunnel_args_t::vni
u32 vni
Definition:
vxlan.h:155
error.h
as_u64
u64 as_u64
Definition:
bihash_doc.h:63
l2_bd.h
foreach_vxlan_input_next
#define foreach_vxlan_input_next
Definition:
vxlan.h:99
vxlan_error.def
ip6_packet.h
vxlan_tunnel_t::dst
ip46_address_t dst
Definition:
vxlan.h:72
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vxlan_encap_node
vlib_node_registration_t vxlan_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_encap_node)
Definition:
encap.c:544
vxlan4_input_node
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
Definition:
decap.c:22
vxlan_tunnel_t::key6
vxlan6_tunnel_key_t * key6
Definition:
vxlan.h:89
ip.h
udp_header_t
Definition:
udp_packet.h:43
hash.h
vxlan_tunnel_t
Definition:
vxlan.h:66
vnet_vxlan_add_del_tunnel_args_t::is_add
u8 is_add
Definition:
vxlan.h:147
format_vxlan_encap_trace
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
Definition:
encap.c:51
l2_input.h
vxlan_main_t::vnet_main
vnet_main_t * vnet_main
Definition:
vxlan.h:135
vnet_vxlan_add_del_tunnel_args_t
Definition:
vxlan.h:146
vxlan_main_t::vlib_main
vlib_main_t * vlib_main
Definition:
vxlan.h:134
u64
unsigned long u64
Definition:
types.h:89
ethernet.h
vxlan_tunnel_t::rewrite
u8 * rewrite
Definition:
vxlan.h:68
ip4_packet.h
vxlan6_input_node
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
Definition:
decap.c:23
vxlan_main_t::vxlan4_tunnel_by_key
uword * vxlan4_tunnel_by_key
Definition:
vxlan.h:124
vxlan_tunnel_t::vni
u32 vni
Definition:
vxlan.h:75
vnet.h
vxlan_tunnel_t::encap_fib_index
u16 encap_fib_index
Definition:
vxlan.h:81
vxlan_header_t
Definition:
vxlan_packet.h:44
vxlan_tunnel_t::decap_next_index
u32 decap_next_index
Definition:
vxlan.h:78
vnet_main_t
Definition:
vnet.h:59
vxlan_input_next_t
vxlan_input_next_t
Definition:
vxlan.h:105
u32
unsigned int u32
Definition:
types.h:88
ip6_header_t
Definition:
ip6_packet.h:283
vxlan_packet.h
vxlan_main_t::vxlan6_tunnel_by_key
uword * vxlan6_tunnel_by_key
Definition:
vxlan.h:125
vxlan_tunnel_t::sw_if_index
u32 sw_if_index
Definition:
vxlan.h:85
uword
u64 uword
Definition:
types.h:112
u16
unsigned short u16
Definition:
types.h:57
u8
unsigned char u8
Definition:
types.h:56
vxlan_tunnel_t::hw_if_index
u16 hw_if_index
Definition:
vxlan.h:84
vxlan_tunnel_t::flags
u32 flags
Definition:
vxlan.h:93
vlib_main_t
Definition:
main.h:59
vxlan_main_t
Definition:
vxlan.h:119
VXLAN_INPUT_N_NEXT
Definition:
vxlan.h:109
vnet_vxlan_add_del_tunnel_args_t::decap_next_index
u32 decap_next_index
Definition:
vxlan.h:154
vxlan_main_t::tunnel_index_by_sw_if_index
u32 * tunnel_index_by_sw_if_index
Definition:
vxlan.h:131
l2_output.h
CLIB_PACKED
typedef CLIB_PACKED(struct{ip4_header_t ip4;udp_header_t udp;vxlan_header_t vxlan;}) ip4_vxlan_header_t
vxlan_tunnel_t::key4
vxlan4_tunnel_key_t * key4
Definition:
vxlan.h:88
vxlan_input_error_t
vxlan_input_error_t
Definition:
vxlan.h:112
ip4_header_t
Definition:
ip4_packet.h:104
udp.h
vxlan_main_t::tunnels
vxlan_tunnel_t * tunnels
Definition:
vxlan.h:121
vxlan_main_t::free_vxlan_tunnel_hw_if_indices
u32 * free_vxlan_tunnel_hw_if_indices
Definition:
vxlan.h:128
ip6_address_t
Definition:
ip6_packet.h:46
vxlan_tunnel_t::src
ip46_address_t src
Definition:
vxlan.h:71
vxlan_main
vxlan_main_t vxlan_main
Definition:
vxlan.h:138
vnet
vnet
vxlan
vxlan.h
Generated on Fri Nov 18 2016 06:18:03 for FD.io VPP by
1.8.11