]>
Commit | Line | Data |
---|---|---|
ce5160c0 AK |
1 | /* |
2 | * Zebra EVPN MH Data structures and definitions | |
3 | * | |
4 | * Copyright (C) 2019 Cumulus Networks, Inc. | |
5 | * Anuradha Karuppiah | |
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 | ||
20 | #ifndef _ZEBRA_EVPN_MH_H | |
21 | #define _ZEBRA_EVPN_MH_H | |
22 | ||
23 | #include <zebra.h> | |
24 | ||
25 | #include "if.h" | |
26 | #include "linklist.h" | |
27 | #include "bitfield.h" | |
28 | #include "zebra_vxlan.h" | |
29 | #include "zebra_vxlan_private.h" | |
30 | ||
31 | #define EVPN_MH_VTY_STR "Multihoming\n" | |
32 | ||
33 | /* Ethernet Segment entry - | |
34 | * - Local and remote ESs are maintained in a global RB tree, | |
35 | * zmh_info->es_rb_tree using ESI as key | |
36 | * - Local ESs are added via zebra config (ZEBRA_EVPNES_LOCAL) when an | |
37 | * access port is associated with an ES-ID | |
38 | * - Remotes ESs are added by BGP based on received/remote EAD/Type-1 routes | |
39 | * (ZEBRA_EVPNES_REMOTE) | |
40 | * - An ES can be simulatenously LOCAL and REMOTE; infact all LOCAL ESs are | |
41 | * expected to have REMOTE ES peers. | |
42 | */ | |
43 | struct zebra_evpn_es { | |
44 | esi_t esi; | |
45 | char esi_str[ESI_STR_LEN]; | |
46 | ||
47 | /* ES flags */ | |
48 | uint32_t flags; | |
49 | #define ZEBRA_EVPNES_LOCAL (1 << 0) /* configured in zebra */ | |
50 | #define ZEBRA_EVPNES_REMOTE (1 << 1) /* added by bgp */ | |
51 | #define ZEBRA_EVPNES_OPER_UP (1 << 2) /* es->ifp is oper-up */ | |
52 | #define ZEBRA_EVPNES_READY_FOR_BGP (1 << 3) /* ready to be sent to BGP */ | |
53 | #define ZEBRA_EVPNES_NHG_ACTIVE (1 << 4) /* NHG has been installed */ | |
1103c5c6 AK |
54 | /* This flag is only applicable to local ESs and signifies that this |
55 | * VTEP is not the DF | |
56 | */ | |
57 | #define ZEBRA_EVPNES_NON_DF (1 << 5) | |
28e80a03 AK |
58 | /* When the ES becomes a bridge port we need to activate the BUM non-DF |
59 | * filter, SPH filter and backup NHG for fast-failover | |
60 | */ | |
61 | #define ZEBRA_EVPNES_BR_PORT (1 << 6) | |
ce5160c0 AK |
62 | |
63 | /* memory used for adding the es to zmh_info->es_rb_tree */ | |
64 | RB_ENTRY(zebra_evpn_es) rb_node; | |
65 | ||
66 | /* [EVPNES_LOCAL] memory used for linking the es to | |
67 | * zmh_info->local_es_list | |
68 | */ | |
69 | struct listnode local_es_listnode; | |
70 | ||
71 | /* [EVPNES_LOCAL] corresponding interface */ | |
72 | struct zebra_if *zif; | |
73 | ||
74 | /* list of ES-EVIs associated with the ES */ | |
75 | struct list *es_evi_list; | |
76 | ||
77 | /* [!EVPNES_LOCAL] List of remote VTEPs (zebra_evpn_es_vtep) */ | |
78 | struct list *es_vtep_list; | |
79 | ||
b169fd6f AK |
80 | /* list of zebra_mac entries using this ES as destination */ |
81 | struct list *mac_list; | |
ce5160c0 AK |
82 | |
83 | /* Nexthop group id */ | |
84 | uint32_t nhg_id; | |
1103c5c6 AK |
85 | |
86 | /* Preference config for BUM-DF election. Sent to BGP and | |
87 | * advertised via the ESR | |
88 | */ | |
89 | uint16_t df_pref; | |
ce5160c0 AK |
90 | }; |
91 | RB_HEAD(zebra_es_rb_head, zebra_evpn_es); | |
92 | RB_PROTOTYPE(zebra_es_rb_head, zebra_evpn_es, rb_node, zebra_es_rb_cmp); | |
93 | ||
94 | /* ES per-EVI info | |
87d76d54 PR |
95 | * - ES-EVIs are maintained per-EVPN (vni->es_evi_rb_tree) |
96 | * - Local ES-EVIs are linked to per-EVPN list for quick access | |
ce5160c0 AK |
97 | * - Although some infrastucture is present for remote ES-EVIs, currently |
98 | * BGP does NOT send remote ES-EVIs to zebra. This may change in the | |
99 | * future (but must be changed thoughtfully and only if needed as ES-EVI | |
100 | * can get prolific and come in the way of rapid failovers) | |
101 | */ | |
102 | struct zebra_evpn_es_evi { | |
103 | struct zebra_evpn_es *es; | |
87d76d54 | 104 | zebra_evpn_t *zevpn; |
ce5160c0 AK |
105 | |
106 | /* ES-EVI flags */ | |
107 | uint32_t flags; | |
108 | /* local ES-EVI */ | |
109 | #define ZEBRA_EVPNES_EVI_LOCAL (1 << 0) /* created by zebra */ | |
110 | #define ZEBRA_EVPNES_EVI_READY_FOR_BGP (1 << 1) /* ready to be sent to BGP */ | |
111 | ||
112 | /* memory used for adding the es_evi to | |
87d76d54 | 113 | * es_evi->zevpn->es_evi_rb_tree |
ce5160c0 AK |
114 | */ |
115 | RB_ENTRY(zebra_evpn_es_evi) rb_node; | |
116 | /* memory used for linking the es_evi to | |
87d76d54 | 117 | * es_evi->zevpn->local_es_evi_list |
ce5160c0 AK |
118 | */ |
119 | struct listnode l2vni_listnode; | |
120 | /* memory used for linking the es_evi to | |
121 | * es_evi->es->es_evi_list | |
122 | */ | |
123 | struct listnode es_listnode; | |
124 | }; | |
125 | ||
126 | /* PE attached to an ES */ | |
127 | struct zebra_evpn_es_vtep { | |
128 | struct zebra_evpn_es *es; /* parent ES */ | |
129 | struct in_addr vtep_ip; | |
130 | ||
1103c5c6 AK |
131 | uint32_t flags; |
132 | /* Rxed Type-4 route from this VTEP */ | |
133 | #define ZEBRA_EVPNES_VTEP_RXED_ESR (1 << 0) | |
28e80a03 | 134 | #define ZEBRA_EVPNES_VTEP_DEL_IN_PROG (1 << 1) |
1103c5c6 | 135 | |
ce5160c0 AK |
136 | /* memory used for adding the entry to es->es_vtep_list */ |
137 | struct listnode es_listnode; | |
138 | ||
139 | /* MAC nexthop */ | |
140 | uint32_t nh_id; | |
141 | ||
1103c5c6 AK |
142 | /* Parameters for DF election */ |
143 | uint8_t df_alg; | |
144 | uint32_t df_pref; | |
145 | ||
ce5160c0 AK |
146 | /* XXX - maintain a backpointer to zebra_vtep_t */ |
147 | }; | |
148 | ||
149 | /* Local/access-side broadcast domain - zebra_evpn_access_bd is added to - | |
150 | * zrouter->evpn_vlan_table (for VLAN aware bridges) OR | |
151 | * zrouter->evpn_bridge_table (for VLAN unaware bridges) | |
152 | * XXX - support for VLAN unaware bridges is yet to be flushed out | |
153 | */ | |
154 | struct zebra_evpn_access_bd { | |
155 | vlanid_t vid; | |
156 | ||
157 | struct zebra_if *vxlan_zif; /* vxlan device */ | |
158 | /* list of members associated with the BD i.e. (potential) ESs */ | |
159 | struct list *mbr_zifs; | |
87d76d54 PR |
160 | /* presence of zevpn activates the EVI on all the ESs in mbr_zifs */ |
161 | zebra_evpn_t *zevpn; | |
ce5160c0 AK |
162 | }; |
163 | ||
164 | /* multihoming information stored in zrouter */ | |
165 | #define zmh_info (zrouter.mh_info) | |
166 | struct zebra_evpn_mh_info { | |
167 | /* RB tree of Ethernet segments (used for EVPN-MH) */ | |
168 | struct zebra_es_rb_head es_rb_tree; | |
169 | /* List of local ESs */ | |
170 | struct list *local_es_list; | |
171 | ||
172 | /* EVPN MH broadcast domains indexed by the VID */ | |
173 | struct hash *evpn_vlan_table; | |
174 | ||
175 | /* A base L2-VNI is maintained to derive parameters such as | |
176 | * ES originator-IP. | |
177 | * XXX: once single vxlan device model becomes available this will | |
178 | * not be necessary | |
179 | */ | |
87d76d54 | 180 | zebra_evpn_t *es_base_evpn; |
ce5160c0 AK |
181 | struct in_addr es_originator_ip; |
182 | ||
183 | /* L2 NH and NHG ids - | |
184 | * Most significant 8 bits is type. Lower 24 bits is the value | |
185 | * allocated from the nh_id_bitmap. | |
186 | */ | |
187 | bitfield_t nh_id_bitmap; | |
188 | #define EVPN_NH_ID_MAX (16*1024) | |
189 | #define EVPN_NH_ID_VAL_MASK 0xffffff | |
190 | #define EVPN_NH_ID_TYPE_POS 24 | |
191 | /* The purpose of using different types for NHG and NH is NOT to manage the | |
192 | * id space separately. It is simply to make debugging easier. | |
193 | */ | |
194 | #define EVPN_NH_ID_TYPE_BIT (1 << EVPN_NH_ID_TYPE_POS) | |
195 | #define EVPN_NHG_ID_TYPE_BIT (2 << EVPN_NH_ID_TYPE_POS) | |
b169fd6f AK |
196 | |
197 | /* XXX - re-visit the default hold timer value */ | |
198 | #define EVPN_MH_MAC_HOLD_TIME_DEF (18 * 60) | |
199 | long mac_hold_time; | |
200 | #define EVPN_MH_NEIGH_HOLD_TIME_DEF (18 * 60) | |
201 | long neigh_hold_time; | |
ce5160c0 AK |
202 | }; |
203 | ||
204 | static inline bool zebra_evpn_mac_is_es_local(zebra_mac_t *mac) | |
205 | { | |
206 | return mac->es && (mac->es->flags & ZEBRA_EVPNES_LOCAL); | |
207 | } | |
208 | ||
209 | /* Returns true if the id is of L2-NHG or L2-NH type */ | |
210 | static inline bool zebra_evpn_mh_is_fdb_nh(uint32_t id) | |
211 | { | |
212 | return ((id & EVPN_NHG_ID_TYPE_BIT) || | |
213 | (id & EVPN_NH_ID_TYPE_BIT)); | |
214 | } | |
215 | ||
216 | /*****************************************************************************/ | |
217 | extern esi_t *zero_esi; | |
218 | extern void zebra_evpn_mh_init(void); | |
219 | extern void zebra_evpn_mh_terminate(void); | |
220 | extern bool zebra_evpn_is_if_es_capable(struct zebra_if *zif); | |
221 | extern void zebra_evpn_if_init(struct zebra_if *zif); | |
222 | extern void zebra_evpn_if_cleanup(struct zebra_if *zif); | |
945ee7b2 AK |
223 | extern void zebra_evpn_es_evi_init(zebra_evpn_t *zevpn); |
224 | extern void zebra_evpn_es_evi_cleanup(zebra_evpn_t *zevpn); | |
87d76d54 | 225 | extern void zebra_evpn_vxl_evpn_set(struct zebra_if *zif, zebra_evpn_t *zevpn, |
ce5160c0 | 226 | bool set); |
87d76d54 PR |
227 | extern void zebra_evpn_es_set_base_evpn(zebra_evpn_t *zevpn); |
228 | extern void zebra_evpn_es_clear_base_evpn(zebra_evpn_t *zevpn); | |
ce5160c0 AK |
229 | extern void zebra_evpn_vl_vxl_ref(uint16_t vid, struct zebra_if *vxlan_zif); |
230 | extern void zebra_evpn_vl_vxl_deref(uint16_t vid, struct zebra_if *vxlan_zif); | |
231 | extern void zebra_evpn_vl_mbr_ref(uint16_t vid, struct zebra_if *zif); | |
232 | extern void zebra_evpn_vl_mbr_deref(uint16_t vid, struct zebra_if *zif); | |
233 | extern void zebra_evpn_es_send_all_to_client(bool add); | |
234 | extern void zebra_evpn_es_if_oper_state_change(struct zebra_if *zif, bool up); | |
235 | extern void zebra_evpn_es_show(struct vty *vty, bool uj); | |
236 | extern void zebra_evpn_es_show_detail(struct vty *vty, bool uj); | |
237 | extern void zebra_evpn_es_show_esi(struct vty *vty, bool uj, esi_t *esi); | |
87d76d54 | 238 | extern void zebra_evpn_update_all_es(zebra_evpn_t *zevpn); |
ce5160c0 AK |
239 | extern void zebra_evpn_proc_remote_es(ZAPI_HANDLER_ARGS); |
240 | extern void zebra_evpn_es_evi_show(struct vty *vty, bool uj, int detail); | |
241 | extern void zebra_evpn_es_evi_show_vni(struct vty *vty, bool uj, | |
242 | vni_t vni, int detail); | |
243 | extern void zebra_evpn_es_mac_deref_entry(zebra_mac_t *mac); | |
244 | extern bool zebra_evpn_es_mac_ref_entry(zebra_mac_t *mac, | |
245 | struct zebra_evpn_es *es); | |
b169fd6f | 246 | extern bool zebra_evpn_es_mac_ref(zebra_mac_t *mac, esi_t *esi); |
ce5160c0 AK |
247 | extern struct zebra_evpn_es *zebra_evpn_es_find(esi_t *esi); |
248 | extern void zebra_evpn_interface_init(void); | |
249 | extern int zebra_evpn_mh_if_write(struct vty *vty, struct interface *ifp); | |
250 | extern void zebra_evpn_acc_vl_show(struct vty *vty, bool uj); | |
251 | extern void zebra_evpn_acc_vl_show_detail(struct vty *vty, bool uj); | |
252 | extern void zebra_evpn_acc_vl_show_vid(struct vty *vty, bool uj, vlanid_t vid); | |
253 | extern void zebra_evpn_if_es_print(struct vty *vty, struct zebra_if *zif); | |
254 | extern void zebra_evpn_es_cleanup(void); | |
b169fd6f AK |
255 | extern int zebra_evpn_mh_mac_holdtime_update(struct vty *vty, |
256 | uint32_t duration, bool set_default); | |
257 | void zebra_evpn_mh_config_write(struct vty *vty); | |
258 | int zebra_evpn_mh_neigh_holdtime_update(struct vty *vty, | |
259 | uint32_t duration, bool set_default); | |
ce5160c0 AK |
260 | |
261 | #endif /* _ZEBRA_EVPN_MH_H */ |