Commit 8a68316e authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Nest: Add command to request graceful restart

When 'graceful down' command is entered, protocols are shut down
with regard to graceful restart. Namely Kernel protocol does
not remove routes and BGP protocol does not send notification,
just closes the connection.
parent bdf2e55d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -492,19 +492,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;

  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;
+2 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ struct config {
  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 */
};

@@ -75,7 +76,7 @@ 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
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ Reply codes of BIRD command-line interface
0022	Undo scheduled
0023	Evaluation of expression
0024	Graceful restart status report
0025	Graceful restart ordered

1000	BIRD version
1001	Interface list
+5 −0
Original line number Diff line number Diff line
@@ -1048,6 +1048,11 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
	p->down_code = PDC_CF_REMOVE;
	p->cf_new = NULL;
      }
      else if (new->gr_down)
      {
	p->down_code = PDC_CMD_GR_DOWN;
	p->cf_new = NULL;
      }
      else /* global shutdown */
      {
	p->down_code = PDC_CMD_SHUTDOWN;
+1 −0
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ struct proto_spec {
#define PDC_CMD_DISABLE		0x11	/* Result of disable command */
#define PDC_CMD_RESTART		0x12	/* Result of restart command */
#define PDC_CMD_SHUTDOWN	0x13	/* Result of global shutdown */
#define PDC_CMD_GR_DOWN		0x14	/* Result of global graceful restart */
#define PDC_RX_LIMIT_HIT	0x21	/* Route receive limit reached */
#define PDC_IN_LIMIT_HIT	0x22	/* Route import limit reached */
#define PDC_OUT_LIMIT_HIT	0x23	/* Route export limit reached */
Loading