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.
7 * This file is part of FRR.
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
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.
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
34 #include "zebra/zebra_l2.h"
35 #include "zebra/interface.h"
36 #include "zebra/zebra_vxlan.h"
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
,
46 /* Private Structure to pass callback data for hash iterator */
47 struct zebra_evpn_show
{
50 struct zebra_vrf
*zvrf
;
57 * Right now, this just has each remote VTEP's IP address.
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
69 struct zebra_vtep
*next
;
70 struct zebra_vtep
*prev
;
76 * Contains information pertaining to a VNI:
77 * - the list of remote VTEPs (with this VNI)
85 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
87 /* Flag for advertising gw macip */
88 uint8_t advertise_gw_macip
;
90 /* Flag for advertising svi macip */
91 uint8_t advertise_svi_macip
;
93 /* Flag for advertising gw macip */
94 uint8_t advertise_subnet
;
96 /* Corresponding VxLAN interface. */
97 struct interface
*vxlan_if
;
99 /* Corresponding SVI interface. */
100 struct interface
*svi_if
;
102 /* List of remote VTEPs */
103 struct zebra_vtep
*vteps
;
106 struct in_addr local_vtep_ip
;
108 /* PIM-SM MDT group for BUM flooding */
109 struct in_addr mcast_grp
;
111 /* tenant VRF, if any */
114 /* List of local or remote MAC */
115 struct hash
*mac_table
;
117 /* List of local or remote neighbors (MAC+IP) */
118 struct hash
*neigh_table
;
120 /* RB tree of ES-EVIs */
121 struct zebra_es_evi_rb_head es_evi_rb_tree
;
123 /* List of local ESs */
124 struct list
*local_es_evi_list
;
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
;
136 struct interface
*zvni_map_to_svi(vlanid_t vid
, struct interface
*br_if
);
138 static inline struct interface
*zevpn_map_to_svi(struct zebra_evpn
*zevpn
)
140 struct interface
*ifp
;
141 struct zebra_if
*zif
= NULL
;
142 struct zebra_vxlan_vni
*vni
;
144 ifp
= zevpn
->vxlan_if
;
150 vni
= zebra_vxlan_if_vni_find(zif
, zevpn
->vni
);
154 /* If down or not mapped to a bridge, we're done. */
155 if (!if_is_operative(ifp
) || !zif
->brslave_info
.br_if
)
158 return zvni_map_to_svi(vni
->access_vlan
, zif
->brslave_info
.br_if
);
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
,
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
,
176 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket
*bucket
,
178 void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket
*bucket
,
180 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket
*bucket
,
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
,
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
,
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
);
225 #endif /*_ZEBRA_EVPN_H */