[patch] kernel protocol learn on FreeBSD 7

Eugene Perevyazko john at dnepro.net
Tue Nov 10 14:40:53 CET 2009


On Tue, Nov 10, 2009 at 01:34:18PM +0200, Eugene Perevyazko wrote:
> On Mon, Nov 09, 2009 at 07:10:17PM +0100, Ondrej Zajicek wrote:
> > On Mon, Nov 09, 2009 at 07:57:01PM +0200, Eugene Perevyazko wrote:
> > > Now I see that async alien routes are added, but not deleted.
> > > They are deleted only on rescan.
> > > Is sysdep/bsd/krt.c missing something related to async deleting of alien routes
> > > or is the patch faulty in some way?
> > 
> > Hmm, i don't know. It is possible that async deletion event handling is not
> > implemented in BSD code.
> > 
> I've traced the problem down to this condition in krt_read_rt() in sysdep/bsd/krt-sock.c:
>   if (!(flags & RTF_UP))
>   {
>     DBG("Down.\n");
>     return;
>   }
> Shouldn't it be !(flags & RTF_DONE) ?
> Or maybe even check rtm.errno first?

Well, I'm getting deeper understanding how this stuff works :)
This is my current version of the patch, that looks like works in both 
async learn and scan modes.


--- sysdep/bsd/krt-sock.c.orig	2009-10-02 11:08:51.000000000 +0300
+++ sysdep/bsd/krt-sock.c	2009-11-10 15:33:24.000000000 +0200
@@ -269,11 +269,18 @@
   int src;
   int flags = msg->rtm.rtm_flags;
   int addrs = msg->rtm.rtm_addrs;
+  pid_t sender_pid = msg->rtm.rtm_pid;
+  pid_t my_pid;
   int masklen = -1;
 
-  if (!(flags & RTF_UP))
+  if ( (!(flags & RTF_UP)) && scan )
   {
-    DBG("Down.\n");
+    DBG("Not up in scan.\n");
+    return;
+  }
+  if ( (!(flags & RTF_DONE)) && !scan )
+  {
+    DBG("Not done async.\n");
     return;
   }
 
@@ -375,6 +382,12 @@
   }
 
   src = KRT_SRC_UNKNOWN;	/* FIXME */
+  src = KRT_SRC_ALIEN;
+  my_pid = getpid();
+  if (sender_pid == my_pid)
+  {
+    src = KRT_SRC_BIRD;
+  }
 
   e = rte_get_temp(&a);
   e->net = net;
--- sysdep/cf/bsd.h.orig	2009-06-28 10:33:51.000000000 +0300
+++ sysdep/cf/bsd.h	2009-11-09 19:32:24.000000000 +0200
@@ -7,7 +7,7 @@
  */
 
 #define CONFIG_AUTO_ROUTES
-#undef CONFIG_SELF_CONSCIOUS
+#define CONFIG_SELF_CONSCIOUS
 #undef CONFIG_MULTIPLE_TABLES
 
 #undef CONFIG_UNIX_IFACE

-- 
Eugene Perevyazko



More information about the Bird-users mailing list