0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Merge commit '37b64441' into thread-next

This commit is contained in:
Maria Matejka 2022-11-07 10:28:01 +01:00
commit 7bbd0b5a3b
8 changed files with 36 additions and 18 deletions

View File

@ -736,7 +736,7 @@ cf_lex_symbol(const char *data)
static void static void
cf_lex_init_kh(void) cf_lex_init_kh(void)
{ {
HASH_INIT(kw_hash, &root_pool, KW_ORDER); HASH_INIT(kw_hash, config_pool, KW_ORDER);
struct keyword *k; struct keyword *k;
for (k=keyword_list; k->name; k++) for (k=keyword_list; k->name; k++)
@ -864,7 +864,7 @@ cf_push_soft_scope(void)
if (conf_this_scope->soft_scopes < 0xfe) if (conf_this_scope->soft_scopes < 0xfe)
conf_this_scope->soft_scopes++; conf_this_scope->soft_scopes++;
else else
cf_push_scope(NULL); cf_push_block_scope();
} }
/** /**
@ -878,7 +878,7 @@ cf_pop_soft_scope(void)
if (conf_this_scope->soft_scopes) if (conf_this_scope->soft_scopes)
conf_this_scope->soft_scopes--; conf_this_scope->soft_scopes--;
else else
cf_pop_scope(); cf_pop_block_scope();
} }
/** /**
@ -893,7 +893,7 @@ cf_swap_soft_scope(void)
if (conf_this_scope->soft_scopes) if (conf_this_scope->soft_scopes)
{ {
conf_this_scope->soft_scopes--; conf_this_scope->soft_scopes--;
cf_push_scope(NULL); cf_push_block_scope();
} }
} }

View File

@ -61,6 +61,7 @@
static jmp_buf conf_jmpbuf; static jmp_buf conf_jmpbuf;
struct config *config, *new_config; struct config *config, *new_config;
pool *config_pool;
static struct config *old_config; /* Old configuration */ static struct config *old_config; /* Old configuration */
static struct config *future_config; /* New config held here if recon requested during recon */ static struct config *future_config; /* New config held here if recon requested during recon */
@ -89,7 +90,7 @@ int undo_available; /* Undo was not requested from last reconfiguration */
struct config * struct config *
config_alloc(const char *name) config_alloc(const char *name)
{ {
pool *p = rp_new(&root_pool, "Config"); pool *p = rp_new(config_pool, "Config");
linpool *l = lp_new_default(p); linpool *l = lp_new_default(p);
struct config *c = lp_allocz(l, sizeof(struct config)); struct config *c = lp_allocz(l, sizeof(struct config));
@ -489,10 +490,12 @@ config_timeout(timer *t UNUSED)
void void
config_init(void) config_init(void)
{ {
config_event = ev_new(&root_pool); config_pool = rp_new(&root_pool, "Configurations");
config_event = ev_new(config_pool);
config_event->hook = config_done; config_event->hook = config_done;
config_timer = tm_new(&root_pool); config_timer = tm_new(config_pool);
config_timer->hook = config_timeout; config_timer->hook = config_timeout;
} }

View File

@ -96,7 +96,7 @@ void order_shutdown(int gr);
/* Pools */ /* Pools */
extern pool *config_pool;
extern linpool *cfg_mem; extern linpool *cfg_mem;
#define cfg_alloc(size) lp_alloc(cfg_mem, size) #define cfg_alloc(size) lp_alloc(cfg_mem, size)
@ -137,6 +137,7 @@ struct sym_scope {
uint slots; /* Variable slots */ uint slots; /* Variable slots */
byte active; /* Currently entered */ byte active; /* Currently entered */
byte block; /* No independent stack frame */
byte soft_scopes; /* Number of soft scopes above */ byte soft_scopes; /* Number of soft scopes above */
}; };
@ -232,6 +233,12 @@ void cf_pop_scope(void);
void cf_push_soft_scope(void); void cf_push_soft_scope(void);
void cf_pop_soft_scope(void); void cf_pop_soft_scope(void);
static inline void cf_push_block_scope(void)
{ cf_push_scope(NULL); conf_this_scope->block = 1; }
static inline void cf_pop_block_scope(void)
{ ASSERT(conf_this_scope->block); cf_pop_scope(); }
char *cf_symbol_class_name(struct symbol *sym); char *cf_symbol_class_name(struct symbol *sym);
/* Parser */ /* Parser */

View File

@ -180,7 +180,7 @@ flow6_opts:
flow_builder_init: flow_builder_init:
{ {
if (this_flow == NULL) if (this_flow == NULL)
this_flow = flow_builder_init(&root_pool); this_flow = flow_builder_init(config_pool); /* FIXME: This should be allocated from tmp in future */
else else
flow_builder_clear(this_flow); flow_builder_clear(this_flow);
}; };

View File

@ -1149,7 +1149,7 @@ This argument can be omitted if there exists only a single instance.
Show the list of symbols defined in the configuration (names of Show the list of symbols defined in the configuration (names of
protocols, routing tables etc.). protocols, routing tables etc.).
<tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag> <tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [(import|export) table <m/p/.<m/c/] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag>
Show contents of specified routing tables, that is routes, their metrics Show contents of specified routing tables, that is routes, their metrics
and (in case the <cf/all/ switch is given) all their attributes. and (in case the <cf/all/ switch is given) all their attributes.
@ -1169,6 +1169,11 @@ This argument can be omitted if there exists only a single instance.
Last, the set of default tables is used: <cf/master4/, <cf/master6/ and Last, the set of default tables is used: <cf/master4/, <cf/master6/ and
each first table of any other network type. each first table of any other network type.
<p>There are internal tables when <cf/(import|export) table/ options
are used for some channels. They can be selected explicitly with
<cf/(import|export) table/ switch, specifying protocol <m/p/ and
channel name <m/c/.
<p>You can also ask for printing only routes processed and accepted by <p>You can also ask for printing only routes processed and accepted by
a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ } a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ }
</cf> or matching a given condition (<cf>where <m/condition/</cf>). </cf> or matching a given condition (<cf>where <m/condition/</cf>).

View File

@ -38,9 +38,9 @@ f_new_var(struct sym_scope *s)
/* /*
* - A variable is an offset on vstack from vbase. * - A variable is an offset on vstack from vbase.
* - Vbase is set on filter start / function call. * - Vbase is set on filter start / function call.
* - Scopes contain anonymous scopes (blocks) inside filter/function scope * - Scopes contain (non-frame) block scopes inside filter/function scope
* - Each scope knows number of vars in that scope * - Each scope knows number of vars in that scope
* - Offset is therefore a sum of 'slots' up to named scope * - Offset is therefore a sum of 'slots' up to filter/function scope
* - New variables are added on top of vstk, so intermediate values cannot * - New variables are added on top of vstk, so intermediate values cannot
* be there during FI_VAR_INIT. I.e. no 'var' inside 'term'. * be there during FI_VAR_INIT. I.e. no 'var' inside 'term'.
* - Also, each f_line must always have its scope, otherwise a variable may * - Also, each f_line must always have its scope, otherwise a variable may
@ -49,7 +49,7 @@ f_new_var(struct sym_scope *s)
int offset = s->slots++; int offset = s->slots++;
while (!s->name) while (s->block)
{ {
s = s->next; s = s->next;
ASSERT(s); ASSERT(s);
@ -491,10 +491,12 @@ filter:
cf_assert_symbol($1, SYM_FILTER); cf_assert_symbol($1, SYM_FILTER);
$$ = $1->filter; $$ = $1->filter;
} }
| filter_body { | { cf_push_scope(NULL); } filter_body {
struct filter *f = cfg_alloc(sizeof(struct filter)); struct filter *f = cfg_alloc(sizeof(struct filter));
*f = (struct filter) { .root = $1 }; *f = (struct filter) { .root = $2 };
$$ = f; $$ = f;
cf_pop_scope();
} }
; ;
@ -937,13 +939,13 @@ cmd:
} }
| FOR { | FOR {
/* Reserve space for walk data on stack */ /* Reserve space for walk data on stack */
cf_push_scope(NULL); cf_push_block_scope();
conf_this_scope->slots += 2; conf_this_scope->slots += 2;
} for_var IN } for_var IN
/* Parse term in the parent scope */ /* Parse term in the parent scope */
{ conf_this_scope->active = 0; } term { conf_this_scope->active = 1; } { conf_this_scope->active = 0; } term { conf_this_scope->active = 1; }
DO cmd { DO cmd {
cf_pop_scope(); cf_pop_block_scope();
$$ = f_new_inst(FI_FOR_INIT, $6, $3); $$ = f_new_inst(FI_FOR_INIT, $6, $3);
$$->next = f_new_inst(FI_FOR_NEXT, $3, $9); $$->next = f_new_inst(FI_FOR_NEXT, $3, $9);
} }

View File

@ -118,6 +118,7 @@ cmd_show_memory(void)
print_size("Routing tables:", rmemsize(rt_table_pool)); print_size("Routing tables:", rmemsize(rt_table_pool));
print_size("Route attributes:", rmemsize(rta_pool)); print_size("Route attributes:", rmemsize(rta_pool));
print_size("Protocols:", rmemsize(proto_pool)); print_size("Protocols:", rmemsize(proto_pool));
print_size("Current config:", rmemsize(config_pool));
struct resmem total = rmemsize(&root_pool); struct resmem total = rmemsize(&root_pool);
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
int pk = atomic_load_explicit(&pages_kept, memory_order_relaxed) int pk = atomic_load_explicit(&pages_kept, memory_order_relaxed)

View File

@ -656,7 +656,7 @@ CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
{ if_show_summary(); } ; { if_show_summary(); } ;
CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]]) CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]]) CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [(import|export) table <p>.<c>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
{ rt_show($3); } ; { rt_show($3); } ;
r_args: r_args: