1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP EVPN internal definitions
3 * Copyright (C) 2017 Cumulus Networks, Inc.
6 #ifndef _BGP_EVPN_PRIVATE_H
7 #define _BGP_EVPN_PRIVATE_H
12 #include "bgpd/bgpd.h"
13 #include "bgpd/bgp_ecommunity.h"
15 #define RT_ADDRSTRLEN 28
17 /* EVPN prefix lengths. This represents the sizeof struct evpn_addr
19 #define EVPN_ROUTE_PREFIXLEN (sizeof(struct evpn_addr) * 8)
21 /* EVPN route RD buffer length */
22 #define BGP_EVPN_PREFIX_RD_LEN 100
24 /* packet sizes for EVPN routes */
25 /* Type-1 route should be 25 bytes
26 * RD (8), ESI (10), eth-tag (4), vni (3)
28 #define BGP_EVPN_TYPE1_PSIZE 25
29 /* Type-4 route should be either 23 or 35 bytes
30 * RD (8), ESI (10), ip-len (1), ip (4 or 16)
32 #define BGP_EVPN_TYPE4_V4_PSIZE 23
33 #define BGP_EVPN_TYPE4_V6_PSIZE 34
35 RB_HEAD(bgp_es_evi_rb_head
, bgp_evpn_es_evi
);
36 RB_PROTOTYPE(bgp_es_evi_rb_head
, bgp_evpn_es_evi
, rb_node
,
39 * Hash table of EVIs. Right now, the only type of EVI supported is with
40 * VxLAN encapsulation, hence each EVI corresponds to a L2 VNI.
41 * The VNIs are not "created" through BGP but through some other interface
42 * on the system. This table stores VNIs that BGP comes to know as present
43 * on the system (through interaction with zebra) as well as pre-configured
44 * VNIs (which need to be defined in the system to become "live").
48 vrf_id_t tenant_vrf_id
;
49 ifindex_t svi_ifindex
;
51 #define VNI_FLAG_CFGD 0x1 /* VNI is user configured */
52 #define VNI_FLAG_LIVE 0x2 /* VNI is "live" */
53 #define VNI_FLAG_RD_CFGD 0x4 /* RD is user configured. */
54 #define VNI_FLAG_IMPRT_CFGD 0x8 /* Import RT is user configured */
55 #define VNI_FLAG_EXPRT_CFGD 0x10 /* Export RT is user configured */
56 #define VNI_FLAG_USE_TWO_LABELS 0x20 /* Attach both L2-VNI and L3-VNI if
57 needed for this VPN */
59 struct bgp
*bgp_vrf
; /* back pointer to the vrf instance */
61 /* Flag to indicate if we are
62 * advertising the g/w mac ip for
64 uint8_t advertise_gw_macip
;
66 /* Flag to indicate if we are
67 * advertising subnet for this VNI */
68 uint8_t advertise_subnet
;
70 /* Flag to indicate if we are advertising the svi mac ip for this VNI*/
71 uint8_t advertise_svi_macip
;
73 /* Id for deriving the RD
74 * automatically for this VNI */
77 /* RD for this VNI. */
81 /* Route type 3 field */
82 struct in_addr originator_ip
;
84 /* PIM-SM MDT group for BUM flooding */
85 struct in_addr mcast_grp
;
87 /* Import and Export RTs. */
88 struct list
*import_rtl
;
89 struct list
*export_rtl
;
92 * EVPN route that uses gateway IP overlay index as its nexthop
93 * needs to do a recursive lookup.
94 * A remote MAC/IP entry should be present for the gateway IP.
95 * Maintain a hash of the addresses received via remote MAC/IP routes
96 * for efficient gateway IP recursive lookup in this EVI
98 struct hash
*remote_ip_hash
;
100 /* Route tables for EVPN routes for
102 struct bgp_table
*ip_table
;
103 struct bgp_table
*mac_table
;
105 /* RB tree of ES-EVIs */
106 struct bgp_es_evi_rb_head es_evi_rb_tree
;
108 /* List of local ESs */
109 struct list
*local_es_evi_list
;
114 DECLARE_QOBJ_TYPE(bgpevpn
);
116 /* Mapping of Import RT to VNIs.
117 * The Import RTs of all VNIs are maintained in a hash table with each
118 * RT linking to all VNIs that will import routes matching this RT.
122 struct ecommunity_val rt
;
124 /* List of VNIs importing routes matching this RT. */
128 /* Mapping of Import RT to VRFs.
129 * The Import RTs of all VRFss are maintained in a hash table with each
130 * RT linking to all VRFs that will import routes matching this RT.
132 struct vrf_irt_node
{
134 struct ecommunity_val rt
;
136 /* List of VNIs importing routes matching this RT. */
141 #define RT_TYPE_IMPORT 1
142 #define RT_TYPE_EXPORT 2
143 #define RT_TYPE_BOTH 3
145 #define EVPN_DAD_DEFAULT_TIME 180 /* secs */
146 #define EVPN_DAD_DEFAULT_MAX_MOVES 5 /* default from RFC 7432 */
147 #define EVPN_DAD_DEFAULT_AUTO_RECOVERY_TIME 1800 /* secs */
149 struct bgp_evpn_info
{
150 /* enable disable dup detect */
151 bool dup_addr_detect
;
153 /* Detection time(M) */
155 /* Detection max moves(N) */
156 uint32_t dad_max_moves
;
157 /* Permanent freeze */
160 uint32_t dad_freeze_time
;
162 /* EVPN enable - advertise svi macip routes */
163 int advertise_svi_macip
;
165 /* PIP feature knob */
167 /* PIP IP (sys ip) */
168 struct in_addr pip_ip
;
169 struct in_addr pip_ip_static
;
170 /* PIP MAC (sys MAC) */
171 struct ethaddr pip_rmac
;
172 struct ethaddr pip_rmac_static
;
173 struct ethaddr pip_rmac_zebra
;
177 /* This structure defines an entry in remote_ip_hash */
178 struct evpn_remote_ip
{
180 struct list
*macip_path_list
;
184 * Wrapper struct for l3 RT's
186 struct vrf_route_target
{
187 /* flags based on config to determine how RTs are handled */
189 #define BGP_VRF_RT_AUTO (1 << 0)
190 #define BGP_VRF_RT_WILD (1 << 1)
192 struct ecommunity
*ecom
;
195 static inline int is_vrf_rd_configured(struct bgp
*bgp_vrf
)
197 return (CHECK_FLAG(bgp_vrf
->vrf_flags
, BGP_VRF_RD_CFGD
));
200 static inline int bgp_evpn_vrf_rd_matches_existing(struct bgp
*bgp_vrf
,
201 struct prefix_rd
*prd
)
203 return (memcmp(&bgp_vrf
->vrf_prd
.val
, prd
->val
, ECOMMUNITY_SIZE
) == 0);
206 static inline vni_t
bgpevpn_get_l3vni(struct bgpevpn
*vpn
)
208 return vpn
->bgp_vrf
? vpn
->bgp_vrf
->l3vni
: 0;
211 static inline void bgpevpn_get_rmac(struct bgpevpn
*vpn
, struct ethaddr
*rmac
)
213 memset(rmac
, 0, sizeof(struct ethaddr
));
216 memcpy(rmac
, &vpn
->bgp_vrf
->rmac
, sizeof(struct ethaddr
));
219 static inline struct list
*bgpevpn_get_vrf_export_rtl(struct bgpevpn
*vpn
)
224 return vpn
->bgp_vrf
->vrf_export_rtl
;
227 static inline struct list
*bgpevpn_get_vrf_import_rtl(struct bgpevpn
*vpn
)
232 return vpn
->bgp_vrf
->vrf_import_rtl
;
235 extern void bgp_evpn_es_evi_vrf_ref(struct bgpevpn
*vpn
);
236 extern void bgp_evpn_es_evi_vrf_deref(struct bgpevpn
*vpn
);
238 static inline void bgpevpn_unlink_from_l3vni(struct bgpevpn
*vpn
)
240 /* bail if vpn is not associated to bgp_vrf */
244 UNSET_FLAG(vpn
->flags
, VNI_FLAG_USE_TWO_LABELS
);
245 listnode_delete(vpn
->bgp_vrf
->l2vnis
, vpn
);
247 bgp_evpn_es_evi_vrf_deref(vpn
);
249 /* remove the backpointer to the vrf instance */
250 bgp_unlock(vpn
->bgp_vrf
);
254 static inline void bgpevpn_link_to_l3vni(struct bgpevpn
*vpn
)
256 struct bgp
*bgp_vrf
= NULL
;
258 /* bail if vpn is already associated to vrf */
262 bgp_vrf
= bgp_lookup_by_vrf_id(vpn
->tenant_vrf_id
);
266 /* associate the vpn to the bgp_vrf instance */
267 vpn
->bgp_vrf
= bgp_lock(bgp_vrf
);
268 listnode_add_sort(bgp_vrf
->l2vnis
, vpn
);
271 * If L3VNI is configured,
272 * check if we are advertising two labels for this vpn
274 if (bgp_vrf
->l3vni
&&
275 !CHECK_FLAG(bgp_vrf
->vrf_flags
, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY
))
276 SET_FLAG(vpn
->flags
, VNI_FLAG_USE_TWO_LABELS
);
278 bgp_evpn_es_evi_vrf_ref(vpn
);
281 static inline int is_vni_configured(struct bgpevpn
*vpn
)
283 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_CFGD
));
286 static inline int is_vni_live(struct bgpevpn
*vpn
)
288 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_LIVE
));
291 static inline int is_l3vni_live(struct bgp
*bgp_vrf
)
293 return (bgp_vrf
->l3vni
&& bgp_vrf
->l3vni_svi_ifindex
);
296 static inline int is_rd_configured(struct bgpevpn
*vpn
)
298 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_RD_CFGD
));
301 static inline int bgp_evpn_rd_matches_existing(struct bgpevpn
*vpn
,
302 struct prefix_rd
*prd
)
304 return (memcmp(&vpn
->prd
.val
, prd
->val
, ECOMMUNITY_SIZE
) == 0);
307 static inline int is_import_rt_configured(struct bgpevpn
*vpn
)
309 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_IMPRT_CFGD
));
312 static inline int is_export_rt_configured(struct bgpevpn
*vpn
)
314 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_EXPRT_CFGD
));
317 static inline void encode_es_rt_extcomm(struct ecommunity_val
*eval
,
320 memset(eval
, 0, sizeof(struct ecommunity_val
));
321 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
322 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT
;
323 memcpy(&eval
->val
[2], mac
, ETH_ALEN
);
326 static inline void encode_df_elect_extcomm(struct ecommunity_val
*eval
,
329 memset(eval
, 0, sizeof(*eval
));
330 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
331 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_DF_ELECTION
;
332 eval
->val
[2] = EVPN_MH_DF_ALG_PREF
;
333 eval
->val
[6] = (pref
>> 8) & 0xff;
334 eval
->val
[7] = pref
& 0xff;
337 static inline void encode_esi_label_extcomm(struct ecommunity_val
*eval
,
340 memset(eval
, 0, sizeof(struct ecommunity_val
));
341 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
342 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL
;
344 eval
->val
[2] |= (1 << 0);
347 static inline void encode_rmac_extcomm(struct ecommunity_val
*eval
,
348 struct ethaddr
*rmac
)
350 memset(eval
, 0, sizeof(*eval
));
351 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
352 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC
;
353 memcpy(&eval
->val
[2], rmac
, ETH_ALEN
);
356 static inline void encode_default_gw_extcomm(struct ecommunity_val
*eval
)
358 memset(eval
, 0, sizeof(*eval
));
359 eval
->val
[0] = ECOMMUNITY_ENCODE_OPAQUE
;
360 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_DEF_GW
;
363 static inline void encode_mac_mobility_extcomm(int static_mac
, uint32_t seq
,
364 struct ecommunity_val
*eval
)
366 memset(eval
, 0, sizeof(*eval
));
367 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
368 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY
;
370 eval
->val
[2] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY
;
371 eval
->val
[4] = (seq
>> 24) & 0xff;
372 eval
->val
[5] = (seq
>> 16) & 0xff;
373 eval
->val
[6] = (seq
>> 8) & 0xff;
374 eval
->val
[7] = seq
& 0xff;
377 static inline void encode_na_flag_extcomm(struct ecommunity_val
*eval
,
378 uint8_t na_flag
, bool proxy
)
380 memset(eval
, 0, sizeof(*eval
));
381 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
382 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ND
;
384 eval
->val
[2] |= ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG
;
386 eval
->val
[2] |= ECOMMUNITY_EVPN_SUBTYPE_PROXY_FLAG
;
389 static inline void ip_prefix_from_type5_prefix(const struct prefix_evpn
*evp
,
392 memset(ip
, 0, sizeof(struct prefix
));
393 if (is_evpn_prefix_ipaddr_v4(evp
)) {
394 ip
->family
= AF_INET
;
395 ip
->prefixlen
= evp
->prefix
.prefix_addr
.ip_prefix_length
;
396 memcpy(&(ip
->u
.prefix4
), &(evp
->prefix
.prefix_addr
.ip
.ip
),
398 } else if (is_evpn_prefix_ipaddr_v6(evp
)) {
399 ip
->family
= AF_INET6
;
400 ip
->prefixlen
= evp
->prefix
.prefix_addr
.ip_prefix_length
;
401 memcpy(&(ip
->u
.prefix6
), &(evp
->prefix
.prefix_addr
.ip
.ip
),
406 static inline int is_evpn_prefix_default(const struct prefix
*evp
)
408 if (evp
->family
!= AF_EVPN
)
411 return ((evp
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
== 0) ?
415 static inline void ip_prefix_from_type2_prefix(const struct prefix_evpn
*evp
,
418 memset(ip
, 0, sizeof(struct prefix
));
419 if (is_evpn_prefix_ipaddr_v4(evp
)) {
420 ip
->family
= AF_INET
;
421 ip
->prefixlen
= IPV4_MAX_BITLEN
;
422 memcpy(&(ip
->u
.prefix4
), &(evp
->prefix
.macip_addr
.ip
.ip
),
424 } else if (is_evpn_prefix_ipaddr_v6(evp
)) {
425 ip
->family
= AF_INET6
;
426 ip
->prefixlen
= IPV6_MAX_BITLEN
;
427 memcpy(&(ip
->u
.prefix6
), &(evp
->prefix
.macip_addr
.ip
.ip
),
432 static inline void ip_prefix_from_evpn_prefix(const struct prefix_evpn
*evp
,
435 if (evp
->prefix
.route_type
== BGP_EVPN_MAC_IP_ROUTE
)
436 ip_prefix_from_type2_prefix(evp
, ip
);
437 else if (evp
->prefix
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
)
438 ip_prefix_from_type5_prefix(evp
, ip
);
441 static inline void build_evpn_type2_prefix(struct prefix_evpn
*p
,
445 memset(p
, 0, sizeof(struct prefix_evpn
));
447 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
448 p
->prefix
.route_type
= BGP_EVPN_MAC_IP_ROUTE
;
449 memcpy(&p
->prefix
.macip_addr
.mac
.octet
, mac
->octet
, ETH_ALEN
);
450 p
->prefix
.macip_addr
.ip
.ipa_type
= IPADDR_NONE
;
451 memcpy(&p
->prefix
.macip_addr
.ip
, ip
, sizeof(*ip
));
455 build_type5_prefix_from_ip_prefix(struct prefix_evpn
*evp
,
456 const struct prefix
*ip_prefix
)
460 memset(&ip
, 0, sizeof(struct ipaddr
));
461 if (ip_prefix
->family
== AF_INET
) {
462 ip
.ipa_type
= IPADDR_V4
;
463 memcpy(&ip
.ipaddr_v4
, &ip_prefix
->u
.prefix4
,
464 sizeof(struct in_addr
));
466 ip
.ipa_type
= IPADDR_V6
;
467 memcpy(&ip
.ipaddr_v6
, &ip_prefix
->u
.prefix6
,
468 sizeof(struct in6_addr
));
471 memset(evp
, 0, sizeof(struct prefix_evpn
));
472 evp
->family
= AF_EVPN
;
473 evp
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
474 evp
->prefix
.route_type
= BGP_EVPN_IP_PREFIX_ROUTE
;
475 evp
->prefix
.prefix_addr
.ip_prefix_length
= ip_prefix
->prefixlen
;
476 evp
->prefix
.prefix_addr
.ip
.ipa_type
= ip
.ipa_type
;
477 memcpy(&evp
->prefix
.prefix_addr
.ip
, &ip
, sizeof(struct ipaddr
));
480 static inline void build_evpn_type3_prefix(struct prefix_evpn
*p
,
481 struct in_addr originator_ip
)
483 memset(p
, 0, sizeof(struct prefix_evpn
));
485 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
486 p
->prefix
.route_type
= BGP_EVPN_IMET_ROUTE
;
487 p
->prefix
.imet_addr
.ip
.ipa_type
= IPADDR_V4
;
488 p
->prefix
.imet_addr
.ip
.ipaddr_v4
= originator_ip
;
491 static inline void build_evpn_type4_prefix(struct prefix_evpn
*p
,
493 struct in_addr originator_ip
)
495 memset(p
, 0, sizeof(struct prefix_evpn
));
497 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
498 p
->prefix
.route_type
= BGP_EVPN_ES_ROUTE
;
499 p
->prefix
.es_addr
.ip_prefix_length
= IPV4_MAX_BITLEN
;
500 p
->prefix
.es_addr
.ip
.ipa_type
= IPADDR_V4
;
501 p
->prefix
.es_addr
.ip
.ipaddr_v4
= originator_ip
;
502 memcpy(&p
->prefix
.es_addr
.esi
, esi
, sizeof(esi_t
));
505 static inline void build_evpn_type1_prefix(struct prefix_evpn
*p
,
508 struct in_addr originator_ip
)
510 memset(p
, 0, sizeof(struct prefix_evpn
));
512 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
513 p
->prefix
.route_type
= BGP_EVPN_AD_ROUTE
;
514 p
->prefix
.ead_addr
.eth_tag
= eth_tag
;
515 p
->prefix
.ead_addr
.ip
.ipa_type
= IPADDR_V4
;
516 p
->prefix
.ead_addr
.ip
.ipaddr_v4
= originator_ip
;
517 memcpy(&p
->prefix
.ead_addr
.esi
, esi
, sizeof(esi_t
));
520 static inline void evpn_type1_prefix_global_copy(struct prefix_evpn
*global_p
,
521 const struct prefix_evpn
*vni_p
)
523 memcpy(global_p
, vni_p
, sizeof(*global_p
));
524 global_p
->prefix
.ead_addr
.ip
.ipa_type
= 0;
525 global_p
->prefix
.ead_addr
.ip
.ipaddr_v4
.s_addr
= INADDR_ANY
;
526 global_p
->prefix
.ead_addr
.frag_id
= 0;
529 /* EAD prefix in the global table doesn't include the VTEP-IP so
530 * we need to create a different copy for the VNI
532 static inline struct prefix_evpn
*
533 evpn_type1_prefix_vni_ip_copy(struct prefix_evpn
*vni_p
,
534 const struct prefix_evpn
*global_p
,
535 struct in_addr originator_ip
)
537 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
538 vni_p
->prefix
.ead_addr
.ip
.ipa_type
= IPADDR_V4
;
539 vni_p
->prefix
.ead_addr
.ip
.ipaddr_v4
= originator_ip
;
544 static inline void evpn_type2_prefix_global_copy(
545 struct prefix_evpn
*global_p
, const struct prefix_evpn
*vni_p
,
546 const struct ethaddr
*mac
, const struct ipaddr
*ip
)
548 memcpy(global_p
, vni_p
, sizeof(*global_p
));
551 global_p
->prefix
.macip_addr
.mac
= *mac
;
554 global_p
->prefix
.macip_addr
.ip
= *ip
;
558 evpn_type2_prefix_vni_ip_copy(struct prefix_evpn
*vni_p
,
559 const struct prefix_evpn
*global_p
)
561 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
562 memset(&vni_p
->prefix
.macip_addr
.mac
, 0, sizeof(struct ethaddr
));
566 evpn_type2_prefix_vni_mac_copy(struct prefix_evpn
*vni_p
,
567 const struct prefix_evpn
*global_p
)
569 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
570 memset(&vni_p
->prefix
.macip_addr
.ip
, 0, sizeof(struct ipaddr
));
573 /* Get MAC of path_info prefix */
574 static inline struct ethaddr
*
575 evpn_type2_path_info_get_mac(const struct bgp_path_info
*local_pi
)
577 assert(local_pi
->extra
);
578 return &local_pi
->extra
->vni_info
.mac
;
581 /* Get IP of path_info prefix */
582 static inline struct ipaddr
*
583 evpn_type2_path_info_get_ip(const struct bgp_path_info
*local_pi
)
585 assert(local_pi
->extra
);
586 return &local_pi
->extra
->vni_info
.ip
;
589 /* Set MAC of path_info prefix */
590 static inline void evpn_type2_path_info_set_mac(struct bgp_path_info
*local_pi
,
591 const struct ethaddr mac
)
593 assert(local_pi
->extra
);
594 local_pi
->extra
->vni_info
.mac
= mac
;
597 /* Set IP of path_info prefix */
598 static inline void evpn_type2_path_info_set_ip(struct bgp_path_info
*local_pi
,
599 const struct ipaddr ip
)
601 assert(local_pi
->extra
);
602 local_pi
->extra
->vni_info
.ip
= ip
;
605 /* Is the IP empty for the RT's dest? */
606 static inline bool is_evpn_type2_dest_ipaddr_none(const struct bgp_dest
*dest
)
608 const struct prefix_evpn
*evp
=
609 (const struct prefix_evpn
*)bgp_dest_get_prefix(dest
);
611 assert(evp
->prefix
.route_type
== BGP_EVPN_MAC_IP_ROUTE
);
612 return is_evpn_prefix_ipaddr_none(evp
);
615 static inline int evpn_default_originate_set(struct bgp
*bgp
, afi_t afi
,
619 CHECK_FLAG(bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
620 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4
))
622 else if (afi
== AFI_IP6
&&
623 CHECK_FLAG(bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
624 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6
))
629 static inline void es_get_system_mac(esi_t
*esi
,
633 * for type-1 and type-3 ESIs,
634 * the system mac starts at val[1]
636 memcpy(mac
, &esi
->val
[1], ETH_ALEN
);
639 static inline bool bgp_evpn_is_svi_macip_enabled(struct bgpevpn
*vpn
)
641 struct bgp
*bgp_evpn
= NULL
;
643 bgp_evpn
= bgp_get_evpn();
645 return (bgp_evpn
->evpn_info
->advertise_svi_macip
||
646 vpn
->advertise_svi_macip
);
649 static inline bool bgp_evpn_is_path_local(struct bgp
*bgp
,
650 struct bgp_path_info
*pi
)
652 return (pi
->peer
== bgp
->peer_self
653 && pi
->type
== ZEBRA_ROUTE_BGP
654 && pi
->sub_type
== BGP_ROUTE_STATIC
);
657 extern struct zclient
*zclient
;
659 extern void bgp_evpn_install_uninstall_default_route(struct bgp
*bgp_vrf
,
660 afi_t afi
, safi_t safi
,
662 extern void evpn_rt_delete_auto(struct bgp
*bgp
, vni_t vni
, struct list
*rtl
,
664 extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp
*bgp_vrf
,
665 struct ecommunity
*ecomadd
);
666 extern void bgp_evpn_configure_export_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
667 extern void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp
*bgp_vrf
,
668 struct ecommunity
*ecomdel
);
669 extern void bgp_evpn_unconfigure_export_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
670 extern void bgp_evpn_configure_import_rt_for_vrf(struct bgp
*bgp_vrf
,
671 struct ecommunity
*ecomadd
,
673 extern void bgp_evpn_configure_import_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
674 extern void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp
*bgp_vrf
,
675 struct ecommunity
*ecomdel
);
676 extern void bgp_evpn_unconfigure_import_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
677 extern int bgp_evpn_handle_export_rt_change(struct bgp
*bgp
,
678 struct bgpevpn
*vpn
);
679 extern void bgp_evpn_handle_autort_change(struct bgp
*bgp
);
680 extern void bgp_evpn_handle_vrf_rd_change(struct bgp
*bgp_vrf
, int withdraw
);
681 extern void bgp_evpn_handle_rd_change(struct bgp
*bgp
, struct bgpevpn
*vpn
,
683 extern int bgp_evpn_install_routes(struct bgp
*bgp
, struct bgpevpn
*vpn
);
684 extern int bgp_evpn_uninstall_routes(struct bgp
*bgp
, struct bgpevpn
*vpn
);
685 extern void bgp_evpn_map_vrf_to_its_rts(struct bgp
*bgp_vrf
);
686 extern void bgp_evpn_unmap_vrf_from_its_rts(struct bgp
*bgp_vrf
);
687 extern void bgp_evpn_map_vni_to_its_rts(struct bgp
*bgp
, struct bgpevpn
*vpn
);
688 extern void bgp_evpn_unmap_vni_from_its_rts(struct bgp
*bgp
,
689 struct bgpevpn
*vpn
);
690 extern void bgp_evpn_derive_auto_rt_import(struct bgp
*bgp
,
691 struct bgpevpn
*vpn
);
692 extern void bgp_evpn_derive_auto_rt_export(struct bgp
*bgp
,
693 struct bgpevpn
*vpn
);
694 extern void bgp_evpn_derive_auto_rd(struct bgp
*bgp
, struct bgpevpn
*vpn
);
695 extern void bgp_evpn_derive_auto_rd_for_vrf(struct bgp
*bgp
);
696 extern struct bgpevpn
*bgp_evpn_lookup_vni(struct bgp
*bgp
, vni_t vni
);
697 extern struct bgpevpn
*bgp_evpn_new(struct bgp
*bgp
, vni_t vni
,
698 struct in_addr originator_ip
,
699 vrf_id_t tenant_vrf_id
,
700 struct in_addr mcast_grp
,
701 ifindex_t svi_ifindex
);
702 extern void bgp_evpn_free(struct bgp
*bgp
, struct bgpevpn
*vpn
);
703 extern bool bgp_evpn_lookup_l3vni_l2vni_table(vni_t vni
);
704 extern int update_routes_for_vni(struct bgp
*bgp
, struct bgpevpn
*vpn
);
705 extern void delete_evpn_route_entry(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
706 struct bgp_dest
*dest
,
707 struct bgp_path_info
**pi
);
708 int vni_list_cmp(void *p1
, void *p2
);
709 extern int evpn_route_select_install(struct bgp
*bgp
, struct bgpevpn
*vpn
,
710 struct bgp_dest
*dest
);
711 extern struct bgp_dest
*
712 bgp_evpn_global_node_get(struct bgp_table
*table
, afi_t afi
, safi_t safi
,
713 const struct prefix_evpn
*evp
, struct prefix_rd
*prd
,
714 const struct bgp_path_info
*local_pi
);
715 extern struct bgp_dest
*bgp_evpn_global_node_lookup(
716 struct bgp_table
*table
, safi_t safi
, const struct prefix_evpn
*evp
,
717 struct prefix_rd
*prd
, const struct bgp_path_info
*local_pi
);
718 extern struct bgp_dest
*
719 bgp_evpn_vni_ip_node_get(struct bgp_table
*const table
,
720 const struct prefix_evpn
*evp
,
721 const struct bgp_path_info
*parent_pi
);
722 extern struct bgp_dest
*
723 bgp_evpn_vni_ip_node_lookup(const struct bgp_table
*const table
,
724 const struct prefix_evpn
*evp
,
725 const struct bgp_path_info
*parent_pi
);
726 extern struct bgp_dest
*
727 bgp_evpn_vni_mac_node_get(struct bgp_table
*const table
,
728 const struct prefix_evpn
*evp
,
729 const struct bgp_path_info
*parent_pi
);
730 extern struct bgp_dest
*
731 bgp_evpn_vni_mac_node_lookup(const struct bgp_table
*const table
,
732 const struct prefix_evpn
*evp
,
733 const struct bgp_path_info
*parent_pi
);
734 extern struct bgp_dest
*
735 bgp_evpn_vni_node_get(struct bgpevpn
*vpn
, const struct prefix_evpn
*p
,
736 const struct bgp_path_info
*parent_pi
);
737 extern struct bgp_dest
*
738 bgp_evpn_vni_node_lookup(const struct bgpevpn
*vpn
, const struct prefix_evpn
*p
,
739 const struct bgp_path_info
*parent_pi
);
741 extern void bgp_evpn_import_route_in_vrfs(struct bgp_path_info
*pi
, int import
);
742 extern void bgp_evpn_update_type2_route_entry(struct bgp
*bgp
,
745 struct bgp_path_info
*local_pi
,
747 extern int bgp_evpn_route_entry_install_if_vrf_match(struct bgp
*bgp_vrf
,
748 struct bgp_path_info
*pi
,
750 extern void bgp_evpn_import_type2_route(struct bgp_path_info
*pi
, int import
);
751 extern void bgp_evpn_xxport_delete_ecomm(void *val
);
752 extern int bgp_evpn_route_target_cmp(struct ecommunity
*ecom1
,
753 struct ecommunity
*ecom2
);
754 #endif /* _BGP_EVPN_PRIVATE_H */