1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Zebra EVPN Data structures and definitions
4 * These are "internal" to this function.
5 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
6 * Copyright (C) 2020 Volta Networks.
18 #include "zebra/zebra_l2.h"
19 #include "zebra/interface.h"
20 #include "zebra/zebra_vxlan.h"
26 RB_HEAD(zebra_es_evi_rb_head
, zebra_evpn_es_evi
);
27 RB_PROTOTYPE(zebra_es_evi_rb_head
, zebra_evpn_es_evi
, rb_node
,
30 /* Private Structure to pass callback data for hash iterator */
31 struct zebra_evpn_show
{
34 struct zebra_vrf
*zvrf
;
41 * Right now, this just has each remote VTEP's IP address.
45 /* NOTE: Can only be IPv4 right now. */
46 struct in_addr vtep_ip
;
47 /* Flood mode (one of enum vxlan_flood_control) based on the PMSI
48 * tunnel type advertised by the remote VTEP
53 struct zebra_vtep
*next
;
54 struct zebra_vtep
*prev
;
60 * Contains information pertaining to a VNI:
61 * - the list of remote VTEPs (with this VNI)
69 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
71 /* Corresponding Bridge information */
73 struct interface
*bridge_if
;
75 /* Flag for advertising gw macip */
76 uint8_t advertise_gw_macip
;
78 /* Flag for advertising svi macip */
79 uint8_t advertise_svi_macip
;
81 /* Flag for advertising gw macip */
82 uint8_t advertise_subnet
;
84 /* Corresponding VxLAN interface. */
85 struct interface
*vxlan_if
;
87 /* Corresponding SVI interface. */
88 struct interface
*svi_if
;
90 /* List of remote VTEPs */
91 struct zebra_vtep
*vteps
;
94 struct in_addr local_vtep_ip
;
96 /* PIM-SM MDT group for BUM flooding */
97 struct in_addr mcast_grp
;
99 /* tenant VRF, if any */
102 /* List of local or remote MAC */
103 struct hash
*mac_table
;
105 /* List of local or remote neighbors (MAC+IP) */
106 struct hash
*neigh_table
;
108 /* RB tree of ES-EVIs */
109 struct zebra_es_evi_rb_head es_evi_rb_tree
;
111 /* List of local ESs */
112 struct list
*local_es_evi_list
;
115 /* for parsing evpn and vni contexts */
116 struct zebra_from_svi_param
{
117 struct interface
*br_if
;
118 struct interface
*svi_if
;
119 struct zebra_if
*zif
;
120 uint8_t bridge_vlan_aware
;
124 struct interface
*zvni_map_to_svi(vlanid_t vid
, struct interface
*br_if
);
126 static inline struct interface
*zevpn_map_to_svi(struct zebra_evpn
*zevpn
)
128 struct interface
*ifp
;
129 struct zebra_if
*zif
= NULL
;
130 struct zebra_vxlan_vni
*vni
;
132 ifp
= zevpn
->vxlan_if
;
138 vni
= zebra_vxlan_if_vni_find(zif
, zevpn
->vni
);
142 /* If down or not mapped to a bridge, we're done. */
143 if (!if_is_operative(ifp
) || !zif
->brslave_info
.br_if
)
146 return zvni_map_to_svi(vni
->access_vlan
, zif
->brslave_info
.br_if
);
149 int advertise_gw_macip_enabled(struct zebra_evpn
*zevpn
);
150 int advertise_svi_macip_enabled(struct zebra_evpn
*zevpn
);
151 void zebra_evpn_print(struct zebra_evpn
*zevpn
, void **ctxt
);
152 void zebra_evpn_print_hash(struct hash_bucket
*bucket
, void *ctxt
[]);
153 void zebra_evpn_print_hash_detail(struct hash_bucket
*bucket
, void *data
);
154 int zebra_evpn_add_macip_for_intf(struct interface
*ifp
,
155 struct zebra_evpn
*zevpn
);
156 int zebra_evpn_del_macip_for_intf(struct interface
*ifp
,
157 struct zebra_evpn
*zevpn
);
158 int zebra_evpn_advertise_subnet(struct zebra_evpn
*zevpn
, struct interface
*ifp
,
160 int zebra_evpn_gw_macip_add(struct interface
*ifp
, struct zebra_evpn
*zevpn
,
161 struct ethaddr
*macaddr
, struct ipaddr
*ip
);
162 int zebra_evpn_gw_macip_del(struct interface
*ifp
, struct zebra_evpn
*zevpn
,
164 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket
*bucket
,
166 void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket
*bucket
,
168 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket
*bucket
,
170 struct zebra_evpn
*zebra_evpn_map_vlan(struct interface
*ifp
,
171 struct interface
*br_if
, vlanid_t vid
);
172 struct zebra_evpn
*zebra_evpn_from_svi(struct interface
*ifp
,
173 struct interface
*br_if
);
174 struct interface
*zebra_evpn_map_to_macvlan(struct interface
*br_if
,
175 struct interface
*svi_if
);
176 void zebra_evpn_rem_mac_install_all(struct zebra_evpn
*zevpn
);
177 void zebra_evpn_rem_mac_uninstall_all(struct zebra_evpn
*zevpn
);
178 void zebra_evpn_read_mac_neigh(struct zebra_evpn
*zevpn
, struct interface
*ifp
);
179 unsigned int zebra_evpn_hash_keymake(const void *p
);
180 bool zebra_evpn_hash_cmp(const void *p1
, const void *p2
);
181 int zebra_evpn_list_cmp(void *p1
, void *p2
);
182 void *zebra_evpn_alloc(void *p
);
183 struct zebra_evpn
*zebra_evpn_lookup(vni_t vni
);
184 struct zebra_evpn
*zebra_evpn_add(vni_t vni
);
185 int zebra_evpn_del(struct zebra_evpn
*zevpn
);
186 int zebra_evpn_send_add_to_client(struct zebra_evpn
*zevpn
);
187 int zebra_evpn_send_del_to_client(struct zebra_evpn
*zevpn
);
188 struct zebra_vtep
*zebra_evpn_vtep_find(struct zebra_evpn
*zevpn
,
189 struct in_addr
*vtep_ip
);
190 struct zebra_vtep
*zebra_evpn_vtep_add(struct zebra_evpn
*zevpn
,
191 struct in_addr
*vtep_ip
,
193 int zebra_evpn_vtep_del(struct zebra_evpn
*zevpn
, struct zebra_vtep
*zvtep
);
194 int zebra_evpn_vtep_del_all(struct zebra_evpn
*zevpn
, int uninstall
);
195 int zebra_evpn_vtep_install(struct zebra_evpn
*zevpn
, struct zebra_vtep
*zvtep
);
196 int zebra_evpn_vtep_uninstall(struct zebra_evpn
*zevpn
,
197 struct in_addr
*vtep_ip
);
198 void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket
*bucket
,
200 void zebra_evpn_cleanup_all(struct hash_bucket
*bucket
, void *arg
);
201 void zebra_evpn_rem_macip_add(vni_t vni
, const struct ethaddr
*macaddr
,
202 uint16_t ipa_len
, const struct ipaddr
*ipaddr
,
203 uint8_t flags
, uint32_t seq
,
204 struct in_addr vtep_ip
, const esi_t
*esi
);
205 void zebra_evpn_rem_macip_del(vni_t vni
, const struct ethaddr
*macaddr
,
206 uint16_t ipa_len
, const struct ipaddr
*ipaddr
,
207 struct in_addr vtep_ip
);
208 void zebra_evpn_cfg_cleanup(struct hash_bucket
*bucket
, void *ctxt
);
214 #endif /*_ZEBRA_EVPN_H */