]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_evpn.h
Merge pull request #8182 from mjstapp/topotest_start_tgen
[mirror_frr.git] / zebra / zebra_evpn.h
1 /*
2 * Zebra EVPN Data structures and definitions
3 * These are "internal" to this function.
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
5 * Copyright (C) 2020 Volta Networks.
6 *
7 * This file is part of FRR.
8 *
9 * FRR is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
12 * later version.
13 *
14 * FRR is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with FRR; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 * 02111-1307, USA.
23 */
24
25 #ifndef _ZEBRA_EVPN_H
26 #define _ZEBRA_EVPN_H
27
28 #include <zebra.h>
29
30 #include "if.h"
31 #include "linklist.h"
32 #include "bitfield.h"
33
34 #include "zebra/zebra_l2.h"
35 #include "zebra/interface.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 typedef struct zebra_evpn_t_ zebra_evpn_t;
42 typedef struct zebra_vtep_t_ zebra_vtep_t;
43
44 RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
45 RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
46 zebra_es_evi_rb_cmp);
47
48 /* Private Structure to pass callback data for hash iterator */
49 struct zebra_evpn_show {
50 struct vty *vty;
51 json_object *json;
52 struct zebra_vrf *zvrf;
53 bool use_json;
54 };
55
56 /*
57 * VTEP info
58 *
59 * Right now, this just has each remote VTEP's IP address.
60 */
61 struct zebra_vtep_t_ {
62 /* Remote IP. */
63 /* NOTE: Can only be IPv4 right now. */
64 struct in_addr vtep_ip;
65 /* Flood mode (one of enum vxlan_flood_control) based on the PMSI
66 * tunnel type advertised by the remote VTEP
67 */
68 int flood_control;
69
70 /* Links. */
71 struct zebra_vtep_t_ *next;
72 struct zebra_vtep_t_ *prev;
73 };
74
75 /*
76 * VNI hash table
77 *
78 * Contains information pertaining to a VNI:
79 * - the list of remote VTEPs (with this VNI)
80 */
81 struct zebra_evpn_t_ {
82 /* VNI - key */
83 vni_t vni;
84
85 /* ES flags */
86 uint32_t flags;
87 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
88
89 /* Flag for advertising gw macip */
90 uint8_t advertise_gw_macip;
91
92 /* Flag for advertising svi macip */
93 uint8_t advertise_svi_macip;
94
95 /* Flag for advertising gw macip */
96 uint8_t advertise_subnet;
97
98 /* Corresponding VxLAN interface. */
99 struct interface *vxlan_if;
100
101 /* Corresponding SVI interface. */
102 struct interface *svi_if;
103
104 /* List of remote VTEPs */
105 zebra_vtep_t *vteps;
106
107 /* Local IP */
108 struct in_addr local_vtep_ip;
109
110 /* PIM-SM MDT group for BUM flooding */
111 struct in_addr mcast_grp;
112
113 /* tenant VRF, if any */
114 vrf_id_t vrf_id;
115
116 /* List of local or remote MAC */
117 struct hash *mac_table;
118
119 /* List of local or remote neighbors (MAC+IP) */
120 struct hash *neigh_table;
121
122 /* RB tree of ES-EVIs */
123 struct zebra_es_evi_rb_head es_evi_rb_tree;
124
125 /* List of local ESs */
126 struct list *local_es_evi_list;
127 };
128
129 /* for parsing evpn and vni contexts */
130 struct zebra_from_svi_param {
131 struct interface *br_if;
132 struct interface *svi_if;
133 struct zebra_if *zif;
134 uint8_t bridge_vlan_aware;
135 vlanid_t vid;
136 };
137
138 struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
139
140 static inline struct interface *zevpn_map_to_svi(zebra_evpn_t *zevpn)
141 {
142 struct interface *ifp;
143 struct zebra_if *zif = NULL;
144 struct zebra_l2info_vxlan zl2_info;
145
146 ifp = zevpn->vxlan_if;
147 if (!ifp)
148 return NULL;
149 zif = ifp->info;
150 if (!zif)
151 return NULL;
152
153 /* If down or not mapped to a bridge, we're done. */
154 if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
155 return NULL;
156 zl2_info = zif->l2info.vxl;
157 return zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
158 }
159
160 int advertise_gw_macip_enabled(zebra_evpn_t *zevpn);
161 int advertise_svi_macip_enabled(zebra_evpn_t *zevpn);
162 void zebra_evpn_print(zebra_evpn_t *zevpn, void **ctxt);
163 void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[]);
164 void zebra_evpn_print_hash_detail(struct hash_bucket *bucket, void *data);
165 int zebra_evpn_add_macip_for_intf(struct interface *ifp, zebra_evpn_t *zevpn);
166 int zebra_evpn_del_macip_for_intf(struct interface *ifp, zebra_evpn_t *zevpn);
167 int zebra_evpn_advertise_subnet(zebra_evpn_t *zevpn, struct interface *ifp,
168 int advertise);
169 int zebra_evpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
170 struct ethaddr *macaddr, struct ipaddr *ip);
171 int zebra_evpn_gw_macip_del(struct interface *ifp, zebra_evpn_t *zevpn,
172 struct ipaddr *ip);
173 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket *bucket,
174 void *ctxt);
175 void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket *bucket,
176 void *ctxt);
177 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
178 void *ctxt);
179 zebra_evpn_t *zebra_evpn_map_vlan(struct interface *ifp,
180 struct interface *br_if, vlanid_t vid);
181 zebra_evpn_t *zebra_evpn_from_svi(struct interface *ifp,
182 struct interface *br_if);
183 struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if,
184 struct interface *svi_if);
185 void zebra_evpn_install_mac_hash(struct hash_bucket *bucket, void *ctxt);
186 void zebra_evpn_read_mac_neigh(zebra_evpn_t *zevpn, struct interface *ifp);
187 unsigned int zebra_evpn_hash_keymake(const void *p);
188 bool zebra_evpn_hash_cmp(const void *p1, const void *p2);
189 int zebra_evpn_list_cmp(void *p1, void *p2);
190 void *zebra_evpn_alloc(void *p);
191 zebra_evpn_t *zebra_evpn_lookup(vni_t vni);
192 zebra_evpn_t *zebra_evpn_add(vni_t vni);
193 int zebra_evpn_del(zebra_evpn_t *zevpn);
194 int zebra_evpn_send_add_to_client(zebra_evpn_t *zevpn);
195 int zebra_evpn_send_del_to_client(zebra_evpn_t *zevpn);
196 zebra_vtep_t *zebra_evpn_vtep_find(zebra_evpn_t *zevpn,
197 struct in_addr *vtep_ip);
198 zebra_vtep_t *zebra_evpn_vtep_add(zebra_evpn_t *zevpn, struct in_addr *vtep_ip,
199 int flood_control);
200 int zebra_evpn_vtep_del(zebra_evpn_t *zevpn, zebra_vtep_t *zvtep);
201 int zebra_evpn_vtep_del_all(zebra_evpn_t *zevpn, int uninstall);
202 int zebra_evpn_vtep_install(zebra_evpn_t *zevpn, zebra_vtep_t *zvtep);
203 int zebra_evpn_vtep_uninstall(zebra_evpn_t *zevpn, struct in_addr *vtep_ip);
204 void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket *bucket,
205 void *zvrf);
206 void zebra_evpn_cleanup_all(struct hash_bucket *bucket, void *arg);
207 void zebra_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
208 uint16_t ipa_len, const struct ipaddr *ipaddr,
209 uint8_t flags, uint32_t seq,
210 struct in_addr vtep_ip, const esi_t *esi);
211 void zebra_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
212 uint16_t ipa_len, const struct ipaddr *ipaddr,
213 struct in_addr vtep_ip);
214 void zebra_evpn_cfg_cleanup(struct hash_bucket *bucket, void *ctxt);
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif /*_ZEBRA_EVPN_H */