]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Protocol filter reload is now done by 'reload filters'
authorMaria Matejka <mq@ucw.cz>
Wed, 27 Mar 2024 10:34:19 +0000 (11:34 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 29 May 2024 08:39:01 +0000 (10:39 +0200)
This prepares for the separate 'reload bgp' command triggering BGP Route Refresh

doc/bird.sgml
doc/migration-bird3.md
nest/config.Y
nest/proto.c
nest/protocol.h

index b8dfa0c78877e2da3358e9b07d996c12c2b67d5a..c5a75e5448a9c35fac1fa669647358d8ae54e6b8 100644 (file)
@@ -1436,7 +1436,7 @@ This argument can be omitted if there exists only a single instance.
        Enable, disable or restart a given protocol instance, instances matching
        the <cf><m/pattern/</cf> or <cf/all/ instances.
 
-       <tag><label id="cli-reload">reload [in|out] (<m/name/|"<m/pattern/"|all) [partial prefix] </tag>
+       <tag><label id="cli-reload">reload filters [in|out] (<m/name/|"<m/pattern/"|all) [partial prefix] </tag>
        Reload a given protocol instance, that means re-import routes from the
        protocol instance and re-export preferred routes to the instance. If
        <cf/in/ or <cf/out/ options are used, the command is restricted to one
index 3dcbc71a3b0ee37810bd871c2ca8fab2fefe8b40..8b0b50df130fdd30fb01a1b376455ce9120146c9 100644 (file)
@@ -58,6 +58,8 @@ shouldn't have complex export filters anyway.
 Export supports also `export in` form, allowing to export only subprefixes of
 the given prefix. Experimental.
 
+Reload of filters is now done by `reload filters` command, contrary to just `reload` in BIRD 2.
+
 ## Route attributes
 
 All protocol attributes have been renamed in CLI to align with the filter language tokens.
index 527051a3ae9cecf5b841ae55151597435a9c8c2e..aceef060f7e4bf55d1f88e266703f42a05e2dd0e 100644 (file)
@@ -980,12 +980,12 @@ CF_CLI(ENABLE, proto_patt opttext, (<protocol> | \"<pattern>\" | all) [message],
 { proto_apply_cmd($2, proto_cmd_enable, 1, (uintptr_t) $3); } ;
 CF_CLI(RESTART, proto_patt opttext, (<protocol> | \"<pattern>\" | all) [message], [[Restart protocol]])
 { proto_apply_cmd($2, proto_cmd_restart, 1, (uintptr_t) $3); } ;
-CF_CLI(RELOAD, proto_patt partial_opt, (<protocol> | \"<pattern>\" | all) [partial <prefix set>], [[Reload protocol]])
-{ proto_call_cmd_reload($2, CMD_RELOAD, $3); } ;
-CF_CLI(RELOAD IN, proto_patt partial_opt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
-{ proto_call_cmd_reload($3, CMD_RELOAD_IN, $4); } ;
-CF_CLI(RELOAD OUT, proto_patt partial_opt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
-{ proto_call_cmd_reload($3, CMD_RELOAD_OUT, $4); } ;
+CF_CLI(RELOAD FILTERS, proto_patt partial_opt, (<protocol> | \"<pattern>\" | all) [partial <prefix set>], [[Reload protocol filters]])
+{ proto_call_cmd_reload($3, CMD_RELOAD, $4); } ;
+CF_CLI(RELOAD FILTERS IN, proto_patt partial_opt, <protocol> | \"<pattern>\" | all, [[Reload protocol filters (just imported routes)]])
+{ proto_call_cmd_reload($4, CMD_RELOAD_IN, $5); } ;
+CF_CLI(RELOAD FILTERS OUT, proto_patt partial_opt, <protocol> | \"<pattern>\" | all, [[Reload protocol filters (just exported routes)]])
+{ proto_call_cmd_reload($4, CMD_RELOAD_OUT, $5); } ;
 
 CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
 CF_CLI(DEBUG, debug_args, (<protocol> | <channel> | \"<pattern>\" | all) (all | off | { states|routes|filters|interfaces|events|packets [, ...] }), [[Control protocol debugging via BIRD logs]])
index cddbac909cb03b810202690af43a5e121a5593d8..3488dd60e71308094e163b9e429e8b079da28f2e 100644 (file)
@@ -68,7 +68,10 @@ static inline int channel_is_active(struct channel *c)
 { return (c->channel_state != CS_DOWN); }
 
 static inline int channel_reloadable(struct channel *c)
-{ return c->proto->reload_routes && c->reloadable; }
+{
+  return c->reloadable && c->proto->reload_routes
+      || ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER);
+}
 
 static inline void
 channel_log_state_change(struct channel *c)
@@ -605,12 +608,6 @@ channel_roa_subscribe_filter(struct channel *c, int dir)
   if (dir && !channel_reloadable(c))
     valid = 0;
 
-#ifdef CONFIG_BGP
-  /* No automatic reload for BGP channels without in_table / out_table */
-  if (c->class == &channel_bgp)
-    valid = dir ? ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER) : !!c->out_table;
-#endif
-
   struct filter_iterator fit;
   FILTER_ITERATE_INIT(&fit, f->root, c->proto->pool);
 
@@ -2922,7 +2919,7 @@ proto_cmd_reload(struct proto *p, uintptr_t _prr, int cnt UNUSED)
     return;
 
   /* All channels must support reload */
-  if (prr->dir != CMD_RELOAD_OUT)
+  if (prr->dir & CMD_RELOAD_IN)
     WALK_LIST(c, p->channels)
       if ((c->channel_state == CS_UP) && !channel_reloadable(c))
       {
index f941fec03039b9779062562e60b87d68cde69959..fc3a94bda0c267a2ac9ffd7e8dd6f18e3e497930 100644 (file)
@@ -286,7 +286,11 @@ struct proto *proto_iterate_named(struct symbol *sym, struct protocol *proto, st
 struct proto_reload_request {
   const struct f_trie *trie;   /* Trie to apply */
   _Atomic uint counter;                /* How many channels remaining */
-  uint dir;                    /* Direction of reload */
+  enum cmd_reload {
+    CMD_RELOAD_IN      = 1,
+    CMD_RELOAD_OUT     = 2,
+    CMD_RELOAD         = (CMD_RELOAD_IN | CMD_RELOAD_OUT),
+  } dir;                       /* Direction of reload */
   event ev;                    /* Event to run when finished */
 };
 
@@ -304,10 +308,6 @@ struct proto_reload_request {
 static inline struct domain_generic *proto_domain(struct proto *p)
 { return birdloop_domain(p->loop); }
 
-#define CMD_RELOAD     0
-#define CMD_RELOAD_IN  1
-#define CMD_RELOAD_OUT 2
-
 static inline u32
 proto_get_router_id(struct proto_config *pc)
 {