summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_mpath.c
diff options
context:
space:
mode:
authorDaniel Walton <dwalton@cumulusnetworks.com>2018-02-26 23:13:22 +0100
committerDaniel Walton <dwalton@cumulusnetworks.com>2018-02-26 23:13:22 +0100
commit194a4f2c5c7f1fd1ea93e97d71bb841ac08947a4 (patch)
tree77d17f24a9f18687b82fce88f471ccad5f61ea1a /bgpd/bgp_mpath.c
parentMerge pull request #1793 from qlyoung/stylechecker (diff)
downloadfrr-194a4f2c5c7f1fd1ea93e97d71bb841ac08947a4.tar.xz
frr-194a4f2c5c7f1fd1ea93e97d71bb841ac08947a4.zip
bgpd: use peer->ifp->ifindex instead of peer->ifindex
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> peer->ifindex was only used in two places but it was never populated so neither of them worked as they should. 'struct peer' also has a 'struct interface' pointer which we can use to get the ifindex.
Diffstat (limited to 'bgpd/bgp_mpath.c')
-rw-r--r--bgpd/bgp_mpath.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 9d32c4bee..5d83192a3 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -93,6 +93,26 @@ int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi,
}
/*
+ * bgp_interface_same
+ *
+ * Return true if ifindex for ifp1 and ifp2 are the same, else return false.
+ */
+static int bgp_interface_same(struct interface *ifp1, struct interface *ifp2)
+{
+ if (!ifp1 && !ifp2)
+ return 1;
+
+ if (!ifp1 && ifp2)
+ return 0;
+
+ if (ifp1 && !ifp2)
+ return 0;
+
+ return (ifp1->ifindex == ifp2->ifindex);
+}
+
+
+/*
* bgp_info_nexthop_cmp
*
* Compare the nexthops of two paths. Return value is less than, equal to,
@@ -130,7 +150,8 @@ int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)
if (!bi1->attr->mp_nexthop_prefer_global &&
!bi2->attr->mp_nexthop_prefer_global)
- compare = !(bi1->peer->ifindex == bi2->peer->ifindex);
+ compare = !bgp_interface_same(bi1->peer->ifp, bi2->peer->ifp);
+
if (!compare)
compare = IPV6_ADDR_CMP(&addr1, &addr2);
break;