]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_evpn_private.h
Merge pull request #8850 from opensourcerouting/ospf6-checksum-json
[mirror_frr.git] / bgpd / bgp_evpn_private.h
1 /* BGP EVPN internal definitions
2 * Copyright (C) 2017 Cumulus Networks, Inc.
3 *
4 * This file is part of FRR.
5 *
6 * FRR is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * FRR is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with FRR; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #ifndef _BGP_EVPN_PRIVATE_H
23 #define _BGP_EVPN_PRIVATE_H
24
25 #include "vxlan.h"
26 #include "zebra.h"
27
28 #include "bgpd/bgpd.h"
29 #include "bgpd/bgp_ecommunity.h"
30
31 #define RT_ADDRSTRLEN 28
32
33 /* EVPN prefix lengths. This represents the sizeof struct evpn_addr
34 * in bits */
35 #define EVPN_ROUTE_PREFIXLEN (sizeof(struct evpn_addr) * 8)
36
37 /* EVPN route RD buffer length */
38 #define BGP_EVPN_PREFIX_RD_LEN 100
39
40 /* packet sizes for EVPN routes */
41 /* Type-1 route should be 25 bytes
42 * RD (8), ESI (10), eth-tag (4), vni (3)
43 */
44 #define BGP_EVPN_TYPE1_PSIZE 25
45 /* Type-4 route should be either 23 or 35 bytes
46 * RD (8), ESI (10), ip-len (1), ip (4 or 16)
47 */
48 #define BGP_EVPN_TYPE4_V4_PSIZE 23
49 #define BGP_EVPN_TYPE4_V6_PSIZE 34
50
51 RB_HEAD(bgp_es_evi_rb_head, bgp_evpn_es_evi);
52 RB_PROTOTYPE(bgp_es_evi_rb_head, bgp_evpn_es_evi, rb_node,
53 bgp_es_evi_rb_cmp);
54 /*
55 * Hash table of EVIs. Right now, the only type of EVI supported is with
56 * VxLAN encapsulation, hence each EVI corresponds to a L2 VNI.
57 * The VNIs are not "created" through BGP but through some other interface
58 * on the system. This table stores VNIs that BGP comes to know as present
59 * on the system (through interaction with zebra) as well as pre-configured
60 * VNIs (which need to be defined in the system to become "live").
61 */
62 struct bgpevpn {
63 vni_t vni;
64 vrf_id_t tenant_vrf_id;
65 ifindex_t svi_ifindex;
66 uint32_t flags;
67 #define VNI_FLAG_CFGD 0x1 /* VNI is user configured */
68 #define VNI_FLAG_LIVE 0x2 /* VNI is "live" */
69 #define VNI_FLAG_RD_CFGD 0x4 /* RD is user configured. */
70 #define VNI_FLAG_IMPRT_CFGD 0x8 /* Import RT is user configured */
71 #define VNI_FLAG_EXPRT_CFGD 0x10 /* Export RT is user configured */
72 #define VNI_FLAG_USE_TWO_LABELS 0x20 /* Attach both L2-VNI and L3-VNI if
73 needed for this VPN */
74
75 struct bgp *bgp_vrf; /* back pointer to the vrf instance */
76
77 /* Flag to indicate if we are
78 * advertising the g/w mac ip for
79 * this VNI*/
80 uint8_t advertise_gw_macip;
81
82 /* Flag to indicate if we are
83 * advertising subnet for this VNI */
84 uint8_t advertise_subnet;
85
86 /* Flag to indicate if we are advertising the svi mac ip for this VNI*/
87 uint8_t advertise_svi_macip;
88
89 /* Id for deriving the RD
90 * automatically for this VNI */
91 uint16_t rd_id;
92
93 /* RD for this VNI. */
94 struct prefix_rd prd;
95
96 /* Route type 3 field */
97 struct in_addr originator_ip;
98
99 /* PIM-SM MDT group for BUM flooding */
100 struct in_addr mcast_grp;
101
102 /* Import and Export RTs. */
103 struct list *import_rtl;
104 struct list *export_rtl;
105
106 /*
107 * EVPN route that uses gateway IP overlay index as its nexthop
108 * needs to do a recursive lookup.
109 * A remote MAC/IP entry should be present for the gateway IP.
110 * Maintain a hash of the addresses received via remote MAC/IP routes
111 * for efficient gateway IP recursive lookup in this EVI
112 */
113 struct hash *remote_ip_hash;
114
115 /* Route table for EVPN routes for
116 * this VNI. */
117 struct bgp_table *route_table;
118
119 /* RB tree of ES-EVIs */
120 struct bgp_es_evi_rb_head es_evi_rb_tree;
121
122 /* List of local ESs */
123 struct list *local_es_evi_list;
124
125 QOBJ_FIELDS;
126 };
127
128 DECLARE_QOBJ_TYPE(bgpevpn);
129
130 /* Mapping of Import RT to VNIs.
131 * The Import RTs of all VNIs are maintained in a hash table with each
132 * RT linking to all VNIs that will import routes matching this RT.
133 */
134 struct irt_node {
135 /* RT */
136 struct ecommunity_val rt;
137
138 /* List of VNIs importing routes matching this RT. */
139 struct list *vnis;
140 };
141
142 /* Mapping of Import RT to VRFs.
143 * The Import RTs of all VRFss are maintained in a hash table with each
144 * RT linking to all VRFs that will import routes matching this RT.
145 */
146 struct vrf_irt_node {
147 /* RT */
148 struct ecommunity_val rt;
149
150 /* List of VNIs importing routes matching this RT. */
151 struct list *vrfs;
152 };
153
154
155 #define RT_TYPE_IMPORT 1
156 #define RT_TYPE_EXPORT 2
157 #define RT_TYPE_BOTH 3
158
159 #define EVPN_DAD_DEFAULT_TIME 180 /* secs */
160 #define EVPN_DAD_DEFAULT_MAX_MOVES 5 /* default from RFC 7432 */
161 #define EVPN_DAD_DEFAULT_AUTO_RECOVERY_TIME 1800 /* secs */
162
163 struct bgp_evpn_info {
164 /* enable disable dup detect */
165 bool dup_addr_detect;
166
167 /* Detection time(M) */
168 int dad_time;
169 /* Detection max moves(N) */
170 uint32_t dad_max_moves;
171 /* Permanent freeze */
172 bool dad_freeze;
173 /* Recovery time */
174 uint32_t dad_freeze_time;
175
176 /* EVPN enable - advertise svi macip routes */
177 int advertise_svi_macip;
178
179 /* PIP feature knob */
180 bool advertise_pip;
181 /* PIP IP (sys ip) */
182 struct in_addr pip_ip;
183 struct in_addr pip_ip_static;
184 /* PIP MAC (sys MAC) */
185 struct ethaddr pip_rmac;
186 struct ethaddr pip_rmac_static;
187 struct ethaddr pip_rmac_zebra;
188 bool is_anycast_mac;
189 };
190
191 /* This structure defines an entry in remote_ip_hash */
192 struct evpn_remote_ip {
193 struct ipaddr addr;
194 struct list *macip_path_list;
195 };
196
197 static inline int is_vrf_rd_configured(struct bgp *bgp_vrf)
198 {
199 return (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD));
200 }
201
202 static inline int bgp_evpn_vrf_rd_matches_existing(struct bgp *bgp_vrf,
203 struct prefix_rd *prd)
204 {
205 return (memcmp(&bgp_vrf->vrf_prd.val, prd->val, ECOMMUNITY_SIZE) == 0);
206 }
207
208 static inline vni_t bgpevpn_get_l3vni(struct bgpevpn *vpn)
209 {
210 return vpn->bgp_vrf ? vpn->bgp_vrf->l3vni : 0;
211 }
212
213 static inline void bgpevpn_get_rmac(struct bgpevpn *vpn, struct ethaddr *rmac)
214 {
215 memset(rmac, 0, sizeof(struct ethaddr));
216 if (!vpn->bgp_vrf)
217 return;
218 memcpy(rmac, &vpn->bgp_vrf->rmac, sizeof(struct ethaddr));
219 }
220
221 static inline struct list *bgpevpn_get_vrf_export_rtl(struct bgpevpn *vpn)
222 {
223 if (!vpn->bgp_vrf)
224 return NULL;
225
226 return vpn->bgp_vrf->vrf_export_rtl;
227 }
228
229 static inline struct list *bgpevpn_get_vrf_import_rtl(struct bgpevpn *vpn)
230 {
231 if (!vpn->bgp_vrf)
232 return NULL;
233
234 return vpn->bgp_vrf->vrf_import_rtl;
235 }
236
237 extern void bgp_evpn_es_evi_vrf_ref(struct bgpevpn *vpn);
238 extern void bgp_evpn_es_evi_vrf_deref(struct bgpevpn *vpn);
239
240 static inline void bgpevpn_unlink_from_l3vni(struct bgpevpn *vpn)
241 {
242 /* bail if vpn is not associated to bgp_vrf */
243 if (!vpn->bgp_vrf)
244 return;
245
246 UNSET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);
247 listnode_delete(vpn->bgp_vrf->l2vnis, vpn);
248
249 bgp_evpn_es_evi_vrf_deref(vpn);
250
251 /* remove the backpointer to the vrf instance */
252 bgp_unlock(vpn->bgp_vrf);
253 vpn->bgp_vrf = NULL;
254 }
255
256 static inline void bgpevpn_link_to_l3vni(struct bgpevpn *vpn)
257 {
258 struct bgp *bgp_vrf = NULL;
259
260 /* bail if vpn is already associated to vrf */
261 if (vpn->bgp_vrf)
262 return;
263
264 bgp_vrf = bgp_lookup_by_vrf_id(vpn->tenant_vrf_id);
265 if (!bgp_vrf)
266 return;
267
268 /* associate the vpn to the bgp_vrf instance */
269 vpn->bgp_vrf = bgp_lock(bgp_vrf);
270 listnode_add_sort(bgp_vrf->l2vnis, vpn);
271
272 /*
273 * If L3VNI is configured,
274 * check if we are advertising two labels for this vpn
275 */
276 if (bgp_vrf->l3vni &&
277 !CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY))
278 SET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);
279
280 bgp_evpn_es_evi_vrf_ref(vpn);
281 }
282
283 static inline int is_vni_configured(struct bgpevpn *vpn)
284 {
285 return (CHECK_FLAG(vpn->flags, VNI_FLAG_CFGD));
286 }
287
288 static inline int is_vni_live(struct bgpevpn *vpn)
289 {
290 return (CHECK_FLAG(vpn->flags, VNI_FLAG_LIVE));
291 }
292
293 static inline int is_l3vni_live(struct bgp *bgp_vrf)
294 {
295 return (bgp_vrf->l3vni && bgp_vrf->l3vni_svi_ifindex);
296 }
297
298 static inline int is_rd_configured(struct bgpevpn *vpn)
299 {
300 return (CHECK_FLAG(vpn->flags, VNI_FLAG_RD_CFGD));
301 }
302
303 static inline int bgp_evpn_rd_matches_existing(struct bgpevpn *vpn,
304 struct prefix_rd *prd)
305 {
306 return (memcmp(&vpn->prd.val, prd->val, ECOMMUNITY_SIZE) == 0);
307 }
308
309 static inline int is_import_rt_configured(struct bgpevpn *vpn)
310 {
311 return (CHECK_FLAG(vpn->flags, VNI_FLAG_IMPRT_CFGD));
312 }
313
314 static inline int is_export_rt_configured(struct bgpevpn *vpn)
315 {
316 return (CHECK_FLAG(vpn->flags, VNI_FLAG_EXPRT_CFGD));
317 }
318
319 static inline int is_vni_param_configured(struct bgpevpn *vpn)
320 {
321 return (is_rd_configured(vpn) || is_import_rt_configured(vpn)
322 || is_export_rt_configured(vpn));
323 }
324
325 static inline void encode_es_rt_extcomm(struct ecommunity_val *eval,
326 struct ethaddr *mac)
327 {
328 memset(eval, 0, sizeof(struct ecommunity_val));
329 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
330 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT;
331 memcpy(&eval->val[2], mac, ETH_ALEN);
332 }
333
334 static inline void encode_df_elect_extcomm(struct ecommunity_val *eval,
335 uint16_t pref)
336 {
337 memset(eval, 0, sizeof(*eval));
338 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
339 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_DF_ELECTION;
340 eval->val[2] = EVPN_MH_DF_ALG_PREF;
341 eval->val[6] = (pref >> 8) & 0xff;
342 eval->val[7] = pref & 0xff;
343 }
344
345 static inline void encode_esi_label_extcomm(struct ecommunity_val *eval,
346 bool single_active)
347 {
348 memset(eval, 0, sizeof(struct ecommunity_val));
349 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
350 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL;
351 if (single_active)
352 eval->val[2] |= (1 << 0);
353 }
354
355 static inline void encode_rmac_extcomm(struct ecommunity_val *eval,
356 struct ethaddr *rmac)
357 {
358 memset(eval, 0, sizeof(*eval));
359 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
360 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
361 memcpy(&eval->val[2], rmac, ETH_ALEN);
362 }
363
364 static inline void encode_default_gw_extcomm(struct ecommunity_val *eval)
365 {
366 memset(eval, 0, sizeof(*eval));
367 eval->val[0] = ECOMMUNITY_ENCODE_OPAQUE;
368 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_DEF_GW;
369 }
370
371 static inline void encode_mac_mobility_extcomm(int static_mac, uint32_t seq,
372 struct ecommunity_val *eval)
373 {
374 memset(eval, 0, sizeof(*eval));
375 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
376 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY;
377 if (static_mac)
378 eval->val[2] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY;
379 eval->val[4] = (seq >> 24) & 0xff;
380 eval->val[5] = (seq >> 16) & 0xff;
381 eval->val[6] = (seq >> 8) & 0xff;
382 eval->val[7] = seq & 0xff;
383 }
384
385 static inline void encode_na_flag_extcomm(struct ecommunity_val *eval,
386 uint8_t na_flag, bool proxy)
387 {
388 memset(eval, 0, sizeof(*eval));
389 eval->val[0] = ECOMMUNITY_ENCODE_EVPN;
390 eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_ND;
391 if (na_flag)
392 eval->val[2] |= ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG;
393 if (proxy)
394 eval->val[2] |= ECOMMUNITY_EVPN_SUBTYPE_PROXY_FLAG;
395 }
396
397 static inline void ip_prefix_from_type5_prefix(const struct prefix_evpn *evp,
398 struct prefix *ip)
399 {
400 memset(ip, 0, sizeof(struct prefix));
401 if (is_evpn_prefix_ipaddr_v4(evp)) {
402 ip->family = AF_INET;
403 ip->prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
404 memcpy(&(ip->u.prefix4), &(evp->prefix.prefix_addr.ip.ip),
405 IPV4_MAX_BYTELEN);
406 } else if (is_evpn_prefix_ipaddr_v6(evp)) {
407 ip->family = AF_INET6;
408 ip->prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
409 memcpy(&(ip->u.prefix6), &(evp->prefix.prefix_addr.ip.ip),
410 IPV6_MAX_BYTELEN);
411 }
412 }
413
414 static inline int is_evpn_prefix_default(const struct prefix *evp)
415 {
416 if (evp->family != AF_EVPN)
417 return 0;
418
419 return ((evp->u.prefix_evpn.prefix_addr.ip_prefix_length == 0) ?
420 1 : 0);
421 }
422
423 static inline void ip_prefix_from_type2_prefix(const struct prefix_evpn *evp,
424 struct prefix *ip)
425 {
426 memset(ip, 0, sizeof(struct prefix));
427 if (is_evpn_prefix_ipaddr_v4(evp)) {
428 ip->family = AF_INET;
429 ip->prefixlen = IPV4_MAX_BITLEN;
430 memcpy(&(ip->u.prefix4), &(evp->prefix.macip_addr.ip.ip),
431 IPV4_MAX_BYTELEN);
432 } else if (is_evpn_prefix_ipaddr_v6(evp)) {
433 ip->family = AF_INET6;
434 ip->prefixlen = IPV6_MAX_BITLEN;
435 memcpy(&(ip->u.prefix6), &(evp->prefix.macip_addr.ip.ip),
436 IPV6_MAX_BYTELEN);
437 }
438 }
439
440 static inline void ip_prefix_from_evpn_prefix(const struct prefix_evpn *evp,
441 struct prefix *ip)
442 {
443 if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
444 ip_prefix_from_type2_prefix(evp, ip);
445 else if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
446 ip_prefix_from_type5_prefix(evp, ip);
447 }
448
449 static inline void build_evpn_type2_prefix(struct prefix_evpn *p,
450 struct ethaddr *mac,
451 struct ipaddr *ip)
452 {
453 memset(p, 0, sizeof(struct prefix_evpn));
454 p->family = AF_EVPN;
455 p->prefixlen = EVPN_ROUTE_PREFIXLEN;
456 p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE;
457 memcpy(&p->prefix.macip_addr.mac.octet, mac->octet, ETH_ALEN);
458 p->prefix.macip_addr.ip.ipa_type = IPADDR_NONE;
459 if (ip)
460 memcpy(&p->prefix.macip_addr.ip, ip, sizeof(*ip));
461 }
462
463 static inline void
464 build_type5_prefix_from_ip_prefix(struct prefix_evpn *evp,
465 const struct prefix *ip_prefix)
466 {
467 struct ipaddr ip;
468
469 memset(&ip, 0, sizeof(struct ipaddr));
470 if (ip_prefix->family == AF_INET) {
471 ip.ipa_type = IPADDR_V4;
472 memcpy(&ip.ipaddr_v4, &ip_prefix->u.prefix4,
473 sizeof(struct in_addr));
474 } else {
475 ip.ipa_type = IPADDR_V6;
476 memcpy(&ip.ipaddr_v6, &ip_prefix->u.prefix6,
477 sizeof(struct in6_addr));
478 }
479
480 memset(evp, 0, sizeof(struct prefix_evpn));
481 evp->family = AF_EVPN;
482 evp->prefixlen = EVPN_ROUTE_PREFIXLEN;
483 evp->prefix.route_type = BGP_EVPN_IP_PREFIX_ROUTE;
484 evp->prefix.prefix_addr.ip_prefix_length = ip_prefix->prefixlen;
485 evp->prefix.prefix_addr.ip.ipa_type = ip.ipa_type;
486 memcpy(&evp->prefix.prefix_addr.ip, &ip, sizeof(struct ipaddr));
487 }
488
489 static inline void build_evpn_type3_prefix(struct prefix_evpn *p,
490 struct in_addr originator_ip)
491 {
492 memset(p, 0, sizeof(struct prefix_evpn));
493 p->family = AF_EVPN;
494 p->prefixlen = EVPN_ROUTE_PREFIXLEN;
495 p->prefix.route_type = BGP_EVPN_IMET_ROUTE;
496 p->prefix.imet_addr.ip.ipa_type = IPADDR_V4;
497 p->prefix.imet_addr.ip.ipaddr_v4 = originator_ip;
498 }
499
500 static inline void build_evpn_type4_prefix(struct prefix_evpn *p,
501 esi_t *esi,
502 struct in_addr originator_ip)
503 {
504 memset(p, 0, sizeof(struct prefix_evpn));
505 p->family = AF_EVPN;
506 p->prefixlen = EVPN_ROUTE_PREFIXLEN;
507 p->prefix.route_type = BGP_EVPN_ES_ROUTE;
508 p->prefix.es_addr.ip_prefix_length = IPV4_MAX_BITLEN;
509 p->prefix.es_addr.ip.ipa_type = IPADDR_V4;
510 p->prefix.es_addr.ip.ipaddr_v4 = originator_ip;
511 memcpy(&p->prefix.es_addr.esi, esi, sizeof(esi_t));
512 }
513
514 static inline void build_evpn_type1_prefix(struct prefix_evpn *p,
515 uint32_t eth_tag,
516 esi_t *esi,
517 struct in_addr originator_ip)
518 {
519 memset(p, 0, sizeof(struct prefix_evpn));
520 p->family = AF_EVPN;
521 p->prefixlen = EVPN_ROUTE_PREFIXLEN;
522 p->prefix.route_type = BGP_EVPN_AD_ROUTE;
523 p->prefix.ead_addr.eth_tag = eth_tag;
524 p->prefix.ead_addr.ip.ipa_type = IPADDR_V4;
525 p->prefix.ead_addr.ip.ipaddr_v4 = originator_ip;
526 memcpy(&p->prefix.ead_addr.esi, esi, sizeof(esi_t));
527 }
528
529 static inline void evpn_type1_prefix_global_copy(struct prefix_evpn *global_p,
530 const struct prefix_evpn *vni_p)
531 {
532 memcpy(global_p, vni_p, sizeof(*global_p));
533 global_p->prefix.ead_addr.ip.ipa_type = 0;
534 global_p->prefix.ead_addr.ip.ipaddr_v4.s_addr = INADDR_ANY;
535 }
536
537 /* EAD prefix in the global table doesn't include the VTEP-IP so
538 * we need to create a different copy for the VNI
539 */
540 static inline struct prefix_evpn *evpn_type1_prefix_vni_copy(
541 struct prefix_evpn *vni_p,
542 const struct prefix_evpn *global_p,
543 struct in_addr originator_ip)
544 {
545 memcpy(vni_p, global_p, sizeof(*vni_p));
546 vni_p->prefix.ead_addr.ip.ipa_type = IPADDR_V4;
547 vni_p->prefix.ead_addr.ip.ipaddr_v4 = originator_ip;
548
549 return vni_p;
550 }
551
552 static inline int evpn_default_originate_set(struct bgp *bgp, afi_t afi,
553 safi_t safi)
554 {
555 if (afi == AFI_IP &&
556 CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
557 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4))
558 return 1;
559 else if (afi == AFI_IP6 &&
560 CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
561 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6))
562 return 1;
563 return 0;
564 }
565
566 static inline void es_get_system_mac(esi_t *esi,
567 struct ethaddr *mac)
568 {
569 /*
570 * for type-1 and type-3 ESIs,
571 * the system mac starts at val[1]
572 */
573 memcpy(mac, &esi->val[1], ETH_ALEN);
574 }
575
576 static inline bool bgp_evpn_is_svi_macip_enabled(struct bgpevpn *vpn)
577 {
578 struct bgp *bgp_evpn = NULL;
579
580 bgp_evpn = bgp_get_evpn();
581
582 return (bgp_evpn->evpn_info->advertise_svi_macip ||
583 vpn->advertise_svi_macip);
584 }
585
586 static inline bool bgp_evpn_is_path_local(struct bgp *bgp,
587 struct bgp_path_info *pi)
588 {
589 return (pi->peer == bgp->peer_self
590 && pi->type == ZEBRA_ROUTE_BGP
591 && pi->sub_type == BGP_ROUTE_STATIC);
592 }
593
594 extern struct zclient *zclient;
595
596 extern void bgp_evpn_install_uninstall_default_route(struct bgp *bgp_vrf,
597 afi_t afi, safi_t safi,
598 bool add);
599 extern void evpn_rt_delete_auto(struct bgp *, vni_t, struct list *);
600 extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,
601 struct ecommunity *ecomadd);
602 extern void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf,
603 struct ecommunity *ecomdel);
604 extern void bgp_evpn_configure_import_rt_for_vrf(struct bgp *bgp_vrf,
605 struct ecommunity *ecomadd);
606 extern void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
607 struct ecommunity *ecomdel);
608 extern int bgp_evpn_handle_export_rt_change(struct bgp *bgp,
609 struct bgpevpn *vpn);
610 extern void bgp_evpn_handle_autort_change(struct bgp *bgp);
611 extern void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, int withdraw);
612 extern void bgp_evpn_handle_rd_change(struct bgp *bgp, struct bgpevpn *vpn,
613 int withdraw);
614 extern int bgp_evpn_install_routes(struct bgp *bgp, struct bgpevpn *vpn);
615 extern int bgp_evpn_uninstall_routes(struct bgp *bgp, struct bgpevpn *vpn);
616 extern void bgp_evpn_map_vrf_to_its_rts(struct bgp *bgp_vrf);
617 extern void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf);
618 extern void bgp_evpn_map_vni_to_its_rts(struct bgp *bgp, struct bgpevpn *vpn);
619 extern void bgp_evpn_unmap_vni_from_its_rts(struct bgp *bgp,
620 struct bgpevpn *vpn);
621 extern void bgp_evpn_derive_auto_rt_import(struct bgp *bgp,
622 struct bgpevpn *vpn);
623 extern void bgp_evpn_derive_auto_rt_export(struct bgp *bgp,
624 struct bgpevpn *vpn);
625 extern void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn);
626 extern void bgp_evpn_derive_auto_rd_for_vrf(struct bgp *bgp);
627 extern struct bgpevpn *bgp_evpn_lookup_vni(struct bgp *bgp, vni_t vni);
628 extern struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
629 struct in_addr originator_ip,
630 vrf_id_t tenant_vrf_id,
631 struct in_addr mcast_grp,
632 ifindex_t svi_ifindex);
633 extern void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn);
634 extern bool bgp_evpn_lookup_l3vni_l2vni_table(vni_t vni);
635 extern int update_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn);
636 extern void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
637 struct bgp_dest *dest,
638 struct bgp_path_info **pi);
639 int vni_list_cmp(void *p1, void *p2);
640 extern int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
641 struct bgp_dest *dest);
642 extern struct bgp_dest *bgp_global_evpn_node_get(struct bgp_table *table,
643 afi_t afi, safi_t safi,
644 const struct prefix_evpn *evp,
645 struct prefix_rd *prd);
646 extern struct bgp_dest *
647 bgp_global_evpn_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi,
648 const struct prefix_evpn *evp,
649 struct prefix_rd *prd);
650 extern void bgp_evpn_import_route_in_vrfs(struct bgp_path_info *pi, int import);
651 extern void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
652 struct bgpevpn *vpn,
653 struct bgp_node *rn,
654 struct bgp_path_info *local_pi,
655 const char *caller);
656 extern int bgp_evpn_route_entry_install_if_vrf_match(struct bgp *bgp_vrf,
657 struct bgp_path_info *pi,
658 int install);
659 extern void bgp_evpn_import_type2_route(struct bgp_path_info *pi, int import);
660 #endif /* _BGP_EVPN_PRIVATE_H */