4-byte AS bug on JunOS

Daryl Collins daryl at htb.com.au
Sun May 12 01:57:05 UTC 2013


Hi,

RtConfig has been generating output like:

   replace: as-path as-path-54 "(0-4801|4803-65535)*";

Which is obviously blocking 4-byte AS's from being accepted.  I found that
the underlying issue was addressed by a patch written by Timo Koehler back
in 2010 which can be found here:
http://marc.info/?l=irrtoolset&m=127722423511925

I've pulled the parts of that patch required and created a patch to 5.0.0
which fixes it for us.

Note that whilst the patch isn't JunOS specific, because of the way IOS and
IOS-XR logic/output is done, they don't suffer from the issue.

Daryl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/irrtoolset/attachments/20130512/8253b141/attachment.html>
-------------- next part --------------
diff -ur src/re2dfa/re2dfa.h.orig src/re2dfa/re2dfa.h
--- src/re2dfa/re2dfa.h.orig	2010-03-20 08:49:41.000000000 +1030
+++ src/re2dfa/re2dfa.h	2013-05-11 19:33:10.000000000 +0930
@@ -48,7 +48,7 @@
 
 #include "config.h"
 
-#define MAX_AS 65535
+#define MAX_AS ~(unsigned int)0-1
 
 /*
  * The following is a compile time limit on the number of NFA states diff -ur src/re2dfa/regexp_nf.cc.orig src/re2dfa/regexp_nf.cc
--- src/re2dfa/regexp_nf.cc.orig	2010-03-20 08:49:41.000000000 +1030
+++ src/re2dfa/regexp_nf.cc	2013-05-11 19:34:45.000000000 +0930
@@ -135,7 +135,7 @@
    
 ////////////////////////////// re2nfa ////////////////////
 
-rd_fm *regexp_nf::do_tildaplus_as(rd_fm *result, int as, bool star) const {
+rd_fm *regexp_nf::do_tildaplus_as(rd_fm *result, ASt as, bool star) 
+const {
    rd_dq *rdr = rd_alloc_range_list_empty();
    rd_insert_range(rdr, rd_alloc_range(as, as));
    rd_fm* m;
@@ -154,15 +154,15 @@
 
 rd_fm *regexp_nf::do_tildaplus(regexp_symbol *sym, ASt peerAS, bool star) const {
    RangeList::Range *r;
-   int i;
+   ASt as;
    assert(!sym->complemented);
       
    rd_fm *result = NULL;
    for (r = sym->asnumbers.ranges.head(); 
 	r; 
 	r = sym->asnumbers.ranges.next(r))
-      for (i = r->low; i <= r->high; ++i)
-	 result = do_tildaplus_as(result, i, star);
+      for (as = r->low; as <= r->high; ++as)
+	 result = do_tildaplus_as(result, as, star);
 
    for (Pix p = sym->asSets.first(); 
 	p;
@@ -179,7 +179,7 @@
       
 	 if (as_set) {
 	    for (Pix pi = as_set->first(); pi; as_set->next(pi)) {
-	       int as1 = (*as_set)(pi);
+	       ASt as1 = (*as_set)(pi);
 	       result = do_tildaplus_as(result, as1, star);
 	       if (expand_as_macros)
 		  sym->asnumbers.add(as1, as1);
@@ -264,7 +264,7 @@
       
 	    if (as_set) {
 	       for (Pix pi = as_set->first(); pi; as_set->next(pi)) {
-		  int as1 = (*as_set)(pi);
+		  ASt as1 = (*as_set)(pi);
 		  rd_insert_range(rdr, rd_alloc_range(as1, as1));
 		  if (expand_as_macros)
 		     (((regexp_symbol *) re)->asnumbers).add(as1, as1); diff -ur src/re2dfa/regexp_nf.hh.orig src/re2dfa/regexp_nf.hh
--- src/re2dfa/regexp_nf.hh.orig	2013-05-11 19:39:01.000000000 +0930
+++ src/re2dfa/regexp_nf.hh	2013-05-11 19:35:06.000000000 +0930
@@ -167,7 +167,7 @@
    rd_fm* dfa(ASt peerAS = RE_INVALID_AS);
    rd_fm* re2nfa(regexp *re, ASt peerAS) const;
    void do_and_terms(regexp_nf &b);	// destroys b's terms
-   rd_fm *do_tildaplus_as(rd_fm *result, int as, bool star) const;
+   rd_fm *do_tildaplus_as(rd_fm *result, ASt as, bool star) const;
    rd_fm *do_tildaplus(regexp_symbol *sym, ASt peerAS, bool star) const;  };
 
diff -ur src/rpsl/rangelist.hh.orig src/rpsl/rangelist.hh
--- src/rpsl/rangelist.hh.orig	2013-05-11 19:39:01.000000000 +0930
+++ src/rpsl/rangelist.hh	2013-05-11 19:36:37.000000000 +0930
@@ -52,7 +52,7 @@
 #include <iostream>
 #include "List.hh"
 
-#define RANGE_TOP 65535
+#define RANGE_TOP ~(unsigned int)0
 
 class RangeList {
 friend class regexp_nf;
@@ -70,7 +70,7 @@
       
       Range()               {}
       Range(const Range& r) : low(r.low), high(r.high) {}
-      Range(int l, int h)   : low(l),     high(h)      {}
+      Range(unsigned int l, unsigned int h)   : low(l),     high(h)      {}
 
       bool operator==(const Range &b) const {
 	 return low == b.low && high == b.high; @@ -84,10 +84,10 @@
    List<Range> ranges;
 
 public:
-   RangeList(int low) {
+   RangeList(unsigned int low) {
       ranges.prepend(new Range(low, low));
    }
-   RangeList(int low, int high) {
+   RangeList(unsigned int low, unsigned int high) {
       ranges.prepend(new Range(low, high));
    }
    RangeList(const RangeList& n) {
@@ -107,12 +107,12 @@
       return *this;
    }   
 
-   void add(int low) {
+   void add(unsigned int low) {
       add(low, low);
    }
-   void add(int low, int high) {
+   void add(unsigned int low, unsigned int high) {
       if (low > high) {
-	 int tmp = low;
+	 unsigned int tmp = low;
 	 low = high;
 	 high = tmp;
       }
diff -ur src/rpsl/regexp.cc.orig src/rpsl/regexp.cc
--- src/rpsl/regexp.cc.orig	2010-03-20 08:49:41.000000000 +1030
+++ src/rpsl/regexp.cc	2013-05-11 19:37:03.000000000 +0930
@@ -55,8 +55,8 @@
 using namespace std;
 
 // Static members
-int regexp_symbol::MIN_AS = 0;
-int regexp_symbol::MAX_AS = RANGE_TOP;
+ASt regexp_symbol::MIN_AS = 0;
+ASt regexp_symbol::MAX_AS = RANGE_TOP;
 
 ////////////////////////////// output ////////////////////
 
diff -ur src/rpsl/regexp.hh.orig src/rpsl/regexp.hh
--- src/rpsl/regexp.hh.orig	2013-05-11 19:39:01.000000000 +0930
+++ src/rpsl/regexp.hh	2013-05-11 19:37:52.000000000 +0930
@@ -143,8 +143,8 @@
 REGEXP_FRIENDS
 friend std::ostream& operator<<(std::ostream& os, regexp_symbol& r);
 public:
-   static int MIN_AS;
-   static int MAX_AS;
+   static ASt MIN_AS;
+   static ASt MAX_AS;
 
 private:
    RangeList asnumbers;
@@ -158,11 +158,11 @@
    // ~regexp_symbol() {   } // compiler is OK
    // regexp_symbol(const regexp_symbol& s) {assert(0);} // compiler is OK
 
-   regexp_symbol(int as1) {
+   regexp_symbol(unsigned int as1) {
       complemented = 0;
       asnumbers.add(as1, as1);
    }
-   regexp_symbol(int as1, int as2) {
+   regexp_symbol(unsigned int as1, unsigned int as2) {
       complemented = 0;
       asnumbers.add(as1, as2);
    }
@@ -171,10 +171,10 @@
       asSets.add(asset);
    }
 
-   void add(int as1) {
+   void add(unsigned int as1) {
       asnumbers.add(as1, as1);
    }
-   void add(int as1, int as2) {
+   void add(unsigned int as1, unsigned int as2) {
       asnumbers.add(as1, as2);
    }
    void add(SymID asset) {


More information about the irrtoolset mailing list