]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra, bgpd: Use L3 interface for VRF's VNI in route install
authorvivek <vivek@cumulusnetworks.com>
Wed, 27 Feb 2019 12:25:53 +0000 (12:25 +0000)
committervivek <vivek@cumulusnetworks.com>
Wed, 27 Feb 2019 12:25:53 +0000 (12:25 +0000)
In the case of EVPN symmetric routing, the tenant VRF is associated with
a VNI that is used for routing and commonly referred to as the L3 VNI or
VRF VNI. Corresponding to this VNI is a VLAN and its associated L3 (IP)
interface (SVI). Overlay next hops (i.e., next hops for routes in the
tenant VRF) are reachable over this interface.

https://tools.ietf.org/html/draft-ietf-bess-evpn-prefix-advertisement
section 4.4 provides additional description of the above constructs.

Use the L3 interface exchanged between zebra and bgp in route install.
This patch in conjunction with the earlier one helps to eliminate some
special code in zebra to derive the next hop's interface.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_zebra.c
zebra/zapi_msg.c

index d0c170322aebf28ff34e544cf34c2ba00e6384b4..a19821cac069bb1dc9534cba4e910e0f9812bc0c 100644 (file)
@@ -1111,20 +1111,23 @@ int bgp_zebra_get_table_range(uint32_t chunk_size,
 }
 
 static int update_ipv4nh_for_route_install(int nh_othervrf,
+                                          struct bgp *nh_bgp,
                                           struct in_addr *nexthop,
                                           struct attr *attr,
                                           bool is_evpn,
                                           struct zapi_nexthop *api_nh)
 {
        api_nh->gate.ipv4 = *nexthop;
+       api_nh->vrf_id = nh_bgp->vrf_id;
 
        /* Need to set fields appropriately for EVPN routes imported into
         * a VRF (which are programmed as onlink on l3-vni SVI) as well as
         * connected routes leaked into a VRF.
         */
-       if (is_evpn)
+       if (is_evpn) {
                api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
-       else if (nh_othervrf &&
+               api_nh->ifindex = nh_bgp->l3vni_svi_ifindex;
+       } else if (nh_othervrf &&
                 api_nh->gate.ipv4.s_addr == INADDR_ANY) {
                api_nh->type = NEXTHOP_TYPE_IFINDEX;
                api_nh->ifindex = attr->nh_ifindex;
@@ -1135,7 +1138,8 @@ static int update_ipv4nh_for_route_install(int nh_othervrf,
 }
 
 static int
-update_ipv6nh_for_route_install(int nh_othervrf, struct in6_addr *nexthop,
+update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
+                               struct in6_addr *nexthop,
                                ifindex_t ifindex, struct bgp_path_info *pi,
                                struct bgp_path_info *best_pi, bool is_evpn,
                                struct zapi_nexthop *api_nh)
@@ -1143,10 +1147,12 @@ update_ipv6nh_for_route_install(int nh_othervrf, struct in6_addr *nexthop,
        struct attr *attr;
 
        attr = pi->attr;
+       api_nh->vrf_id = nh_bgp->vrf_id;
 
-       if (is_evpn)
+       if (is_evpn) {
                api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
-       else if (nh_othervrf) {
+               api_nh->ifindex = nh_bgp->l3vni_svi_ifindex;
+       } else if (nh_othervrf) {
                if (IN6_IS_ADDR_UNSPECIFIED(nexthop)) {
                        api_nh->type = NEXTHOP_TYPE_IFINDEX;
                        api_nh->ifindex = attr->nh_ifindex;
@@ -1297,8 +1303,6 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
                        continue;
 
                api_nh = &api.nexthops[valid_nh_count];
-               api_nh->vrf_id = nh_othervrf ? info->extra->bgp_orig->vrf_id
-                                            : bgp->vrf_id;
                if (nh_family == AF_INET) {
                        if (bgp_debug_zebra(&api.prefix)) {
                                if (mpinfo->extra) {
@@ -1338,6 +1342,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
 
                        nh_updated = update_ipv4nh_for_route_install(
                                        nh_othervrf,
+                                       nh_othervrf ?
+                                       info->extra->bgp_orig : bgp,
                                        &mpinfo_cp->attr->nexthop,
                                        mpinfo_cp->attr, is_evpn, api_nh);
                } else {
@@ -1372,7 +1378,9 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
                        nexthop = bgp_path_info_to_ipv6_nexthop(mpinfo_cp,
                                                                &ifindex);
                        nh_updated = update_ipv6nh_for_route_install(
-                                       nh_othervrf, nexthop, ifindex,
+                                       nh_othervrf, nh_othervrf ?
+                                       info->extra->bgp_orig : bgp,
+                                       nexthop, ifindex,
                                        mpinfo, info, is_evpn, api_nh);
                }
 
index 9b91289decb20f34c8d4a9005f721c1b75f0f9fc..8b3382dba84ff6bcac1ba8009a515fe17c7017f9 100644 (file)
@@ -1432,12 +1432,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
                case NEXTHOP_TYPE_IPV4_IFINDEX:
 
                        memset(&vtep_ip, 0, sizeof(struct ipaddr));
-                       if (CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) {
-                               ifindex = get_l3vni_svi_ifindex(vrf_id);
-                       } else {
-                               ifindex = api_nh->ifindex;
-                       }
-
+                       ifindex = api_nh->ifindex;
                        if (IS_ZEBRA_DEBUG_RECV) {
                                char nhbuf[INET6_ADDRSTRLEN] = {0};
 
@@ -1473,12 +1468,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
                        break;
                case NEXTHOP_TYPE_IPV6_IFINDEX:
                        memset(&vtep_ip, 0, sizeof(struct ipaddr));
-                       if (CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) {
-                               ifindex = get_l3vni_svi_ifindex(vrf_id);
-                       } else {
-                               ifindex = api_nh->ifindex;
-                       }
-
+                       ifindex = api_nh->ifindex;
                        nexthop = route_entry_nexthop_ipv6_ifindex_add(
                                re, &api_nh->gate.ipv6, ifindex,
                                api_nh->vrf_id);