]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_evpn.h
zebra: multiple vlan aware bridge data structure and related changes
[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 #include "zebra/zebra_vxlan.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
43 RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
44 zebra_es_evi_rb_cmp);
45
46 /* Private Structure to pass callback data for hash iterator */
47 struct zebra_evpn_show {
48 struct vty *vty;
49 json_object *json;
50 struct zebra_vrf *zvrf;
51 bool use_json;
52 };
53
54 /*
55 * VTEP info
56 *
57 * Right now, this just has each remote VTEP's IP address.
58 */
59 struct zebra_vtep {
60 /* Remote IP. */
61 /* NOTE: Can only be IPv4 right now. */
62 struct in_addr vtep_ip;
63 /* Flood mode (one of enum vxlan_flood_control) based on the PMSI
64 * tunnel type advertised by the remote VTEP
65 */
66 int flood_control;
67
68 /* Links. */
69 struct zebra_vtep *next;
70 struct zebra_vtep *prev;
71 };
72
73 /*
74 * VNI hash table
75 *
76 * Contains information pertaining to a VNI:
77 * - the list of remote VTEPs (with this VNI)
78 */
79 struct zebra_evpn {
80 /* VNI - key */
81 vni_t vni;
82
83 /* ES flags */
84 uint32_t flags;
85 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
86
87 /* Flag for advertising gw macip */
88 uint8_t advertise_gw_macip;
89
90 /* Flag for advertising svi macip */
91 uint8_t advertise_svi_macip;
92
93 /* Flag for advertising gw macip */
94 uint8_t advertise_subnet;
95
96 /* Corresponding VxLAN interface. */
97 struct interface *vxlan_if;
98
99 /* Corresponding SVI interface. */
100 struct interface *svi_if;
101
102 /* List of remote VTEPs */
103 struct zebra_vtep *vteps;
104
105 /* Local IP */
106 struct in_addr local_vtep_ip;
107
108 /* PIM-SM MDT group for BUM flooding */
109 struct in_addr mcast_grp;
110
111 /* tenant VRF, if any */
112 vrf_id_t vrf_id;
113
114 /* List of local or remote MAC */
115 struct hash *mac_table;
116
117 /* List of local or remote neighbors (MAC+IP) */
118 struct hash *neigh_table;
119
120 /* RB tree of ES-EVIs */
121 struct zebra_es_evi_rb_head es_evi_rb_tree;
122
123 /* List of local ESs */
124 struct list *local_es_evi_list;
125 };
126
127 /* for parsing evpn and vni contexts */
128 struct zebra_from_svi_param {
129 struct interface *br_if;
130 struct interface *svi_if;
131 struct zebra_if *zif;
132 uint8_t bridge_vlan_aware;
133 vlanid_t vid;
134 };
135
136 struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
137
138 static inline struct interface *zevpn_map_to_svi(struct zebra_evpn *zevpn)
139 {
140 struct interface *ifp;
141 struct zebra_if *zif = NULL;
142 struct zebra_vxlan_vni *vni;
143
144 ifp = zevpn->vxlan_if;
145 if (!ifp)
146 return NULL;
147 zif = ifp->info;
148 if (!zif)
149 return NULL;
150 vni = zebra_vxlan_if_vni_find(zif, zevpn->vni);
151 if (!vni)
152 return NULL;
153
154 /* If down or not mapped to a bridge, we're done. */
155 if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
156 return NULL;
157
158 return zvni_map_to_svi(vni->access_vlan, zif->brslave_info.br_if);
159 }
160
161 int advertise_gw_macip_enabled(struct zebra_evpn *zevpn);
162 int advertise_svi_macip_enabled(struct zebra_evpn *zevpn);
163 void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt);
164 void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[]);
165 void zebra_evpn_print_hash_detail(struct hash_bucket *bucket, void *data);
166 int zebra_evpn_add_macip_for_intf(struct interface *ifp,
167 struct zebra_evpn *zevpn);
168 int zebra_evpn_del_macip_for_intf(struct interface *ifp,
169 struct zebra_evpn *zevpn);
170 int zebra_evpn_advertise_subnet(struct zebra_evpn *zevpn, struct interface *ifp,
171 int advertise);
172 int zebra_evpn_gw_macip_add(struct interface *ifp, struct zebra_evpn *zevpn,
173 struct ethaddr *macaddr, struct ipaddr *ip);
174 int zebra_evpn_gw_macip_del(struct interface *ifp, struct zebra_evpn *zevpn,
175 struct ipaddr *ip);
176 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket *bucket,
177 void *ctxt);
178 void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket *bucket,
179 void *ctxt);
180 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
181 void *ctxt);
182 struct zebra_evpn *zebra_evpn_map_vlan(struct interface *ifp,
183 struct interface *br_if, vlanid_t vid);
184 struct zebra_evpn *zebra_evpn_from_svi(struct interface *ifp,
185 struct interface *br_if);
186 struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if,
187 struct interface *svi_if);
188 void zebra_evpn_install_mac_hash(struct hash_bucket *bucket, void *ctxt);
189 void zebra_evpn_read_mac_neigh(struct zebra_evpn *zevpn, struct interface *ifp);
190 unsigned int zebra_evpn_hash_keymake(const void *p);
191 bool zebra_evpn_hash_cmp(const void *p1, const void *p2);
192 int zebra_evpn_list_cmp(void *p1, void *p2);
193 void *zebra_evpn_alloc(void *p);
194 struct zebra_evpn *zebra_evpn_lookup(vni_t vni);
195 struct zebra_evpn *zebra_evpn_add(vni_t vni);
196 int zebra_evpn_del(struct zebra_evpn *zevpn);
197 int zebra_evpn_send_add_to_client(struct zebra_evpn *zevpn);
198 int zebra_evpn_send_del_to_client(struct zebra_evpn *zevpn);
199 struct zebra_vtep *zebra_evpn_vtep_find(struct zebra_evpn *zevpn,
200 struct in_addr *vtep_ip);
201 struct zebra_vtep *zebra_evpn_vtep_add(struct zebra_evpn *zevpn,
202 struct in_addr *vtep_ip,
203 int flood_control);
204 int zebra_evpn_vtep_del(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
205 int zebra_evpn_vtep_del_all(struct zebra_evpn *zevpn, int uninstall);
206 int zebra_evpn_vtep_install(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
207 int zebra_evpn_vtep_uninstall(struct zebra_evpn *zevpn,
208 struct in_addr *vtep_ip);
209 void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket *bucket,
210 void *zvrf);
211 void zebra_evpn_cleanup_all(struct hash_bucket *bucket, void *arg);
212 void zebra_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
213 uint16_t ipa_len, const struct ipaddr *ipaddr,
214 uint8_t flags, uint32_t seq,
215 struct in_addr vtep_ip, const esi_t *esi);
216 void zebra_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
217 uint16_t ipa_len, const struct ipaddr *ipaddr,
218 struct in_addr vtep_ip);
219 void zebra_evpn_cfg_cleanup(struct hash_bucket *bucket, void *ctxt);
220
221 #ifdef __cplusplus
222 }
223 #endif
224
225 #endif /*_ZEBRA_EVPN_H */