]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vxlan.h
Merge pull request #12364 from sworleys/SVD-DVNI-PR
[mirror_frr.git] / zebra / zebra_vxlan.h
1 /*
2 * Zebra VxLAN (EVPN) Data structures and definitions
3 * These are public definitions referenced by other files.
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
5 *
6 * This file is part of FRR.
7 *
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with FRR; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23
24 #ifndef _ZEBRA_VXLAN_H
25 #define _ZEBRA_VXLAN_H
26
27 #include <zebra.h>
28 #include <zebra/zebra_router.h>
29
30 #include "linklist.h"
31 #include "if.h"
32 #include "vlan.h"
33 #include "vxlan.h"
34
35 #include "lib/json.h"
36 #include "zebra/zebra_vrf.h"
37 #include "zebra/zserv.h"
38 #include "zebra/zebra_dplane.h"
39 #include "zebra/interface.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /* Is EVPN enabled? */
46 #define EVPN_ENABLED(zvrf) (zvrf)->advertise_all_vni
47 static inline int is_evpn_enabled(void)
48 {
49 return EVPN_ENABLED(zebra_vrf_get_evpn());
50 }
51
52 static inline int
53 is_vxlan_flooding_head_end(void)
54 {
55 struct zebra_vrf *zvrf = zebra_vrf_get_evpn();
56 return (zvrf->vxlan_flood_ctrl == VXLAN_FLOOD_HEAD_END_REPL);
57 }
58
59 /* VxLAN interface change flags of interest. */
60 #define ZEBRA_VXLIF_LOCAL_IP_CHANGE (1 << 0)
61 #define ZEBRA_VXLIF_MASTER_CHANGE (1 << 1)
62 #define ZEBRA_VXLIF_VLAN_CHANGE (1 << 2)
63 #define ZEBRA_VXLIF_MCAST_GRP_CHANGE (1 << 3)
64 #define ZEBRA_VXLIF_MASTER_MAC_CHANGE (1 << 4)
65
66 #define ZEBRA_VXLIF_VNI_UPDATE(__flags) \
67 ((__flags) & (ZEBRA_VXLIF_VLAN_CHANGE | ZEBRA_VXLIF_MCAST_GRP_CHANGE))
68 #define ZEBRA_VXLIF_UPDATE(__flags) \
69 ((__flags) & (ZEBRA_VXLIF_LOCAL_IP_CHANGE | ZEBRA_VXLIF_MASTER_CHANGE))
70
71 #define VNI_STR_LEN 32
72
73 /* ZAPI message handlers */
74 extern void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS);
75 extern void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS);
76 extern void zebra_vxlan_remote_vtep_add_zapi(ZAPI_HANDLER_ARGS);
77 extern void zebra_vxlan_remote_vtep_del_zapi(ZAPI_HANDLER_ARGS);
78 void zebra_vxlan_remote_vtep_add(vrf_id_t vrf_id, vni_t vni,
79 struct in_addr vtep_ip, int flood_control);
80 extern void zebra_vxlan_remote_vtep_del(vrf_id_t vrf_id, vni_t vni,
81 struct in_addr vtep_ip);
82 extern void zebra_vxlan_flood_control(ZAPI_HANDLER_ARGS);
83 extern void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS);
84 extern void zebra_vxlan_advertise_svi_macip(ZAPI_HANDLER_ARGS);
85 extern void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS);
86 extern void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS);
87 extern void zebra_vxlan_dup_addr_detection(ZAPI_HANDLER_ARGS);
88 extern void zebra_vxlan_sg_replay(ZAPI_HANDLER_ARGS);
89
90 extern int is_l3vni_for_prefix_routes_only(vni_t vni);
91 extern ifindex_t get_l3vni_svi_ifindex(vrf_id_t vrf_id);
92 extern ifindex_t get_l3vni_vxlan_ifindex(vrf_id_t vrf_id);
93 extern vni_t get_l3vni_vni(vrf_id_t vrf_id);
94 extern bool is_vrf_l3vni_svd_backed(vrf_id_t vrf_id);
95 extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf);
96 extern int zebra_vxlan_vrf_enable(struct zebra_vrf *zvrf);
97 extern int zebra_vxlan_vrf_disable(struct zebra_vrf *zvrf);
98 extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf);
99 extern void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
100 struct ipaddr *ip, bool uj);
101 extern void zebra_vxlan_print_evpn(struct vty *vty, bool uj);
102 extern void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
103 struct ethaddr *rmac,
104 bool use_json);
105 extern void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf,
106 vni_t vni, bool use_json, bool detail);
107 extern void zebra_vxlan_print_macs_all_vni(struct vty *vty,
108 struct zebra_vrf *zvrf,
109 bool print_dup,
110 bool use_json);
111 extern void zebra_vxlan_print_macs_all_vni_detail(struct vty *vty,
112 struct zebra_vrf *zvrf,
113 bool print_dup,
114 bool use_json);
115 extern void zebra_vxlan_print_macs_all_vni_vtep(struct vty *vty,
116 struct zebra_vrf *zvrf,
117 struct in_addr vtep_ip,
118 bool use_json);
119 extern void zebra_vxlan_print_specific_mac_vni(struct vty *vty,
120 struct zebra_vrf *zvrf,
121 vni_t vni, struct ethaddr *mac,
122 bool use_json);
123 extern void zebra_vxlan_print_macs_vni_vtep(struct vty *vty,
124 struct zebra_vrf *zvrf, vni_t vni,
125 struct in_addr vtep_ip,
126 bool use_json);
127 extern void zebra_vxlan_print_macs_vni_dad(struct vty *vty,
128 struct zebra_vrf *zvrf, vni_t vni,
129 bool use_json);
130 extern void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf,
131 vni_t vni, bool use_json);
132 extern void zebra_vxlan_print_neigh_all_vni(struct vty *vty,
133 struct zebra_vrf *zvrf,
134 bool print_dup,
135 bool use_json);
136 extern void zebra_vxlan_print_neigh_all_vni_detail(struct vty *vty,
137 struct zebra_vrf *zvrf,
138 bool print_dup,
139 bool use_json);
140 extern void zebra_vxlan_print_specific_neigh_vni(struct vty *vty,
141 struct zebra_vrf *zvrf,
142 vni_t vni, struct ipaddr *ip,
143 bool use_json);
144 extern void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty,
145 struct zebra_vrf *zvrf, vni_t vni,
146 struct in_addr vtep_ip,
147 bool use_json);
148 extern void zebra_vxlan_print_neigh_vni_dad(struct vty *vty,
149 struct zebra_vrf *zvrf, vni_t vni,
150 bool use_json);
151 extern void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf,
152 vni_t vni, bool use_json,
153 json_object *json_array);
154 extern void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
155 bool use_json);
156 extern void zebra_vxlan_print_vnis_detail(struct vty *vty,
157 struct zebra_vrf *zvrf,
158 bool use_json);
159 extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni,
160 bool use_json);
161 extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json);
162 extern void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t vni,
163 bool use_json);
164 extern void zebra_vxlan_print_nh_svd(struct vty *vty, bool use_json);
165 extern void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json);
166 extern void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, bool use_json);
167 extern void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,
168 json_object *json_vrfs);
169 extern int zebra_vxlan_add_del_gw_macip(struct interface *ifp,
170 const struct prefix *p, int add);
171 extern int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if);
172 extern int zebra_vxlan_svi_down(struct interface *ifp,
173 struct interface *link_if);
174 extern int zebra_vxlan_handle_kernel_neigh_update(
175 struct interface *ifp, struct interface *link_if, struct ipaddr *ip,
176 struct ethaddr *macaddr, uint16_t state, bool is_ext,
177 bool is_router, bool local_inactive, bool dp_static);
178 extern int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
179 struct interface *link_if,
180 struct ipaddr *ip);
181 extern int zebra_vxlan_local_mac_add_update(struct interface *ifp,
182 struct interface *br_if,
183 struct ethaddr *mac, vlanid_t vid,
184 bool sticky, bool local_inactive,
185 bool dp_static);
186 extern int zebra_vxlan_local_mac_del(struct interface *ifp,
187 struct interface *br_if,
188 struct ethaddr *mac, vlanid_t vid);
189 extern int zebra_vxlan_check_readd_vtep(struct interface *ifp, vni_t vni,
190 struct in_addr vtep_ip);
191 extern int zebra_vxlan_if_up(struct interface *ifp);
192 extern int zebra_vxlan_if_down(struct interface *ifp);
193 extern int zebra_vxlan_if_add(struct interface *ifp);
194 extern int zebra_vxlan_if_update(struct interface *ifp,
195 struct zebra_vxlan_if_update_ctx *ctx);
196 extern int zebra_vxlan_if_del(struct interface *ifp);
197 extern int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni,
198 char *err, int err_str_sz,
199 int filter, int add);
200 extern void zebra_vxlan_init_tables(struct zebra_vrf *zvrf);
201 extern void zebra_vxlan_close_tables(struct zebra_vrf *);
202 extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *);
203 extern void zebra_vxlan_init(void);
204 extern void zebra_vxlan_disable(void);
205 extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,
206 const struct ethaddr *rmac,
207 const struct ipaddr *ip,
208 const struct prefix *host_prefix);
209 extern void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
210 struct ipaddr *vtep_ip,
211 struct prefix *host_prefix);
212 extern int zebra_vxlan_clear_dup_detect_vni_mac(struct zebra_vrf *zvrf,
213 vni_t vni,
214 struct ethaddr *macaddr,
215 char *errmsg,
216 size_t errmsg_len);
217 extern int zebra_vxlan_clear_dup_detect_vni_ip(struct zebra_vrf *zvrf,
218 vni_t vni, struct ipaddr *ip,
219 char *errmsg, size_t errmsg_len);
220 extern int zebra_vxlan_clear_dup_detect_vni_all(struct zebra_vrf *zvrf);
221 extern int zebra_vxlan_clear_dup_detect_vni(struct zebra_vrf *zvrf, vni_t vni);
222 extern void zebra_vxlan_handle_result(struct zebra_dplane_ctx *ctx);
223
224 extern void zebra_evpn_init(void);
225 extern void zebra_vxlan_macvlan_up(struct interface *ifp);
226 extern void zebra_vxlan_macvlan_down(struct interface *ifp);
227 extern int vni_list_cmp(void *p1, void *p2);
228 extern int zebra_vxlan_dp_network_mac_add(struct interface *ifp,
229 struct interface *br_if,
230 struct ethaddr *macaddr, vlanid_t vid,
231 vni_t vni, uint32_t nhg_id,
232 bool sticky, bool dp_static);
233 extern int zebra_vxlan_dp_network_mac_del(struct interface *ifp,
234 struct interface *br_if,
235 struct ethaddr *macaddr, vlanid_t vid,
236 vni_t vni);
237
238 extern void zebra_vxlan_set_accept_bgp_seq(bool set);
239 extern bool zebra_vxlan_get_accept_bgp_seq(void);
240
241 #ifdef __cplusplus
242 }
243 #endif
244
245 #endif /* _ZEBRA_VXLAN_H */