]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - conf/conf.c
Merge branch 'master' into mq-filter-stack
[thirdparty/bird.git] / conf / conf.c
index 9978ef23c4da30a7653adb0c0f28c1dd5fb6e1dd..b21d5213ad198a4347ce81a183cbeaf478880378 100644 (file)
@@ -52,7 +52,7 @@
 #include "lib/resource.h"
 #include "lib/string.h"
 #include "lib/event.h"
-#include "sysdep/unix/timer.h"
+#include "lib/timer.h"
 #include "conf/conf.h"
 #include "filter/filter.h"
 
@@ -98,13 +98,14 @@ config_alloc(const char *name)
   memcpy(ndup, name, nlen);
 
   init_list(&c->tests);
+  init_list(&c->symbols);
   c->mrtdump_file = -1; /* Hack, this should be sysdep-specific */
   c->pool = p;
   c->mem = l;
   c->file_name = ndup;
-  c->load_time = now;
-  c->tf_route = c->tf_proto = (struct timeformat){"%T", "%F", 20*3600};
-  c->tf_base = c->tf_log = (struct timeformat){"%F %T", NULL, 0};
+  c->load_time = current_time();
+  c->tf_route = c->tf_proto = TM_ISO_SHORT_MS;
+  c->tf_base = c->tf_log = TM_ISO_LONG_MS;
   c->gr_wait = DEFAULT_GR_WAIT;
 
   return c;
@@ -166,7 +167,7 @@ int
 cli_parse(struct config *c)
 {
   int done = 0;
-  c->sym_fallback = config->sym_hash;
+  c->fallback = config;
   new_config = c;
   cfg_mem = c->mem;
   if (setjmp(conf_jmpbuf))
@@ -177,7 +178,7 @@ cli_parse(struct config *c)
   done = 1;
 
 cleanup:
-  c->sym_fallback = NULL;
+  c->fallback = NULL;
   new_config = NULL;
   cfg_mem = NULL;
   return done;
@@ -209,7 +210,7 @@ config_del_obstacle(struct config *c)
 {
   DBG("+++ deleting obstacle %d\n", c->obstacle_count);
   c->obstacle_count--;
-  if (!c->obstacle_count)
+  if (!c->obstacle_count && (c != config))
     ev_schedule(config_event);
 }
 
@@ -219,11 +220,6 @@ global_commit(struct config *new, struct config *old)
   if (!old)
     return 0;
 
-  if (!ipa_equal(old->listen_bgp_addr, new->listen_bgp_addr) ||
-      (old->listen_bgp_port != new->listen_bgp_port) ||
-      (old->listen_bgp_flags != new->listen_bgp_flags))
-    log(L_WARN "Reconfiguration of BGP listening socket not implemented, please restart BIRD.");
-
   if (!new->router_id)
     {
       new->router_id = old->router_id;
@@ -263,6 +259,8 @@ config_do_commit(struct config *c, int type)
   if (old_config)
     old_config->obstacle_count++;
 
+  DBG("filter_commit\n");
+  filter_commit(c, old_config);
   DBG("sysdep_commit\n");
   int force_restart = sysdep_commit(c, old_config);
   DBG("global_commit\n");
@@ -307,7 +305,7 @@ config_done(void *unused UNUSED)
  * config_commit - commit a configuration
  * @c: new configuration
  * @type: type of reconfiguration (RECONFIG_SOFT or RECONFIG_HARD)
- * @timeout: timeout for undo (or 0 for no timeout)
+ * @timeout: timeout for undo (in seconds; or 0 for no timeout)
  *
  * When a configuration is parsed and prepared for use, the
  * config_commit() function starts the process of reconfiguration.
@@ -331,7 +329,7 @@ config_done(void *unused UNUSED)
  * are accepted.
  */
 int
-config_commit(struct config *c, int type, int timeout)
+config_commit(struct config *c, int type, uint timeout)
 {
   if (shutting_down)
     {
@@ -340,8 +338,8 @@ config_commit(struct config *c, int type, int timeout)
     }
 
   undo_available = 1;
-  if (timeout > 0)
-    tm_start(config_timer, timeout);
+  if (timeout)
+    tm_start(config_timer, timeout S);
   else
     tm_stop(config_timer);
 
@@ -449,10 +447,28 @@ config_undo(void)
   return CONF_PROGRESS;
 }
 
+int
+config_status(void)
+{
+  if (shutting_down)
+    return CONF_SHUTDOWN;
+
+  if (configuring)
+    return future_cftype ? CONF_QUEUED : CONF_PROGRESS;
+
+  return CONF_DONE;
+}
+
+btime
+config_timer_status(void)
+{
+  return tm_active(config_timer) ? tm_remains(config_timer) : -1;
+}
+
 extern void cmd_reconfig_undo_notify(void);
 
 static void
-config_timeout(struct timer *t UNUSED)
+config_timeout(timer *t UNUSED)
 {
   log(L_INFO "Config timeout expired, starting undo");
   cmd_reconfig_undo_notify();
@@ -479,19 +495,24 @@ config_init(void)
  * for switching to an empty configuration.
  */
 void
-order_shutdown(void)
+order_shutdown(int gr)
 {
   struct config *c;
 
   if (shutting_down)
     return;
 
-  log(L_INFO "Shutting down");
+  if (!gr)
+    log(L_INFO "Shutting down");
+  else
+    log(L_INFO "Shutting down for graceful restart");
+
   c = lp_alloc(config->mem, sizeof(struct config));
   memcpy(c, config, sizeof(struct config));
   init_list(&c->protos);
   init_list(&c->tables);
   c->shutdown = 1;
+  c->gr_down = gr;
 
   config_commit(c, RECONFIG_HARD, 0);
   shutting_down = 1;
@@ -517,6 +538,7 @@ cf_error(const char *msg, ...)
   va_end(args);
   new_config->err_msg = cfg_strdup(buf);
   new_config->err_lino = ifs->lino;
+  new_config->err_chno = ifs->chno - ifs->toklen + 1;
   new_config->err_file_name = ifs->file_name;
   cf_lex_unwind();
   longjmp(conf_jmpbuf, 1);