summaryrefslogtreecommitdiff
path: root/bgpd/bgp_mpath.c
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2020-03-24 14:38:37 -0700
committervivek <vivek@cumulusnetworks.com>2020-03-30 20:12:31 -0700
commitf7e1c681f4bf4e2cc1486318d24c42c9e5fb6349 (patch)
treea0b38a24651382b6f653fb34803aaa761b86a535 /bgpd/bgp_mpath.c
parent7b651a321e7207ef72597400156fe6c79c9a6da3 (diff)
bgpd: Implement options for link bandwidth handling
Support configurable options to control how link bandwidth is handled by the receiver. The default behavior is to automatically honor the link bandwidths received and use it to perform a weighted ECMP BUT only if all paths in the multipath have associated link bandwidth; if one or more paths do not have link bandwidth, normal ECMP is performed among the multipaths. This behavior is as recommended by https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth. The additional options available are to (a) completely ignore any link bandwidth (i.e., weighted ECMP is effectively disabled), (b) skip paths in the multipath which do not have link bandwidth and perform weighted ECMP among the other paths (if at least some paths have the bandwidth) or (c) use a default weight (value chosen is 1) for the paths which do not have link bandwidth. The command syntax is bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing> Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_mpath.c')
-rw-r--r--bgpd/bgp_mpath.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index a3d40849ce..f66f56cb49 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -419,6 +419,10 @@ static void bgp_path_info_mpath_lb_update(struct bgp_path_info *path, bool set,
return;
}
if (set) {
+ if (cum_bw)
+ SET_FLAG(mpath->mp_flags, BGP_MP_LB_PRESENT);
+ else
+ UNSET_FLAG(mpath->mp_flags, BGP_MP_LB_PRESENT);
if (all_paths_lb)
SET_FLAG(mpath->mp_flags, BGP_MP_LB_ALL);
else
@@ -446,14 +450,24 @@ struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *path)
/*
* bgp_path_info_chkwtd
*
- * Given bestpath bgp_path_info, return if we should attempt to
- * do weighted ECMP or not
+ * Return if we should attempt to do weighted ECMP or not
+ * The path passed in is the bestpath.
*/
-bool bgp_path_info_mpath_chkwtd(struct bgp_path_info *path)
+bool bgp_path_info_mpath_chkwtd(struct bgp *bgp, struct bgp_path_info *path)
{
- if (!path->mpath)
+ /* Check if told to ignore weights or not multipath */
+ if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW || !path->mpath)
return false;
- return (path->mpath->mp_flags & BGP_MP_LB_ALL);
+
+ /* All paths in multipath should have associated weight (bandwidth)
+ * unless told explicitly otherwise.
+ */
+ if (bgp->lb_handling != BGP_LINK_BW_SKIP_MISSING &&
+ bgp->lb_handling != BGP_LINK_BW_DEFWT_4_MISSING)
+ return (path->mpath->mp_flags & BGP_MP_LB_ALL);
+
+ /* At least one path should have bandwidth. */
+ return (path->mpath->mp_flags & BGP_MP_LB_PRESENT);
}
/*