Browse Source

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>
Daniel Walton 4 years ago
parent
commit
78243040fc
2 changed files with 6 additions and 2 deletions
  1. 5 1
      bgpd/bgp_aspath.c
  2. 1 1
      bgpd/bgp_aspath.h

+ 5 - 1
bgpd/bgp_aspath.c

@@ -427,7 +427,7 @@ aspath_count_confeds (struct aspath *aspath)
 }
 
 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 @@ aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2)
   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)))

+ 1 - 1
bgpd/bgp_aspath.h

@@ -103,7 +103,7 @@ extern int aspath_firstas_check (struct aspath *, as_t);
 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 *);