]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Kernel route syncer now supports dynamic reconfiguration. Also it doesn't
authorMartin Mares <mj@ucw.cz>
Tue, 18 Jan 2000 10:39:30 +0000 (10:39 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 18 Jan 2000 10:39:30 +0000 (10:39 +0000)
depend on the startup counter hack now and uses a zero-time timer instead
to make itself scheduled after normal protocol startup.

sysdep/linux/krt-scan.h
sysdep/linux/netlink/krt-scan.h
sysdep/linux/netlink/krt-set.h
sysdep/unix/krt-set.h
sysdep/unix/krt.c
sysdep/unix/krt.h

index c5bf58847dace2678aaea36dbc846e3583eb516c..6c7e440fe321642b6ba749d6dd166fb89e773c83 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Linux Kernel Route Syncer -- Scanning
  *
- *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -16,4 +16,6 @@ struct krt_scan_status {
   list temp_ifs;                       /* Temporary interfaces */
 };
 
+static inline int krt_scan_params_same(struct krt_scan_params *o, struct krt_scan_params *n) { return 1; }
+
 #endif
index cdfe44431fcc2418cbf6281fc8b70a5d29bbcd84..ec10a7fec17b7a4fb8e319c822f3f9f3d9006fb5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Linux Kernel Netlink Route Syncer -- Scanning
  *
- *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -30,4 +30,9 @@ struct krt_scan_status {
   list temp_ifs;                       /* Temporary interfaces */
 };
 
+static inline int krt_scan_params_same(struct krt_scan_params *o, struct krt_scan_params *n)
+{
+  return o->async == n->async && o->table_id == n->table_id;
+}
+
 #endif
index 48df5ecf9d50937f90cf6a9e32185de6a90907fe..4f35e090252614904a5bdfcfbe051fb094624f9b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Kernel Netlink Route Syncer -- Dummy Include File
  *
- *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -22,5 +22,6 @@ struct krt_set_status {
 static inline void krt_set_construct(struct krt_config *c) { };
 static inline void krt_set_start(struct krt_proto *p, int first) { };
 static inline void krt_set_shutdown(struct krt_proto *p, int last) { };
+static inline int krt_set_params_same(struct krt_set_params *o, struct krt_set_params *n) { return 1; }
 
 #endif
index cfa5fb763ab8c56c673f7da9ee91351e59666e06..1c5e15e133aeb780458cf026a78d6d4e7c78237a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Unix Kernel Route Syncer -- Setting
  *
- *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -15,4 +15,6 @@ struct krt_set_params {
 struct krt_set_status {
 };
 
+static inline int krt_set_params_same(struct krt_set_params *o, struct krt_set_params *n) { return 1; }
+
 #endif
index b321729b527bab8cd588b3666ec86c962e7cfb2b..110ded08fdf61e346c259676aceb8fd0d1fd4525 100644 (file)
@@ -582,6 +582,7 @@ krt_prune(struct krt_proto *p)
   if (KRT_CF->learn)
     krt_learn_prune(p);
 #endif
+  p->initialized = 1;
 }
 
 void
@@ -661,7 +662,8 @@ krt_notify(struct proto *P, net *net, rte *new, rte *old, struct ea_list *tmpa)
     net->n.flags |= KRF_INSTALLED;
   else
     net->n.flags &= ~KRF_INSTALLED;
-  krt_set_notify(p, net, new, old);
+  if (p->initialized)                  /* Before first scan we don't touch the routes */
+    krt_set_notify(p, net, new, old);
 }
 
 /*
@@ -703,7 +705,7 @@ krt_start_timer(struct krt_proto *p)
   t->hook = krt_scan;
   t->data = p;
   t->recurrent = KRT_CF->scan_time;
-  tm_start(t, KRT_CF->scan_time);
+  tm_start(t, 0);
   return t;
 }
 
@@ -735,13 +737,11 @@ krt_start(struct proto *P)
 #ifdef CONFIG_ALL_TABLES_AT_ONCE
   if (first)
     krt_scan_timer = krt_start_timer(p);
+  else
+    tm_start(p->scan_timer, 0);
   p->scan_timer = krt_scan_timer;
-  /* If this is the last instance to be initialized, kick the timer */
-  if (!P->proto->startup_counter)
-    krt_scan(p->scan_timer);
 #else
   p->scan_timer = krt_start_timer(p);
-  krt_scan(p->scan_timer);
 #endif
 
   return PS_UP;
@@ -785,6 +785,19 @@ krt_init(struct proto_config *c)
   return &p->p;
 }
 
+static int
+krt_reconfigure(struct proto *p, struct proto_config *new)
+{
+  struct krt_config *o = (struct krt_config *) p->cf;
+  struct krt_config *n = (struct krt_config *) new;
+
+  return o->scan_time == n->scan_time
+    && o->learn == n->learn            /* persist needn't be the same */
+    && krt_set_params_same(&o->set, &n->set)
+    && krt_scan_params_same(&o->scan, &n->scan)
+    ;
+}
+
 struct protocol proto_unix_kernel = {
   name:                "Kernel",
   template:    "kernel%d",
@@ -794,6 +807,7 @@ struct protocol proto_unix_kernel = {
   init:                krt_init,
   start:       krt_start,
   shutdown:    krt_shutdown,
+  reconfigure: krt_reconfigure,
 #ifdef KRT_ALLOW_LEARN
   dump:                krt_dump,
   dump_attrs:  krt_dump_attrs,
index 85b884a1ad43306219facbbc807e65ca40d46892..8a444f0460407653d3c798b54e3cf08fe1a78608 100644 (file)
@@ -62,6 +62,7 @@ struct krt_proto {
 #ifdef CONFIG_ALL_TABLES_AT_ONCE
   node instance_node;          /* Node in krt instance list */
 #endif
+  int initialized;             /* First scan has already been finished */
 };
 
 extern struct proto_config *cf_krt;