Skip to content

Commit

Permalink
Merge pull request #7681 from chiragshah6/mdev
Browse files Browse the repository at this point in the history
bgpd: fix distance for aggregate route
  • Loading branch information
riw777 committed Dec 7, 2020
2 parents bd32345 + 801bb99 commit 6a68410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions bgpd/bgp_route.c
Expand Up @@ -13702,7 +13702,7 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
afi_t afi, safi_t safi, struct bgp *bgp)
{
struct bgp_dest *dest;
struct prefix q;
struct prefix q = {0};
struct peer *peer;
struct bgp_distance *bdistance;
struct access_list *alist;
Expand All @@ -13716,8 +13716,11 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
if (pinfo->attr->distance)
return pinfo->attr->distance;

/* Check source address. */
if (!sockunion2hostprefix(&peer->su, &q))
/* Check source address.
* Note: for aggregate route, peer can have unspec af type.
*/
if (pinfo->sub_type != BGP_ROUTE_AGGREGATE
&& !sockunion2hostprefix(&peer->su, &q))
return 0;

dest = bgp_node_match(bgp_distance_table[afi][safi], &q);
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_zebra.c
Expand Up @@ -526,10 +526,10 @@ static int zebra_read_route(ZAPI_CALLBACK_ARGS)
inet_ntop(api.prefix.family, &nexthop, buf,
sizeof(buf));
zlog_debug(
"Rx route ADD VRF %u %s[%d] %pFX nexthop %s (type %d if %u) metric %u tag %" ROUTE_TAG_PRI,
"Rx route ADD VRF %u %s[%d] %pFX nexthop %s (type %d if %u) metric %u distance %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
api.instance, &api.prefix, buf, nhtype, ifindex,
api.metric, api.tag);
api.metric, api.distance, api.tag);
} else {
zlog_debug("Rx route DEL VRF %u %s[%d] %pFX", vrf_id,
zebra_route_string(api.type), api.instance,
Expand Down

0 comments on commit 6a68410

Please sign in to comment.