]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Trigger EVPN type-5 injection upon link-bandwidth change
authorvivek <vivek@cumulusnetworks.com>
Thu, 9 Apr 2020 01:46:59 +0000 (18:46 -0700)
committervivek <vivek@cumulusnetworks.com>
Thu, 9 Apr 2020 02:12:09 +0000 (19:12 -0700)
Ensure that upon a link-bandwidth change - for e.g., due to change in
the number of multipaths - EVPN type-5 route injection is triggered.
In the absence of this, the proper link-bandwidth is not updated in
EVPN type-5 routes originated by the router.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
bgpd/bgp_route.c

index a036771dcea06756db6a024c032ceee2dd7caf68..e341ed632bf5ff971535db944b6f62f513d9b428 100644 (file)
@@ -2444,6 +2444,54 @@ struct bgp_process_queue {
        unsigned int queued;
 };
 
+static void bgp_process_evpn_route_injection(struct bgp *bgp, afi_t afi,
+                                            safi_t safi, struct bgp_node *rn,
+                                            struct bgp_path_info *new_select,
+                                            struct bgp_path_info *old_select)
+{
+       const struct prefix *p = bgp_node_get_prefix(rn);
+
+       if ((afi != AFI_IP && afi != AFI_IP6) || (safi != SAFI_UNICAST))
+               return;
+
+       if (advertise_type5_routes(bgp, afi) && new_select
+           && is_route_injectable_into_evpn(new_select)) {
+
+               /* apply the route-map */
+               if (bgp->adv_cmd_rmap[afi][safi].map) {
+                       route_map_result_t ret;
+                       struct bgp_path_info rmap_path;
+                       struct bgp_path_info_extra rmap_path_extra;
+                       struct attr dummy_attr;
+
+                       dummy_attr = *new_select->attr;
+
+                       /* Fill temp path_info */
+                       prep_for_rmap_apply(&rmap_path, &rmap_path_extra, rn,
+                                           new_select, new_select->peer,
+                                           &dummy_attr);
+
+                       RESET_FLAG(dummy_attr.rmap_change_flags);
+
+                       ret = route_map_apply(bgp->adv_cmd_rmap[afi][safi].map,
+                                             p, RMAP_BGP, &rmap_path);
+
+                       if (ret == RMAP_DENYMATCH) {
+                               bgp_attr_flush(&dummy_attr);
+                               bgp_evpn_withdraw_type5_route(bgp, p, afi,
+                                                             safi);
+                       } else
+                               bgp_evpn_advertise_type5_route(
+                                       bgp, p, &dummy_attr, afi, safi);
+               } else {
+                       bgp_evpn_advertise_type5_route(bgp, p, new_select->attr,
+                                                      afi, safi);
+               }
+       } else if (advertise_type5_routes(bgp, afi) && old_select
+                  && is_route_injectable_into_evpn(old_select))
+               bgp_evpn_withdraw_type5_route(bgp, p, afi, safi);
+}
+
 /*
  * old_select = The old best path
  * new_select = the new best path
@@ -2607,6 +2655,12 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
                        UNSET_FLAG(rn->flags, BGP_NODE_LABEL_CHANGED);
                }
 
+               /* advertise/withdraw type-5 routes */
+               if (CHECK_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG)
+                   || CHECK_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG))
+                       bgp_process_evpn_route_injection(
+                               bgp, afi, safi, rn, old_select, old_select);
+
                UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
                UNSET_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG);
                bgp_zebra_clear_route_change_flags(rn);
@@ -2696,53 +2750,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
                }
        }
 
-       /* advertise/withdraw type-5 routes */
-       if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
-               const struct prefix *p = bgp_node_get_prefix(rn);
-
-               if (advertise_type5_routes(bgp, afi) &&
-                   new_select &&
-                   is_route_injectable_into_evpn(new_select)) {
-
-                       /* apply the route-map */
-                       if (bgp->adv_cmd_rmap[afi][safi].map) {
-                               route_map_result_t ret;
-                               struct bgp_path_info rmap_path;
-                               struct bgp_path_info_extra rmap_path_extra;
-                               struct attr dummy_attr;
-
-                               dummy_attr = *new_select->attr;
-
-                               /* Fill temp path_info */
-                               prep_for_rmap_apply(
-                                       &rmap_path, &rmap_path_extra,
-                                       rn, new_select, new_select->peer,
-                                       &dummy_attr);
-
-                               RESET_FLAG(dummy_attr.rmap_change_flags);
-
-                               ret = route_map_apply(
-                                       bgp->adv_cmd_rmap[afi][safi].map,
-                                       p, RMAP_BGP, &rmap_path);
-                               if (ret == RMAP_DENYMATCH) {
-                                       bgp_attr_flush(&dummy_attr);
-                                       bgp_evpn_withdraw_type5_route(
-                                               bgp, p, afi, safi);
-                               } else
-                                       bgp_evpn_advertise_type5_route(
-                                               bgp, p, &dummy_attr,
-                                               afi, safi);
-                       } else {
-                               bgp_evpn_advertise_type5_route(bgp, p,
-                                                              new_select->attr,
-                                                              afi, safi);
-
-                       }
-               } else if (advertise_type5_routes(bgp, afi) &&
-                          old_select &&
-                          is_route_injectable_into_evpn(old_select))
-                       bgp_evpn_withdraw_type5_route(bgp, p, afi, safi);
-       }
+       bgp_process_evpn_route_injection(bgp, afi, safi, rn, new_select,
+                                        old_select);
 
        /* Clear any route change flags. */
        bgp_zebra_clear_route_change_flags(rn);