diff src/routeconfig.cpp @ 2:bb3f804f13a0

add random unsynchronization to hourly timer, trust prefix only for same origin AS, ignore self adjacency
author Carl Byington <carl@five-ten-sg.com>
date Mon, 19 May 2008 21:45:45 -0700
parents 48d06780cf77
children 180d26aa2a17
line wrap: on
line diff
--- a/src/routeconfig.cpp	Tue May 13 15:46:53 2008 -0700
+++ b/src/routeconfig.cpp	Mon May 19 21:45:45 2008 -0700
@@ -66,6 +66,7 @@
     uint32_t prefix() const         { return prefix_value;                         };
     bool active()          const    { return announced;                            };
     adjacent aspair(int i) const    { return adjacent(path[i], path[i+1]);         };
+    bool selfpair(int i)   const    { return (path[1] == path[i+1]);               };
     bool empty()           const    { return !announced && origin_history.empty(); };
     void update_history(a_set &adj_set);
     suspicion suspicious(a_history &adj_history, bool debug = false, int prefix_length = 0, uint32_t ip = 0);
@@ -167,7 +168,9 @@
 void route_prefix::add_route(aspath path_, a_history &adj_history)
 {
     suspicion s = suspicious(adj_history);
-    trusted   = announced && (s == suspicious_none);
+    int oldorig = path.empty()  ? 0 : path [path.size()  - 1];
+    int neworig = path_.empty() ? 0 : path_[path_.size() - 1];
+    trusted   = announced && (s == suspicious_none) && (oldorig == neworig);
     announced = true;
     path      = path_;
 }
@@ -226,7 +229,7 @@
         }
         // update current adjacency set
         for (int k=0; k<n; k++) {
-            adj_set.insert(aspair(k));
+            if (!selfpair(k)) adj_set.insert(aspair(k));
         }
     }
 
@@ -272,6 +275,7 @@
 
     // check as adjacency stability
     for (int k=0; k<n; k++) {
+        if (!selfpair(k)) {
         adjacent aa = aspair(k);
         a_history::iterator a = adj_history.find(aa);
         if (a == adj_history.end()) {
@@ -296,6 +300,7 @@
             return suspicious_adjacency;
         }
     }
+    }
     return suspicious_none;
 }