summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_route.c7
-rw-r--r--tests/topotests/bgp_vpnv4_gre/r1/bgpd.conf1
-rw-r--r--tests/topotests/bgp_vpnv4_gre/r1/ipv4_routes.json2
3 files changed, 9 insertions, 1 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 40f29dac5c..2595bd1d36 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -15012,6 +15012,7 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
struct bgp_distance *bdistance;
struct access_list *alist;
struct bgp_static *bgp_static;
+ struct bgp_path_info *bpi_ultimate;
if (!bgp)
return 0;
@@ -15021,6 +15022,12 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
if (pinfo->attr->distance)
return pinfo->attr->distance;
+ /* get peer origin to calculate appropriate distance */
+ if (pinfo->sub_type == BGP_ROUTE_IMPORTED) {
+ bpi_ultimate = bgp_get_imported_bpi_ultimate(pinfo);
+ peer = bpi_ultimate->peer;
+ }
+
/* Check source address.
* Note: for aggregate route, peer can have unspec af type.
*/
diff --git a/tests/topotests/bgp_vpnv4_gre/r1/bgpd.conf b/tests/topotests/bgp_vpnv4_gre/r1/bgpd.conf
index 0e2d3a8248..295811bfd0 100644
--- a/tests/topotests/bgp_vpnv4_gre/r1/bgpd.conf
+++ b/tests/topotests/bgp_vpnv4_gre/r1/bgpd.conf
@@ -14,6 +14,7 @@ router bgp 65500 vrf vrf1
bgp router-id 192.0.2.1
address-family ipv4 unicast
redistribute connected
+ distance bgp 21 201 41
label vpn export 101
rd vpn export 444:1
rt vpn both 52:100
diff --git a/tests/topotests/bgp_vpnv4_gre/r1/ipv4_routes.json b/tests/topotests/bgp_vpnv4_gre/r1/ipv4_routes.json
index 5f2732aab0..e57e21bb12 100644
--- a/tests/topotests/bgp_vpnv4_gre/r1/ipv4_routes.json
+++ b/tests/topotests/bgp_vpnv4_gre/r1/ipv4_routes.json
@@ -7,7 +7,7 @@
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
- "distance": 20,
+ "distance": 201,
"metric": 0,
"nexthops": [
{