2 * Copyright (c) 2016 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef included_vnet_lisp_gpe_h
17 #define included_vnet_lisp_gpe_h
19 #include <vppinfra/error.h>
20 #include <vppinfra/mhash.h>
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/l2/l2_input.h>
24 #include <vnet/ethernet/ethernet.h>
25 #include <vnet/ip/ip4_packet.h>
26 #include <vnet/ip/udp.h>
27 #include <vnet/lisp-cp/lisp_types.h>
28 #include <vnet/lisp-gpe/lisp_gpe_packet.h>
30 #define IP_UDP_HDR_LEN (word) (sizeof(udp_header_t) + sizeof(ip4_header_t))
32 typedef CLIB_PACKED (struct {
33 ip4_header_t ip4; /* 20 bytes */
34 udp_header_t udp; /* 8 bytes */
35 lisp_gpe_header_t lisp; /* 8 bytes */
36 }) ip4_udp_lisp_gpe_header_t;
50 } lisp_gpe_tunnel_key_t;
54 /* Rewrite string. $$$$ embed vnet_rewrite header */
57 /* decap next index */
60 /* tunnel src and dst addresses */
65 u32 encap_fib_index; /* tunnel partner lookup here */
66 u32 decap_fib_index; /* inner IP lookup here */
68 /* vnet intfc hw/sw_if_index */
72 /* LISP header fields in HOST byte order */
80 #define foreach_lisp_gpe_input_next \
81 _(DROP, "error-drop") \
82 _(IP4_INPUT, "ip4-input") \
83 _(IP6_INPUT, "ip6-input") \
84 _(ETHERNET_INPUT, "ethernet-input")
87 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
88 foreach_lisp_gpe_input_next
90 LISP_GPE_INPUT_N_NEXT,
91 } lisp_gpe_input_next_t;
94 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
95 #include <vnet/lisp-gpe/lisp_gpe_error.def>
100 /* As a first step, reuse v4 fib. The goal of the typedef is to shield
101 * consumers from future updates that may result in the lisp ip4 fib diverging
103 typedef ip4_fib_t lisp_ip4_fib_t;
105 typedef struct lisp_gpe_main
107 /* Pool of src fibs that are paired with dst fibs */
108 ip4_fib_t * src_fibs;
110 /* vector of encap tunnel instances */
111 lisp_gpe_tunnel_t * tunnels;
113 /* lookup tunnel by key */
114 mhash_t lisp_gpe_tunnel_by_key;
116 /* lookup decap tunnel termination sw_if_index by vni and vice versa */
117 uword * tunnel_term_sw_if_index_by_vni;
118 uword * vni_by_tunnel_term_sw_if_index;
120 /* Free vlib hw_if_indices */
121 u32 * free_lisp_gpe_tunnel_hw_if_indices;
123 /* Lookup lisp-gpe interfaces by vrf */
124 uword * lisp_gpe_hw_if_index_by_table_id;
126 /* Lookup lgpe_ip4_lookup_next by vrf */
127 uword * lgpe_ip4_lookup_next_index_by_table_id;
129 /* next node indexes that points ip4 lookup to lisp gpe lookup and lisp cp */
130 u32 ip4_lookup_next_lgpe_ip4_lookup;
133 vlib_main_t * vlib_main;
134 vnet_main_t * vnet_main;
135 ip_lookup_main_t * lookup_main;
139 lisp_gpe_main_t lisp_gpe_main;
141 extern vlib_node_registration_t lgpe_ip4_lookup_node;
142 extern vlib_node_registration_t lisp_gpe_input_node;
145 format_lisp_gpe_tx_trace (u8 * s, va_list * args);
147 format_lisp_gpe_header_with_length (u8 * s, va_list * args);
152 ip4_address_t src, dst;
155 u32 decap_next_index;
160 u32 vni; /* host byte order */
161 } vnet_lisp_gpe_add_del_tunnel_args_t;
164 vnet_lisp_gpe_add_del_tunnel (vnet_lisp_gpe_add_del_tunnel_args_t *a,
170 u32 table_id; /* vrf */
171 u32 vni; /* host byte order */
172 } vnet_lisp_gpe_add_del_iface_args_t;
175 vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t *a,
181 } vnet_lisp_gpe_enable_disable_args_t;
184 vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t *a);
192 } negative_fwd_actions_e;
198 negative_fwd_actions_e action;
199 gid_address_t seid; /* TODO convert to ip4, ip6, mac ? */
201 ip_address_t slocator;
202 ip_address_t dlocator;
205 u32 decap_next_index;
210 u32 vni; /* host byte order */
212 } vnet_lisp_gpe_add_del_fwd_entry_args_t;
215 vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t *a,
219 format_lisp_gpe_header_with_length (u8 * s, va_list * args);
221 #endif /* included_vnet_lisp_gpe_h */