Hello.

I have created a patch (attached) with new protocol option: disabled
keep on|off. To keep the protocol's state while loading new config. It
is useful when protocols disabled manually in the runtime, but we want
to keep that state when loading new config. Patch is attached. I have
made it against the current int-new branch.
diff --git a/doc/bird.sgml b/doc/bird.sgml
index 72c386f..7c7614e 100644
--- a/doc/bird.sgml
+++ b/doc/bird.sgml
@@ -626,6 +626,12 @@ agreement").
 	command line interface without needing to touch the configuration.
 	Disabled protocols are not activated. Default: protocol is enabled.
 
+	<tag><label id="proto-disabled-keep">disabled keep <m/switch/</tag>
+	Keep the protocol state while loading new configuration. So manually
+	disabled ptotocols are not enabled during configure and vice vers.
+	The option's value is taken from the new configuration.
+	Default: disabled (protocol state is not kept).
+
 	<tag><label id="proto-debug">debug all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag>
 	Set protocol debugging options. If asked, each protocol is capable of
 	writing trace messages about its work to the log (with category
diff --git a/nest/config.Y b/nest/config.Y
index 88f74b9..60669e1 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -204,6 +204,7 @@ proto_name:
 
 proto_item:
    /* EMPTY */
+ | DISABLED KEEP bool { this_proto->disabled_keep = $3; }
  | DISABLED bool { this_proto->disabled = $2; }
  | DEBUG debug_mask { this_proto->debug = $2; }
  | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
diff --git a/nest/proto.c b/nest/proto.c
index 7905c9f..a321fce 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -913,6 +913,13 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
 	nc = sym->def;
 	nc->proto = p;
 
+	/* Keep protocol state if configured */
+	if (nc->disabled_keep && (p->disabled != nc->disabled))
+	{
+	  log(L_INFO "Keeping state of protocol %s", p->name);
+	  nc->disabled = p->disabled;
+	}
+
 	/* We will try to reconfigure protocol p */
 	if (! force_reconfig && proto_reconfigure(p, oc, nc, type))
 	  continue;
diff --git a/nest/protocol.h b/nest/protocol.h
index 343ce52..2fd17ae 100644
--- a/nest/protocol.h
+++ b/nest/protocol.h
@@ -115,6 +115,7 @@ struct proto_config {
   int class;				/* SYM_PROTO or SYM_TEMPLATE */
   u8 net_type;				/* Protocol network type (NET_*), 0 for undefined */
   u8 disabled;				/* Protocol enabled/disabled by default */
+  u8 disabled_keep;			/* Keep state on configure */
   u32 debug, mrtdump;			/* Debugging bitfields, both use D_* constants */
   u32 router_id;			/* Protocol specific router ID */
 

Reply via email to