]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_evpn_private.h
Merge pull request #2291 from qlyoung/top-cleanup
[mirror_frr.git] / bgpd / bgp_evpn_private.h
index 1eecb9ecf7e47372bc1f7efca12f5ebc24dd4a02..39a08e70364a6bf1b2e1b33096a76883020e8993 100644 (file)
@@ -272,15 +272,15 @@ static inline void ip_prefix_from_type5_prefix(struct prefix_evpn *evp,
                                               struct prefix *ip)
 {
        memset(ip, 0, sizeof(struct prefix));
-       if (IS_EVPN_PREFIX_IPADDR_V4(evp)) {
+       if (is_evpn_prefix_ipaddr_v4(evp)) {
                ip->family = AF_INET;
-               ip->prefixlen = evp->prefix.ip_prefix_length;
-               memcpy(&(ip->u.prefix4), &(evp->prefix.ip.ip),
+               ip->prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
+               memcpy(&(ip->u.prefix4), &(evp->prefix.prefix_addr.ip.ip),
                       IPV4_MAX_BYTELEN);
-       } else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) {
+       } else if (is_evpn_prefix_ipaddr_v6(evp)) {
                ip->family = AF_INET6;
-               ip->prefixlen = evp->prefix.ip_prefix_length;
-               memcpy(&(ip->u.prefix6), &(evp->prefix.ip.ip),
+               ip->prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
+               memcpy(&(ip->u.prefix6), &(evp->prefix.prefix_addr.ip.ip),
                       IPV6_MAX_BYTELEN);
        }
 }
@@ -290,26 +290,36 @@ static inline int is_evpn_prefix_default(struct prefix *evp)
        if (evp->family != AF_EVPN)
                return 0;
 
-       return ((evp->u.prefix_evpn.ip_prefix_length  == 0) ? 1 : 0);
+       return ((evp->u.prefix_evpn.prefix_addr.ip_prefix_length  == 0) ?
+               1 : 0);
 }
 
 static inline void ip_prefix_from_type2_prefix(struct prefix_evpn *evp,
                                               struct prefix *ip)
 {
        memset(ip, 0, sizeof(struct prefix));
-       if (IS_EVPN_PREFIX_IPADDR_V4(evp)) {
+       if (is_evpn_prefix_ipaddr_v4(evp)) {
                ip->family = AF_INET;
                ip->prefixlen = IPV4_MAX_BITLEN;
-               memcpy(&(ip->u.prefix4), &(evp->prefix.ip.ip),
+               memcpy(&(ip->u.prefix4), &(evp->prefix.macip_addr.ip.ip),
                       IPV4_MAX_BYTELEN);
-       } else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) {
+       } else if (is_evpn_prefix_ipaddr_v6(evp)) {
                ip->family = AF_INET6;
                ip->prefixlen = IPV6_MAX_BITLEN;
-               memcpy(&(ip->u.prefix6), &(evp->prefix.ip.ip),
+               memcpy(&(ip->u.prefix6), &(evp->prefix.macip_addr.ip.ip),
                       IPV6_MAX_BYTELEN);
        }
 }
 
+static inline void ip_prefix_from_evpn_prefix(struct prefix_evpn *evp,
+                                             struct prefix *ip)
+{
+       if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
+               ip_prefix_from_type2_prefix(evp, ip);
+       else if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
+               ip_prefix_from_type5_prefix(evp, ip);
+}
+
 static inline void build_evpn_type2_prefix(struct prefix_evpn *p,
                                           struct ethaddr *mac,
                                           struct ipaddr *ip)
@@ -318,10 +328,10 @@ static inline void build_evpn_type2_prefix(struct prefix_evpn *p,
        p->family = AF_EVPN;
        p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN;
        p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE;
-       memcpy(&p->prefix.mac.octet, mac->octet, ETH_ALEN);
-       p->prefix.ip.ipa_type = IPADDR_NONE;
+       memcpy(&p->prefix.macip_addr.mac.octet, mac->octet, ETH_ALEN);
+       p->prefix.macip_addr.ip.ipa_type = IPADDR_NONE;
        if (ip)
-               memcpy(&p->prefix.ip, ip, sizeof(*ip));
+               memcpy(&p->prefix.macip_addr.ip, ip, sizeof(*ip));
 }
 
 static inline void build_type5_prefix_from_ip_prefix(struct prefix_evpn *evp,
@@ -343,10 +353,10 @@ static inline void build_type5_prefix_from_ip_prefix(struct prefix_evpn *evp,
        memset(evp, 0, sizeof(struct prefix_evpn));
        evp->family = AF_EVPN;
        evp->prefixlen = EVPN_TYPE_5_ROUTE_PREFIXLEN;
-       evp->prefix.ip_prefix_length = ip_prefix->prefixlen;
        evp->prefix.route_type = BGP_EVPN_IP_PREFIX_ROUTE;
-       evp->prefix.ip.ipa_type = ip.ipa_type;
-       memcpy(&evp->prefix.ip, &ip, sizeof(struct ipaddr));
+       evp->prefix.prefix_addr.ip_prefix_length = ip_prefix->prefixlen;
+       evp->prefix.prefix_addr.ip.ipa_type = ip.ipa_type;
+       memcpy(&evp->prefix.prefix_addr.ip, &ip, sizeof(struct ipaddr));
 }
 
 static inline void build_evpn_type3_prefix(struct prefix_evpn *p,
@@ -356,8 +366,8 @@ static inline void build_evpn_type3_prefix(struct prefix_evpn *p,
        p->family = AF_EVPN;
        p->prefixlen = EVPN_TYPE_3_ROUTE_PREFIXLEN;
        p->prefix.route_type = BGP_EVPN_IMET_ROUTE;
-       p->prefix.ip.ipa_type = IPADDR_V4;
-       p->prefix.ip.ipaddr_v4 = originator_ip;
+       p->prefix.imet_addr.ip.ipa_type = IPADDR_V4;
+       p->prefix.imet_addr.ip.ipaddr_v4 = originator_ip;
 }
 
 static inline int evpn_default_originate_set(struct bgp *bgp, afi_t afi,
@@ -385,6 +395,7 @@ extern void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
                                                   struct ecommunity *ecomdel);
 extern int bgp_evpn_handle_export_rt_change(struct bgp *bgp,
                                            struct bgpevpn *vpn);
+extern void bgp_evpn_handle_autort_change(struct bgp *bgp);
 extern void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, int withdraw);
 extern void bgp_evpn_handle_rd_change(struct bgp *bgp, struct bgpevpn *vpn,
                                      int withdraw);