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. */
80 /* Route type 3 field */
81 struct in_addr originator_ip
;
83 /* PIM-SM MDT group for BUM flooding */
84 struct in_addr mcast_grp
;
86 /* Import and Export RTs. */
87 struct list
*import_rtl
;
88 struct list
*export_rtl
;
91 * EVPN route that uses gateway IP overlay index as its nexthop
92 * needs to do a recursive lookup.
93 * A remote MAC/IP entry should be present for the gateway IP.
94 * Maintain a hash of the addresses received via remote MAC/IP routes
95 * for efficient gateway IP recursive lookup in this EVI
97 struct hash
*remote_ip_hash
;
99 /* Route tables for EVPN routes for
101 struct bgp_table
*ip_table
;
102 struct bgp_table
*mac_table
;
104 /* RB tree of ES-EVIs */
105 struct bgp_es_evi_rb_head es_evi_rb_tree
;
107 /* List of local ESs */
108 struct list
*local_es_evi_list
;
113 DECLARE_QOBJ_TYPE(bgpevpn
);
115 /* Mapping of Import RT to VNIs.
116 * The Import RTs of all VNIs are maintained in a hash table with each
117 * RT linking to all VNIs that will import routes matching this RT.
121 struct ecommunity_val rt
;
123 /* List of VNIs importing routes matching this RT. */
127 /* Mapping of Import RT to VRFs.
128 * The Import RTs of all VRFss are maintained in a hash table with each
129 * RT linking to all VRFs that will import routes matching this RT.
131 struct vrf_irt_node
{
133 struct ecommunity_val rt
;
135 /* List of VNIs importing routes matching this RT. */
140 #define RT_TYPE_IMPORT 1
141 #define RT_TYPE_EXPORT 2
142 #define RT_TYPE_BOTH 3
144 #define EVPN_DAD_DEFAULT_TIME 180 /* secs */
145 #define EVPN_DAD_DEFAULT_MAX_MOVES 5 /* default from RFC 7432 */
146 #define EVPN_DAD_DEFAULT_AUTO_RECOVERY_TIME 1800 /* secs */
148 struct bgp_evpn_info
{
149 /* enable disable dup detect */
150 bool dup_addr_detect
;
152 /* Detection time(M) */
154 /* Detection max moves(N) */
155 uint32_t dad_max_moves
;
156 /* Permanent freeze */
159 uint32_t dad_freeze_time
;
161 /* EVPN enable - advertise svi macip routes */
162 int advertise_svi_macip
;
164 /* PIP feature knob */
166 /* PIP IP (sys ip) */
167 struct in_addr pip_ip
;
168 struct in_addr pip_ip_static
;
169 /* PIP MAC (sys MAC) */
170 struct ethaddr pip_rmac
;
171 struct ethaddr pip_rmac_static
;
172 struct ethaddr pip_rmac_zebra
;
176 /* This structure defines an entry in remote_ip_hash */
177 struct evpn_remote_ip
{
179 struct list
*macip_path_list
;
183 * Wrapper struct for l3 RT's
185 struct vrf_route_target
{
186 /* flags based on config to determine how RTs are handled */
188 #define BGP_VRF_RT_AUTO (1 << 0)
189 #define BGP_VRF_RT_WILD (1 << 1)
191 struct ecommunity
*ecom
;
194 static inline int is_vrf_rd_configured(struct bgp
*bgp_vrf
)
196 return (CHECK_FLAG(bgp_vrf
->vrf_flags
, BGP_VRF_RD_CFGD
));
199 static inline int bgp_evpn_vrf_rd_matches_existing(struct bgp
*bgp_vrf
,
200 struct prefix_rd
*prd
)
202 return (memcmp(&bgp_vrf
->vrf_prd
.val
, prd
->val
, ECOMMUNITY_SIZE
) == 0);
205 static inline vni_t
bgpevpn_get_l3vni(struct bgpevpn
*vpn
)
207 return vpn
->bgp_vrf
? vpn
->bgp_vrf
->l3vni
: 0;
210 static inline void bgpevpn_get_rmac(struct bgpevpn
*vpn
, struct ethaddr
*rmac
)
212 memset(rmac
, 0, sizeof(struct ethaddr
));
215 memcpy(rmac
, &vpn
->bgp_vrf
->rmac
, sizeof(struct ethaddr
));
218 static inline struct list
*bgpevpn_get_vrf_export_rtl(struct bgpevpn
*vpn
)
223 return vpn
->bgp_vrf
->vrf_export_rtl
;
226 static inline struct list
*bgpevpn_get_vrf_import_rtl(struct bgpevpn
*vpn
)
231 return vpn
->bgp_vrf
->vrf_import_rtl
;
234 extern void bgp_evpn_es_evi_vrf_ref(struct bgpevpn
*vpn
);
235 extern void bgp_evpn_es_evi_vrf_deref(struct bgpevpn
*vpn
);
237 static inline void bgpevpn_unlink_from_l3vni(struct bgpevpn
*vpn
)
239 /* bail if vpn is not associated to bgp_vrf */
243 UNSET_FLAG(vpn
->flags
, VNI_FLAG_USE_TWO_LABELS
);
244 listnode_delete(vpn
->bgp_vrf
->l2vnis
, vpn
);
246 bgp_evpn_es_evi_vrf_deref(vpn
);
248 /* remove the backpointer to the vrf instance */
249 bgp_unlock(vpn
->bgp_vrf
);
253 static inline void bgpevpn_link_to_l3vni(struct bgpevpn
*vpn
)
255 struct bgp
*bgp_vrf
= NULL
;
257 /* bail if vpn is already associated to vrf */
261 bgp_vrf
= bgp_lookup_by_vrf_id(vpn
->tenant_vrf_id
);
265 /* associate the vpn to the bgp_vrf instance */
266 vpn
->bgp_vrf
= bgp_lock(bgp_vrf
);
267 listnode_add_sort(bgp_vrf
->l2vnis
, vpn
);
270 * If L3VNI is configured,
271 * check if we are advertising two labels for this vpn
273 if (bgp_vrf
->l3vni
&&
274 !CHECK_FLAG(bgp_vrf
->vrf_flags
, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY
))
275 SET_FLAG(vpn
->flags
, VNI_FLAG_USE_TWO_LABELS
);
277 bgp_evpn_es_evi_vrf_ref(vpn
);
280 static inline int is_vni_configured(struct bgpevpn
*vpn
)
282 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_CFGD
));
285 static inline int is_vni_live(struct bgpevpn
*vpn
)
287 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_LIVE
));
290 static inline int is_l3vni_live(struct bgp
*bgp_vrf
)
292 return (bgp_vrf
->l3vni
&& bgp_vrf
->l3vni_svi_ifindex
);
295 static inline int is_rd_configured(struct bgpevpn
*vpn
)
297 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_RD_CFGD
));
300 static inline int bgp_evpn_rd_matches_existing(struct bgpevpn
*vpn
,
301 struct prefix_rd
*prd
)
303 return (memcmp(&vpn
->prd
.val
, prd
->val
, ECOMMUNITY_SIZE
) == 0);
306 static inline int is_import_rt_configured(struct bgpevpn
*vpn
)
308 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_IMPRT_CFGD
));
311 static inline int is_export_rt_configured(struct bgpevpn
*vpn
)
313 return (CHECK_FLAG(vpn
->flags
, VNI_FLAG_EXPRT_CFGD
));
316 static inline void encode_es_rt_extcomm(struct ecommunity_val
*eval
,
319 memset(eval
, 0, sizeof(struct ecommunity_val
));
320 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
321 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT
;
322 memcpy(&eval
->val
[2], mac
, ETH_ALEN
);
325 static inline void encode_df_elect_extcomm(struct ecommunity_val
*eval
,
328 memset(eval
, 0, sizeof(*eval
));
329 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
330 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_DF_ELECTION
;
331 eval
->val
[2] = EVPN_MH_DF_ALG_PREF
;
332 eval
->val
[6] = (pref
>> 8) & 0xff;
333 eval
->val
[7] = pref
& 0xff;
336 static inline void encode_esi_label_extcomm(struct ecommunity_val
*eval
,
339 memset(eval
, 0, sizeof(struct ecommunity_val
));
340 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
341 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL
;
343 eval
->val
[2] |= (1 << 0);
346 static inline void encode_rmac_extcomm(struct ecommunity_val
*eval
,
347 struct ethaddr
*rmac
)
349 memset(eval
, 0, sizeof(*eval
));
350 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
351 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC
;
352 memcpy(&eval
->val
[2], rmac
, ETH_ALEN
);
355 static inline void encode_default_gw_extcomm(struct ecommunity_val
*eval
)
357 memset(eval
, 0, sizeof(*eval
));
358 eval
->val
[0] = ECOMMUNITY_ENCODE_OPAQUE
;
359 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_DEF_GW
;
362 static inline void encode_mac_mobility_extcomm(int static_mac
, uint32_t seq
,
363 struct ecommunity_val
*eval
)
365 memset(eval
, 0, sizeof(*eval
));
366 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
367 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY
;
369 eval
->val
[2] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY
;
370 eval
->val
[4] = (seq
>> 24) & 0xff;
371 eval
->val
[5] = (seq
>> 16) & 0xff;
372 eval
->val
[6] = (seq
>> 8) & 0xff;
373 eval
->val
[7] = seq
& 0xff;
376 static inline void encode_na_flag_extcomm(struct ecommunity_val
*eval
,
377 uint8_t na_flag
, bool proxy
)
379 memset(eval
, 0, sizeof(*eval
));
380 eval
->val
[0] = ECOMMUNITY_ENCODE_EVPN
;
381 eval
->val
[1] = ECOMMUNITY_EVPN_SUBTYPE_ND
;
383 eval
->val
[2] |= ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG
;
385 eval
->val
[2] |= ECOMMUNITY_EVPN_SUBTYPE_PROXY_FLAG
;
388 static inline void ip_prefix_from_type5_prefix(const struct prefix_evpn
*evp
,
391 memset(ip
, 0, sizeof(struct prefix
));
392 if (is_evpn_prefix_ipaddr_v4(evp
)) {
393 ip
->family
= AF_INET
;
394 ip
->prefixlen
= evp
->prefix
.prefix_addr
.ip_prefix_length
;
395 memcpy(&(ip
->u
.prefix4
), &(evp
->prefix
.prefix_addr
.ip
.ip
),
397 } else if (is_evpn_prefix_ipaddr_v6(evp
)) {
398 ip
->family
= AF_INET6
;
399 ip
->prefixlen
= evp
->prefix
.prefix_addr
.ip_prefix_length
;
400 memcpy(&(ip
->u
.prefix6
), &(evp
->prefix
.prefix_addr
.ip
.ip
),
405 static inline int is_evpn_prefix_default(const struct prefix
*evp
)
407 if (evp
->family
!= AF_EVPN
)
410 return ((evp
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
== 0) ?
414 static inline void ip_prefix_from_type2_prefix(const struct prefix_evpn
*evp
,
417 memset(ip
, 0, sizeof(struct prefix
));
418 if (is_evpn_prefix_ipaddr_v4(evp
)) {
419 ip
->family
= AF_INET
;
420 ip
->prefixlen
= IPV4_MAX_BITLEN
;
421 memcpy(&(ip
->u
.prefix4
), &(evp
->prefix
.macip_addr
.ip
.ip
),
423 } else if (is_evpn_prefix_ipaddr_v6(evp
)) {
424 ip
->family
= AF_INET6
;
425 ip
->prefixlen
= IPV6_MAX_BITLEN
;
426 memcpy(&(ip
->u
.prefix6
), &(evp
->prefix
.macip_addr
.ip
.ip
),
431 static inline void ip_prefix_from_evpn_prefix(const struct prefix_evpn
*evp
,
434 if (evp
->prefix
.route_type
== BGP_EVPN_MAC_IP_ROUTE
)
435 ip_prefix_from_type2_prefix(evp
, ip
);
436 else if (evp
->prefix
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
)
437 ip_prefix_from_type5_prefix(evp
, ip
);
440 static inline void build_evpn_type2_prefix(struct prefix_evpn
*p
,
444 memset(p
, 0, sizeof(struct prefix_evpn
));
446 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
447 p
->prefix
.route_type
= BGP_EVPN_MAC_IP_ROUTE
;
448 memcpy(&p
->prefix
.macip_addr
.mac
.octet
, mac
->octet
, ETH_ALEN
);
449 p
->prefix
.macip_addr
.ip
.ipa_type
= IPADDR_NONE
;
450 memcpy(&p
->prefix
.macip_addr
.ip
, ip
, sizeof(*ip
));
454 build_type5_prefix_from_ip_prefix(struct prefix_evpn
*evp
,
455 const struct prefix
*ip_prefix
)
459 memset(&ip
, 0, sizeof(struct ipaddr
));
460 if (ip_prefix
->family
== AF_INET
) {
461 ip
.ipa_type
= IPADDR_V4
;
462 memcpy(&ip
.ipaddr_v4
, &ip_prefix
->u
.prefix4
,
463 sizeof(struct in_addr
));
465 ip
.ipa_type
= IPADDR_V6
;
466 memcpy(&ip
.ipaddr_v6
, &ip_prefix
->u
.prefix6
,
467 sizeof(struct in6_addr
));
470 memset(evp
, 0, sizeof(struct prefix_evpn
));
471 evp
->family
= AF_EVPN
;
472 evp
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
473 evp
->prefix
.route_type
= BGP_EVPN_IP_PREFIX_ROUTE
;
474 evp
->prefix
.prefix_addr
.ip_prefix_length
= ip_prefix
->prefixlen
;
475 evp
->prefix
.prefix_addr
.ip
.ipa_type
= ip
.ipa_type
;
476 memcpy(&evp
->prefix
.prefix_addr
.ip
, &ip
, sizeof(struct ipaddr
));
479 static inline void build_evpn_type3_prefix(struct prefix_evpn
*p
,
480 struct in_addr originator_ip
)
482 memset(p
, 0, sizeof(struct prefix_evpn
));
484 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
485 p
->prefix
.route_type
= BGP_EVPN_IMET_ROUTE
;
486 p
->prefix
.imet_addr
.ip
.ipa_type
= IPADDR_V4
;
487 p
->prefix
.imet_addr
.ip
.ipaddr_v4
= originator_ip
;
490 static inline void build_evpn_type4_prefix(struct prefix_evpn
*p
,
492 struct in_addr originator_ip
)
494 memset(p
, 0, sizeof(struct prefix_evpn
));
496 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
497 p
->prefix
.route_type
= BGP_EVPN_ES_ROUTE
;
498 p
->prefix
.es_addr
.ip_prefix_length
= IPV4_MAX_BITLEN
;
499 p
->prefix
.es_addr
.ip
.ipa_type
= IPADDR_V4
;
500 p
->prefix
.es_addr
.ip
.ipaddr_v4
= originator_ip
;
501 memcpy(&p
->prefix
.es_addr
.esi
, esi
, sizeof(esi_t
));
504 static inline void build_evpn_type1_prefix(struct prefix_evpn
*p
,
507 struct in_addr originator_ip
)
509 memset(p
, 0, sizeof(struct prefix_evpn
));
511 p
->prefixlen
= EVPN_ROUTE_PREFIXLEN
;
512 p
->prefix
.route_type
= BGP_EVPN_AD_ROUTE
;
513 p
->prefix
.ead_addr
.eth_tag
= eth_tag
;
514 p
->prefix
.ead_addr
.ip
.ipa_type
= IPADDR_V4
;
515 p
->prefix
.ead_addr
.ip
.ipaddr_v4
= originator_ip
;
516 memcpy(&p
->prefix
.ead_addr
.esi
, esi
, sizeof(esi_t
));
519 static inline void evpn_type1_prefix_global_copy(struct prefix_evpn
*global_p
,
520 const struct prefix_evpn
*vni_p
)
522 memcpy(global_p
, vni_p
, sizeof(*global_p
));
523 global_p
->prefix
.ead_addr
.ip
.ipa_type
= 0;
524 global_p
->prefix
.ead_addr
.ip
.ipaddr_v4
.s_addr
= INADDR_ANY
;
525 global_p
->prefix
.ead_addr
.frag_id
= 0;
528 /* EAD prefix in the global table doesn't include the VTEP-IP so
529 * we need to create a different copy for the VNI
531 static inline struct prefix_evpn
*
532 evpn_type1_prefix_vni_ip_copy(struct prefix_evpn
*vni_p
,
533 const struct prefix_evpn
*global_p
,
534 struct in_addr originator_ip
)
536 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
537 vni_p
->prefix
.ead_addr
.ip
.ipa_type
= IPADDR_V4
;
538 vni_p
->prefix
.ead_addr
.ip
.ipaddr_v4
= originator_ip
;
543 static inline void evpn_type2_prefix_global_copy(
544 struct prefix_evpn
*global_p
, const struct prefix_evpn
*vni_p
,
545 const struct ethaddr
*mac
, const struct ipaddr
*ip
)
547 memcpy(global_p
, vni_p
, sizeof(*global_p
));
550 global_p
->prefix
.macip_addr
.mac
= *mac
;
553 global_p
->prefix
.macip_addr
.ip
= *ip
;
557 evpn_type2_prefix_vni_ip_copy(struct prefix_evpn
*vni_p
,
558 const struct prefix_evpn
*global_p
)
560 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
561 memset(&vni_p
->prefix
.macip_addr
.mac
, 0, sizeof(struct ethaddr
));
565 evpn_type2_prefix_vni_mac_copy(struct prefix_evpn
*vni_p
,
566 const struct prefix_evpn
*global_p
)
568 memcpy(vni_p
, global_p
, sizeof(*vni_p
));
569 memset(&vni_p
->prefix
.macip_addr
.ip
, 0, sizeof(struct ipaddr
));
572 /* Get MAC of path_info prefix */
573 static inline struct ethaddr
*
574 evpn_type2_path_info_get_mac(const struct bgp_path_info
*local_pi
)
576 assert(local_pi
->extra
);
577 return &local_pi
->extra
->vni_info
.mac
;
580 /* Get IP of path_info prefix */
581 static inline struct ipaddr
*
582 evpn_type2_path_info_get_ip(const struct bgp_path_info
*local_pi
)
584 assert(local_pi
->extra
);
585 return &local_pi
->extra
->vni_info
.ip
;
588 /* Set MAC of path_info prefix */
589 static inline void evpn_type2_path_info_set_mac(struct bgp_path_info
*local_pi
,
590 const struct ethaddr mac
)
592 assert(local_pi
->extra
);
593 local_pi
->extra
->vni_info
.mac
= mac
;
596 /* Set IP of path_info prefix */
597 static inline void evpn_type2_path_info_set_ip(struct bgp_path_info
*local_pi
,
598 const struct ipaddr ip
)
600 assert(local_pi
->extra
);
601 local_pi
->extra
->vni_info
.ip
= ip
;
604 /* Is the IP empty for the RT's dest? */
605 static inline bool is_evpn_type2_dest_ipaddr_none(const struct bgp_dest
*dest
)
607 const struct prefix_evpn
*evp
=
608 (const struct prefix_evpn
*)bgp_dest_get_prefix(dest
);
610 assert(evp
->prefix
.route_type
== BGP_EVPN_MAC_IP_ROUTE
);
611 return is_evpn_prefix_ipaddr_none(evp
);
614 static inline int evpn_default_originate_set(struct bgp
*bgp
, afi_t afi
,
618 CHECK_FLAG(bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
619 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4
))
621 else if (afi
== AFI_IP6
&&
622 CHECK_FLAG(bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
623 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6
))
628 static inline void es_get_system_mac(esi_t
*esi
,
632 * for type-1 and type-3 ESIs,
633 * the system mac starts at val[1]
635 memcpy(mac
, &esi
->val
[1], ETH_ALEN
);
638 static inline bool bgp_evpn_is_svi_macip_enabled(struct bgpevpn
*vpn
)
640 struct bgp
*bgp_evpn
= NULL
;
642 bgp_evpn
= bgp_get_evpn();
644 return (bgp_evpn
->evpn_info
->advertise_svi_macip
||
645 vpn
->advertise_svi_macip
);
648 static inline bool bgp_evpn_is_path_local(struct bgp
*bgp
,
649 struct bgp_path_info
*pi
)
651 return (pi
->peer
== bgp
->peer_self
652 && pi
->type
== ZEBRA_ROUTE_BGP
653 && pi
->sub_type
== BGP_ROUTE_STATIC
);
656 extern struct zclient
*zclient
;
658 extern void bgp_evpn_install_uninstall_default_route(struct bgp
*bgp_vrf
,
659 afi_t afi
, safi_t safi
,
661 extern void evpn_rt_delete_auto(struct bgp
*bgp
, vni_t vni
, struct list
*rtl
,
663 extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp
*bgp_vrf
,
664 struct ecommunity
*ecomadd
);
665 extern void bgp_evpn_configure_export_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
666 extern void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp
*bgp_vrf
,
667 struct ecommunity
*ecomdel
);
668 extern void bgp_evpn_unconfigure_export_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
669 extern void bgp_evpn_configure_import_rt_for_vrf(struct bgp
*bgp_vrf
,
670 struct ecommunity
*ecomadd
,
672 extern void bgp_evpn_configure_import_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
673 extern void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp
*bgp_vrf
,
674 struct ecommunity
*ecomdel
);
675 extern void bgp_evpn_unconfigure_import_auto_rt_for_vrf(struct bgp
*bgp_vrf
);
676 extern int bgp_evpn_handle_export_rt_change(struct bgp
*bgp
,
677 struct bgpevpn
*vpn
);
678 extern void bgp_evpn_handle_autort_change(struct bgp
*bgp
);
679 extern void bgp_evpn_handle_vrf_rd_change(struct bgp
*bgp_vrf
, int withdraw
);
680 extern void bgp_evpn_handle_rd_change(struct bgp
*bgp
, struct bgpevpn
*vpn
,
682 extern int bgp_evpn_install_routes(struct bgp
*bgp
, struct bgpevpn
*vpn
);
683 extern int bgp_evpn_uninstall_routes(struct bgp
*bgp
, struct bgpevpn
*vpn
);
684 extern void bgp_evpn_map_vrf_to_its_rts(struct bgp
*bgp_vrf
);
685 extern void bgp_evpn_unmap_vrf_from_its_rts(struct bgp
*bgp_vrf
);
686 extern void bgp_evpn_map_vni_to_its_rts(struct bgp
*bgp
, struct bgpevpn
*vpn
);
687 extern void bgp_evpn_unmap_vni_from_its_rts(struct bgp
*bgp
,
688 struct bgpevpn
*vpn
);
689 extern void bgp_evpn_derive_auto_rt_import(struct bgp
*bgp
,
690 struct bgpevpn
*vpn
);
691 extern void bgp_evpn_derive_auto_rt_export(struct bgp
*bgp
,
692 struct bgpevpn
*vpn
);
693 extern void bgp_evpn_derive_auto_rd(struct bgp
*bgp
, struct bgpevpn
*vpn
);
694 extern void bgp_evpn_derive_auto_rd_for_vrf(struct bgp
*bgp
);
695 extern struct bgpevpn
*bgp_evpn_lookup_vni(struct bgp
*bgp
, vni_t vni
);
696 extern struct bgpevpn
*bgp_evpn_new(struct bgp
*bgp
, vni_t vni
,
697 struct in_addr originator_ip
,
698 vrf_id_t tenant_vrf_id
,
699 struct in_addr mcast_grp
,
700 ifindex_t svi_ifindex
);
701 extern void bgp_evpn_free(struct bgp
*bgp
, struct bgpevpn
*vpn
);
702 extern bool bgp_evpn_lookup_l3vni_l2vni_table(vni_t vni
);
703 extern int update_routes_for_vni(struct bgp
*bgp
, struct bgpevpn
*vpn
);
704 extern void delete_evpn_route_entry(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
705 struct bgp_dest
*dest
,
706 struct bgp_path_info
**pi
);
707 int vni_list_cmp(void *p1
, void *p2
);
708 extern int evpn_route_select_install(struct bgp
*bgp
, struct bgpevpn
*vpn
,
709 struct bgp_dest
*dest
);
710 extern struct bgp_dest
*
711 bgp_evpn_global_node_get(struct bgp_table
*table
, afi_t afi
, safi_t safi
,
712 const struct prefix_evpn
*evp
, struct prefix_rd
*prd
,
713 const struct bgp_path_info
*local_pi
);
714 extern struct bgp_dest
*
715 bgp_evpn_global_node_lookup(struct bgp_table
*table
, afi_t afi
, safi_t safi
,
716 const struct prefix_evpn
*evp
,
717 struct prefix_rd
*prd
,
718 const struct bgp_path_info
*local_pi
);
719 extern struct bgp_dest
*
720 bgp_evpn_vni_ip_node_get(struct bgp_table
*const table
,
721 const struct prefix_evpn
*evp
,
722 const struct bgp_path_info
*parent_pi
);
723 extern struct bgp_dest
*
724 bgp_evpn_vni_ip_node_lookup(const struct bgp_table
*const table
,
725 const struct prefix_evpn
*evp
,
726 const struct bgp_path_info
*parent_pi
);
727 extern struct bgp_dest
*
728 bgp_evpn_vni_mac_node_get(struct bgp_table
*const table
,
729 const struct prefix_evpn
*evp
,
730 const struct bgp_path_info
*parent_pi
);
731 extern struct bgp_dest
*
732 bgp_evpn_vni_mac_node_lookup(const struct bgp_table
*const table
,
733 const struct prefix_evpn
*evp
,
734 const struct bgp_path_info
*parent_pi
);
735 extern struct bgp_dest
*
736 bgp_evpn_vni_node_get(struct bgpevpn
*vpn
, const struct prefix_evpn
*p
,
737 const struct bgp_path_info
*parent_pi
);
738 extern struct bgp_dest
*
739 bgp_evpn_vni_node_lookup(const struct bgpevpn
*vpn
, const struct prefix_evpn
*p
,
740 const struct bgp_path_info
*parent_pi
);
742 extern void bgp_evpn_import_route_in_vrfs(struct bgp_path_info
*pi
, int import
);
743 extern void bgp_evpn_update_type2_route_entry(struct bgp
*bgp
,
746 struct bgp_path_info
*local_pi
,
748 extern int bgp_evpn_route_entry_install_if_vrf_match(struct bgp
*bgp_vrf
,
749 struct bgp_path_info
*pi
,
751 extern void bgp_evpn_import_type2_route(struct bgp_path_info
*pi
, int import
);
752 extern void bgp_evpn_xxport_delete_ecomm(void *val
);
753 extern int bgp_evpn_route_target_cmp(struct ecommunity
*ecom1
,
754 struct ecommunity
*ecom2
);
755 #endif /* _BGP_EVPN_PRIVATE_H */