[Babel-users] Duplicating externals (was: not routing)

Juliusz Chroboczek jch at pps.jussieu.fr
Sat Nov 7 17:47:26 UTC 2009


Okay, I think that's the correct solution.

Please try this patch, running Babel with ``-A''.

                                        Juliusz

Sat Nov  7 18:44:25 CET 2009  Juliusz Chroboczek <jch at pps.jussieu.fr>
  * Document -A.
Sat Nov  7 18:43:25 CET 2009  Juliusz Chroboczek <jch at pps.jussieu.fr>
  * Implement -A.
diff -rN -u old-babeld/babeld.c new-babeld/babeld.c
--- old-babeld/babeld.c	2009-11-07 18:44:52.228760892 +0100
+++ new-babeld/babeld.c	2009-11-07 18:44:52.228760892 +0100
@@ -171,6 +171,11 @@
             if(kernel_metric < 0 || kernel_metric > 0xFFFF)
                 goto usage;
             break;
+        case 'A':
+            allow_duplicates = atoi(optarg);
+            if(allow_duplicates < 0 || allow_duplicates > 0xFFFF)
+                goto usage;
+            break;
         case 'P':
             parasitic = 1;
             break;
@@ -231,7 +236,6 @@
         }
     }
 
-
     if(!config_file) {
         if(access("/etc/babeld.conf", F_OK) >= 0)
             config_file = "/etc/babeld.conf";
@@ -258,6 +262,12 @@
         wired_hello_interval = 20000;
     wired_hello_interval = MAX(wired_hello_interval, 5);
 
+    if(parasitic && allow_duplicates >= 0) {
+        /* Too difficult to get right. */
+        fprintf(stderr, "Sorry, -P and -A are incompatible.\n");
+        exit(1);
+    }
+
     if(do_daemonise) {
         if(logfile == NULL)
             logfile = "/var/log/babeld.log";
@@ -776,7 +786,7 @@
             "                "
             "[-h hello] [-H wired_hello] [-i idle_hello]\n"
             "                "
-            "[-k metric] [-s] [-P] [-l] [-w] [-d level] [-g port]\n"
+            "[-k metric] [-A metric] [-s] [-P] [-l] [-w] [-d level] [-g port]\n"
             "                "
             "[-t table] [-T table] [-c file] [-C statement]\n"
             "                "
diff -rN -u old-babeld/babeld.man new-babeld/babeld.man
--- old-babeld/babeld.man	2009-11-07 18:44:52.224764188 +0100
+++ new-babeld/babeld.man	2009-11-07 18:44:52.232763395 +0100
@@ -52,6 +52,12 @@
 Specify the priority value used when installing routes into the kernel.
 The default is 0.
 .TP
+.BI \-A " priority"
+Allow duplicating external routes when their kernel priority is at least
+.IR priority .
+Do not use this option unless you know what you are doing, as it can cause
+persistent route flapping.
+.TP
 .B \-l
 Use IFF_RUNNING (carrier sense) when determining interface availability.
 .TP
diff -rN -u old-babeld/message.c new-babeld/message.c
--- old-babeld/message.c	2009-11-07 18:44:52.228760892 +0100
+++ new-babeld/message.c	2009-11-07 18:44:52.232763395 +0100
@@ -878,16 +878,15 @@
             }
 
             xroute = find_xroute(b[i].prefix, b[i].plen);
-            if(xroute) {
+            route = find_installed_route(b[i].prefix, b[i].plen);
+
+            if(xroute && (!route || xroute->metric <= kernel_metric)) {
                 really_send_update(net, myid,
                                    xroute->prefix, xroute->plen,
                                    myseqno, xroute->metric);
                 last_prefix = xroute->prefix;
                 last_plen = xroute->plen;
-                continue;
-            }
-            route = find_installed_route(b[i].prefix, b[i].plen);
-            if(route) {
+            } else if(route) {
                 seqno = route->seqno;
                 metric = route->metric;
                 if(metric < INFINITY)
@@ -903,13 +902,12 @@
                 update_source(route->src, seqno, metric);
                 last_prefix = route->src->prefix;
                 last_plen = route->src->plen;
-                continue;
+            } else {
+            /* There's no route for this prefix.  This can happen shortly
+               after an xroute has been retracted, so send a retraction. */
+                really_send_update(net, myid, b[i].prefix, b[i].plen,
+                                   myseqno, INFINITY);
             }
-            /* If we reach this point, there's no route for this prefix.
-               This can happen after an xroute has been retracted, so send
-               a retraction. */
-            really_send_update(net, myid, b[i].prefix, b[i].plen,
-                               myseqno, INFINITY);
         }
         schedule_flush_now(net);
     done:
@@ -1348,7 +1346,9 @@
     struct neighbour *successor = NULL;
 
     xroute = find_xroute(prefix, plen);
-    if(xroute) {
+    route = find_installed_route(prefix, plen);
+
+    if(xroute && (!route || xroute->metric <= kernel_metric)) {
         if(hop_count > 0 && memcmp(id, myid, 8) == 0) {
             if(seqno_compare(seqno, myseqno) > 0) {
                 if(seqno_minus(seqno, myseqno) > 100) {
@@ -1362,7 +1362,6 @@
         return;
     }
 
-    route = find_installed_route(prefix, plen);
     if(route &&
        (memcmp(id, route->src->id, 8) != 0 ||
         seqno_compare(seqno, route->seqno) <= 0)) {
diff -rN -u old-babeld/route.c new-babeld/route.c
--- old-babeld/route.c	2009-11-07 18:44:52.224764188 +0100
+++ new-babeld/route.c	2009-11-07 18:44:52.232763395 +0100
@@ -42,6 +42,7 @@
 struct route *routes = NULL;
 int numroutes = 0, maxroutes = 0;
 int kernel_metric = 0;
+int allow_duplicates = -1;
 
 struct route *
 find_route(const unsigned char *prefix, unsigned char plen,
@@ -512,6 +513,7 @@
 consider_route(struct route *route)
 {
     struct route *installed;
+    struct xroute *xroute;
 
     if(route->installed)
         return;
@@ -519,8 +521,9 @@
     if(!route_feasible(route))
         return;
 
-    if(find_xroute(route->src->prefix, route->src->plen))
-       return;
+    xroute = find_xroute(route->src->prefix, route->src->plen);
+    if(xroute && (allow_duplicates < 0 || xroute->metric >= allow_duplicates))
+        return;
 
     installed = find_installed_route(route->src->prefix, route->src->plen);
 
diff -rN -u old-babeld/route.h new-babeld/route.h
--- old-babeld/route.h	2009-11-07 18:44:52.224764188 +0100
+++ new-babeld/route.h	2009-11-07 18:44:52.232763395 +0100
@@ -34,7 +34,7 @@
 
 extern struct route *routes;
 extern int numroutes, maxroutes;
-extern int kernel_metric;
+extern int kernel_metric, allow_duplicates;
 
 struct route *find_route(const unsigned char *prefix, unsigned char plen,
                          struct neighbour *neigh, const unsigned char *nexthop);
diff -rN -u old-babeld/xroute.c new-babeld/xroute.c
--- old-babeld/xroute.c	2009-11-07 18:44:52.224764188 +0100
+++ new-babeld/xroute.c	2009-11-07 18:44:52.236762195 +0100
@@ -208,8 +208,11 @@
             if(rc) {
                 struct route *route;
                 route = find_installed_route(routes[i].prefix, routes[i].plen);
-                if(route)
-                    uninstall_route(route);
+                if(route) {
+                    if(allow_duplicates < 0 ||
+                       routes[i].metric < allow_duplicates)
+                        uninstall_route(route);
+                }
                 change = 1;
                 if(send_updates)
                     send_update(NULL, 0, routes[i].prefix, routes[i].plen);




More information about the Babel-users mailing list