bgpd: iBGP multipath is broken if 'bgp deterministic-med' is enabled.
AS_PATH comparison is broken if CONFED_AS_SEQ are present.
This patch fixes this issue
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 3fd359c..e5541f6 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -427,7 +427,7 @@
}
unsigned int
-aspath_count_hops (struct aspath *aspath)
+aspath_count_hops (const struct aspath *aspath)
{
int count = 0;
struct assegment *seg = aspath->segments;
@@ -1574,6 +1574,10 @@
seg1 = aspath1->segments;
seg2 = aspath2->segments;
+ /* If both paths are originated in this AS then we do want to compare MED */
+ if (!seg1 && !seg2)
+ return 1;
+
/* find first non-confed segments for each */
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
|| (seg1->type == AS_CONFED_SET)))
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index aa13daa..c8f929f 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -103,7 +103,7 @@
extern int aspath_confed_check (struct aspath *);
extern int aspath_left_confed_check (struct aspath *);
extern unsigned long aspath_count (void);
-extern unsigned int aspath_count_hops (struct aspath *);
+extern unsigned int aspath_count_hops (const struct aspath *);
extern unsigned int aspath_count_confeds (struct aspath *);
extern unsigned int aspath_size (struct aspath *);
extern as_t aspath_highest (struct aspath *);