diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 00000000..f1eb3b51 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,7 @@ +; BIRD project coding conventions + +((c-mode + (c-file-style . "bsd") + (c-basic-offset . 2) + (fill-column . 80) + (show-trailing-whitespace . t))) diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 38250d90..1d6cae2c 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -88,7 +88,7 @@ HASH_DEFINE_REHASH_FN(SYM, struct symbol) HASH(struct keyword) kw_hash; -static struct sym_scope *conf_this_scope; +struct sym_scope *conf_this_scope; linpool *cfg_mem; @@ -719,7 +719,8 @@ cf_lex_init(int is_cli, struct config *c) else BEGIN(INITIAL); - conf_this_scope = cfg_allocz(sizeof(struct sym_scope)); + c->root_scope = cfg_allocz(sizeof(struct sym_scope)); + conf_this_scope = c->root_scope; conf_this_scope->active = 1; } diff --git a/conf/conf.c b/conf/conf.c index b0980d7e..b21d5213 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -447,6 +447,24 @@ 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 @@ -477,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; diff --git a/conf/conf.h b/conf/conf.h index 708a1034..21dc3fa1 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -53,8 +53,10 @@ struct config { int file_fd; /* File descriptor of main configuration file */ HASH(struct symbol) sym_hash; /* Lexer: symbol hash table */ struct config *fallback; /* Link to regular config for CLI parsing */ + struct sym_scope *root_scope; /* Scope for root symbols */ int obstacle_count; /* Number of items blocking freeing of this config */ int shutdown; /* This is a pseudo-config for daemon shutdown */ + int gr_down; /* This is a pseudo-config for graceful restart */ btime load_time; /* When we've got this configuration */ }; @@ -69,11 +71,13 @@ void config_free(struct config *); int config_commit(struct config *, int type, uint timeout); int config_confirm(void); int config_undo(void); +int config_status(void); +btime config_timer_status(void); void config_init(void); void cf_error(const char *msg, ...) NORET; void config_add_obstacle(struct config *); void config_del_obstacle(struct config *); -void order_shutdown(void); +void order_shutdown(int gr); #define RECONFIG_NONE 0 #define RECONFIG_HARD 1 @@ -167,6 +171,8 @@ struct include_file_stack { extern struct include_file_stack *ifs; +extern struct sym_scope *conf_this_scope; + int cf_lex(void); void cf_lex_init(int is_cli, struct config *c); void cf_lex_unwind(void); diff --git a/doc/bird.sgml b/doc/bird.sgml index 8594b930..e0b60c81 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -561,7 +561,7 @@ include "tablename.conf";; can be seen (together with other symbols) using 'show symbols' command.