]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Kernel syncer is now configurable. It will probably need some more
authorMartin Mares <mj@ucw.cz>
Sun, 6 Dec 1998 17:40:42 +0000 (17:40 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 6 Dec 1998 17:40:42 +0000 (17:40 +0000)
options, but at least basic tuning is possible now.

bird.conf
sysdep/linux/Modules
sysdep/linux/krt-scan.Y [new file with mode: 0644]
sysdep/linux/krt-scan.c
sysdep/linux/krt-scan.h
sysdep/unix/Modules
sysdep/unix/krt.Y [new file with mode: 0644]
sysdep/unix/krt.h
sysdep/unix/main.c
sysdep/unix/sync-rt.c

index 6797aee0c40fc5f75701bf8f0a90af8d0a24772b..80c4f5127ceeaabf1c45546108f48f1a175a60d0 100644 (file)
--- a/bird.conf
+++ b/bird.conf
@@ -17,3 +17,9 @@ protocol device {
 #      disabled
 #      interface "-eth*", "*"
 }
+
+protocol kernel {
+#      disabled
+       learn;                  # Learn all routes from the kernel
+       scan time 10;           # Scan kernel tables every 10 seconds
+}
index 5562ab217a667b48e0b88a1c6bede4744e6866a6..6244479f926038fce2173ccb00b55df549ee4317 100644 (file)
@@ -1,2 +1,3 @@
 krt-scan.c
 krt-scan.h
+krt-scan.Y
diff --git a/sysdep/linux/krt-scan.Y b/sysdep/linux/krt-scan.Y
new file mode 100644 (file)
index 0000000..fcdcfe6
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *     BIRD -- Linux Kernel Syncer Configuration
+ *
+ *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "lib/krt-scan.h"
+
+CF_DECLS
+
+CF_KEYWORDS(LEARN, SCAN, TIME)
+
+CF_GRAMMAR
+
+CF_ADDTO(kern_proto, kern_proto krt_scan_item ';')
+
+krt_scan_item:
+   LEARN bool {
+      ((struct krt_proto *) this_proto)->scanopt.learn = $2;
+   }
+ | SCAN TIME expr {
+      /* Scan time of 0 means scan on startup only */
+      ((struct krt_proto *) this_proto)->scanopt.recurrence = $3;
+   }
+ ;
+
+CF_CODE
+
+CF_END
index 6fdb3bfd5bb67ce991b29bd8b4304e7cd2bd982e..9d8cf5f491bc03dd825d0cb99644f40cf625856a 100644 (file)
@@ -131,11 +131,11 @@ krt_parse_entry(byte *e, struct krt_proto *p)
        return;
 #endif
       DBG("krt_parse_entry: kernel reporting unknown route %I/%d\n", dest, masklen);
-#if 1
-      /* FIXME: should be configurable */
-      if (flags & RTF_GATEWAY)
-       krt_magic_route(p, net, gw);
-#endif
+      if (p->scanopt.learn)
+       {
+         if (flags & RTF_GATEWAY)
+           krt_magic_route(p, net, gw);
+       }
       net->n.flags |= KRF_UPDATE;
     }
 }
@@ -235,7 +235,8 @@ krt_scan_preconfig(struct krt_proto *x)
 {
   SCANOPT;
 
-  p->recurrence = 10;                  /* FIXME: use reasonable default value */
+  p->recurrence = 60;
+  p->learn = 0;
 }
 
 void
index 1ea1ca7288a004caaf58d6206fb79b2651dd6677..18073e2b91e04353ee252eb127eafb54bbd92e84 100644 (file)
@@ -11,6 +11,7 @@
 
 struct krt_scan_params {
   int recurrence;                      /* How often should we scan krt, 0=only on startup */
+  int learn;                           /* Should we learn routes from the kernel? */
   struct timer *timer;
 };
 
index 70ed14549d041c6b9b7cf667214c3b31c7dd3b96..441c3f0742f67ff371f0fc6f60c47de11799d8ad 100644 (file)
@@ -5,6 +5,7 @@ io.c
 unix.h
 sync-if.c
 sync-rt.c
+krt.Y
 krt.h
 krt-set.c
 krt-set.h
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
new file mode 100644 (file)
index 0000000..d4dd082
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *     BIRD -- UNIX Kernel Syncer Configuration
+ *
+ *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "lib/krt.h"
+
+CF_DECLS
+
+CF_KEYWORDS(KERNEL)
+
+CF_GRAMMAR
+
+/* Kernel protocol */
+
+CF_ADDTO(proto, kern_proto '}')
+
+kern_proto_start: proto_start KERNEL {
+     if (!(this_proto = cf_krt_proto)) cf_error("Kernel protocol already defined");
+     cf_krt_proto = NULL;
+   }
+ ;
+
+CF_ADDTO(kern_proto, kern_proto_start '{')
+CF_ADDTO(kern_proto, kern_proto proto_item ';')
+
+CF_CODE
+
+CF_END
index e7b559746ea9391e2bae93296fd5ba04ebfadf41..2da29e5d96159714f152189eaf2d96ef0d2c1e89 100644 (file)
@@ -22,6 +22,8 @@ struct krt_proto {
   struct krt_scan_params scanopt;
 };
 
+extern struct proto *cf_krt_proto;
+
 /* krt-scan.c */
 
 void krt_scan_preconfig(struct krt_proto *);
index 4aeb9c1976bae9dcf02aa0075a73fc10aeb38928..f5076c410a7f3358d12a807fb47acf06084d46e0 100644 (file)
@@ -82,7 +82,6 @@ read_config(void)
   cf_read_hook = cf_read;
   cf_lex_init(1);
   cf_parse();
-  add_tail(&protocol_list, &proto_unix_kernel.n); /* FIXME: Must be _always_ the last one */
   protos_postconfig();
 }
 
@@ -104,6 +103,7 @@ main(void)
   if_init();
 
   protos_build();
+  add_tail(&protocol_list, &proto_unix_kernel.n);
   protos_init();
 
   debug("Reading configuration file.\n");
index 69b2bde1a2eee84c889f1160a585e3577e75241f..169494e2163b5c1693440d36719bc989fbbb8a6a 100644 (file)
@@ -23,6 +23,8 @@
 #include "unix.h"
 #include "krt.h"
 
+struct proto *cf_krt_proto;
+
 void
 krt_start(struct proto *P)
 {
@@ -42,6 +44,7 @@ krt_preconfig(struct protocol *x)
 {
   struct krt_proto *p = (struct krt_proto *) proto_new(&proto_unix_kernel, sizeof(struct krt_proto));
 
+  cf_krt_proto = &p->p;
   p->p.preference = DEF_PREF_UKR;
   p->p.start = krt_start;
   p->p.shutdown = krt_shutdown;