0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Protocol filter reload is now done by 'reload filters'

This prepares for the separate 'reload bgp' command triggering BGP Route Refresh
This commit is contained in:
Maria Matejka 2024-03-27 11:34:19 +01:00
parent 492c416c0a
commit e17824f5e5
5 changed files with 19 additions and 20 deletions

View 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

View 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.

View 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]])

View 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))
{

View 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)
{