summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_nht.c
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2022-02-14 14:18:10 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2022-12-15 17:09:35 +0100
commitac2f64d3ec2fe63d3d1ba13f5c297cd70aed4364 (patch)
tree03dd6134f459f8b1d110d5f15d5861b432396e66 /bgpd/bgp_nht.c
parentMerge pull request #12447 from karlquan/master (diff)
downloadfrr-ac2f64d3ec2fe63d3d1ba13f5c297cd70aed4364.tar.xz
frr-ac2f64d3ec2fe63d3d1ba13f5c297cd70aed4364.zip
bgpd: fix the IGP metric for best path selection on VPN import
Since the commit da0c0ef70c ("bgpd: VRF-Lite fix best path selection"), the best path selection is made from the comparison of the attributes of the original route i.e. the ultimate path. The IGP metric is currently set on the child path instead of the ultimate path (i.e. the parent path). On eBGP, the ultimate path is the child path. However, for imported routes, the ultimate path is always set to 0, which results in skipping the IGP metric comparison when selecting the best path. Set the IGP metric on the ultimate path when a BGP nexthop is added or updated. Fixes: da0c0ef70c ("bgpd: VRF-Lite fix best path selection") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'bgpd/bgp_nht.c')
-rw-r--r--bgpd/bgp_nht.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index e387cdd48..cf8ff524e 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -294,6 +294,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
{
struct bgp_nexthop_cache_head *tree = NULL;
struct bgp_nexthop_cache *bnc;
+ struct bgp_path_info *bpi_ultimate;
struct prefix p;
uint32_t srte_color = 0;
int is_bgp_static_route = 0;
@@ -450,10 +451,12 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
/* updates NHT pi list reference */
path_nh_map(pi, bnc, true);
+ bpi_ultimate = bgp_get_imported_bpi_ultimate(pi);
if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric)
- (bgp_path_info_extra_get(pi))->igpmetric = bnc->metric;
- else if (pi->extra)
- pi->extra->igpmetric = 0;
+ (bgp_path_info_extra_get(bpi_ultimate))->igpmetric =
+ bnc->metric;
+ else if (bpi_ultimate->extra)
+ bpi_ultimate->extra->igpmetric = 0;
} else if (peer) {
/*
* Let's not accidentally save the peer data for a peer
@@ -1123,6 +1126,7 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
{
struct bgp_dest *dest;
struct bgp_path_info *path;
+ struct bgp_path_info *bpi_ultimate;
int afi;
struct peer *peer = (struct peer *)bnc->nht_info;
struct bgp_table *table;
@@ -1222,11 +1226,12 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
/* Copy the metric to the path. Will be used for bestpath
* computation */
+ bpi_ultimate = bgp_get_imported_bpi_ultimate(path);
if (bgp_isvalid_nexthop(bnc) && bnc->metric)
- (bgp_path_info_extra_get(path))->igpmetric =
+ (bgp_path_info_extra_get(bpi_ultimate))->igpmetric =
bnc->metric;
- else if (path->extra)
- path->extra->igpmetric = 0;
+ else if (bpi_ultimate->extra)
+ bpi_ultimate->extra->igpmetric = 0;
if (CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_METRIC_CHANGED)
|| CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED)