From: Daniel Walton <[email protected]>

AS_PATH comparison is broken if CONFED_AS_SEQ are present

Signed-off-by: Daniel Walton <[email protected]>
---
 bgpd/bgp_aspath.c | 6 +++++-
 bgpd/bgp_aspath.h | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 3c8436e..11823e9 100644
--- a/bgpd/bgp_aspath.c
+++ b/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;
@@ -1445,6 +1445,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)))
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index 15b09f5..7cf746c 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -98,7 +98,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 *);
-- 
1.9.1


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to