mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
CLI: Show symbols, route and mpls explicitly passes the actual config to the show function
This commit is contained in:
parent
c4fbc5592d
commit
73ad0e2dcb
@ -51,7 +51,7 @@ cmd_show_symbols(struct sym_show_data *sd)
|
||||
cli_msg(1010, "%-8s\t%s", sd->sym->name, cf_symbol_class_name(sd->sym));
|
||||
else
|
||||
{
|
||||
for (const struct sym_scope *scope = config->root_scope; scope; scope = scope->next)
|
||||
for (const struct sym_scope *scope = sd->config->root_scope; scope; scope = scope->next)
|
||||
HASH_WALK(scope->hash, next, sym)
|
||||
{
|
||||
if (sd->type && (sym->class != sd->type))
|
||||
|
@ -7,8 +7,9 @@
|
||||
*/
|
||||
|
||||
struct sym_show_data {
|
||||
int type; /* Symbols type to show */
|
||||
struct symbol *sym;
|
||||
int type; /* Symbols type to show */
|
||||
struct symbol *sym;
|
||||
struct config *config; /* The actual configuration to dump */
|
||||
};
|
||||
|
||||
struct f_inst;
|
||||
|
@ -734,8 +734,9 @@ r_args:
|
||||
$$ = cfg_allocz(sizeof(struct rt_show_data));
|
||||
init_list(&($$->tables));
|
||||
$$->filter = FILTER_ACCEPT;
|
||||
$$->running_on_config = config;
|
||||
$$->running_on_config = this_cli->main_config;
|
||||
$$->cli = this_cli;
|
||||
$$->tf_route = this_cli->main_config->tf_route;
|
||||
}
|
||||
| r_args net_any {
|
||||
$$ = $1;
|
||||
@ -766,7 +767,7 @@ r_args:
|
||||
| r_args TABLE ALL {
|
||||
struct rtable_config *t;
|
||||
$$ = $1;
|
||||
WALK_LIST(t, config->tables)
|
||||
WALK_LIST(t, this_cli->main_config->tables)
|
||||
rt_show_add_table($$, t->table);
|
||||
$$->tables_defined_by = RSD_TDB_ALL;
|
||||
}
|
||||
@ -934,6 +935,7 @@ CF_CLI_OPT(SHOW SYMBOLS TEMPLATE)
|
||||
sym_args:
|
||||
/* empty */ {
|
||||
$$ = cfg_allocz(sizeof(struct sym_show_data));
|
||||
$$->config = this_cli->main_config;
|
||||
}
|
||||
| sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
|
||||
| sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
|
||||
|
@ -147,7 +147,7 @@ mpls_channel_end: { mpls_channel_postconfig(this_channel); } channel_end;
|
||||
show_mpls_ranges_args:
|
||||
/* empty */
|
||||
{
|
||||
if (EMPTY_LIST(config->mpls_domains))
|
||||
if (EMPTY_LIST(this_cli->main_config->mpls_domains))
|
||||
cf_error("No MPLS domain defined");
|
||||
|
||||
$$ = cfg_allocz(sizeof(struct mpls_show_ranges_cmd));
|
||||
@ -180,7 +180,7 @@ show_mpls_ranges_args:
|
||||
if ($$->range)
|
||||
cf_error("Only one MPLS label range expected");
|
||||
|
||||
$$->domain = $$->domain ?: cf_default_mpls_domain(config);
|
||||
$$->domain = $$->domain ?: cf_default_mpls_domain(this_cli->main_config);
|
||||
$$->range = $$->domain->static_range;
|
||||
}
|
||||
| show_mpls_ranges_args DYNAMIC
|
||||
@ -188,7 +188,7 @@ show_mpls_ranges_args:
|
||||
if ($$->range)
|
||||
cf_error("Only one MPLS label range expected");
|
||||
|
||||
$$->domain = $$->domain ?: cf_default_mpls_domain(config);
|
||||
$$->domain = $$->domain ?: cf_default_mpls_domain(this_cli->main_config);
|
||||
$$->range = $$->domain->dynamic_range;
|
||||
}
|
||||
;
|
||||
|
@ -789,6 +789,7 @@ struct rt_show_data {
|
||||
struct rt_show_data_rtable *tab; /* Iterator over table list */
|
||||
struct rt_show_data_rtable *last_table; /* Last table in output */
|
||||
int verbose, tables_defined_by;
|
||||
struct timeformat tf_route;
|
||||
const struct filter *filter;
|
||||
struct proto *show_protocol;
|
||||
struct proto *export_protocol;
|
||||
|
@ -50,7 +50,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
|
||||
int dest = nhad ? (NEXTHOP_IS_REACHABLE(nhad) ? RTD_UNICAST : nhad->dest) : RTD_NONE;
|
||||
int flowspec_valid = net_is_flow(e->net) ? rt_get_flowspec_valid(e) : FLOWSPEC_UNKNOWN;
|
||||
|
||||
tm_format_time(tm, &config->tf_route, e->lastmod);
|
||||
tm_format_time(tm, &d->tf_route, e->lastmod);
|
||||
ip_addr a_from = ea_get_ip(a, &ea_gen_from, IPA_NONE);
|
||||
if (ipa_nonzero(a_from) && (!nhad || !ipa_equal(a_from, nhad->nh.gw)))
|
||||
bsprintf(from, " from %I", a_from);
|
||||
@ -260,7 +260,7 @@ rt_show_cont(struct cli *c)
|
||||
{
|
||||
struct rt_show_data *d = c->rover;
|
||||
|
||||
if (d->running_on_config && (d->running_on_config != config))
|
||||
if (OBSREF_GET(d->running_on_config) != OBSREF_GET(config))
|
||||
{
|
||||
cli_printf(c, 8004, "Stopped due to reconfiguration");
|
||||
return rt_show_done(d);
|
||||
@ -376,9 +376,10 @@ rt_show_get_default_tables(struct rt_show_data *d)
|
||||
return;
|
||||
}
|
||||
|
||||
struct symbol **def_tables = d->cli->main_config->def_tables;
|
||||
for (int i=1; i<NET_MAX; i++)
|
||||
if (config->def_tables[i] && config->def_tables[i]->table && config->def_tables[i]->table->table)
|
||||
rt_show_add_table(d, config->def_tables[i]->table->table);
|
||||
if (def_tables[i] && def_tables[i]->table && def_tables[i]->table->table)
|
||||
rt_show_add_table(d, def_tables[i]->table->table);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -431,7 +432,7 @@ rt_show_prepare_tables(struct rt_show_data *d)
|
||||
.addr = d->addr,
|
||||
.mode = d->addr_mode,
|
||||
},
|
||||
.trace_routes = config->show_route_debug,
|
||||
.trace_routes = d->cli->main_config->show_route_debug,
|
||||
};
|
||||
|
||||
rt_feeder_subscribe(ex, &tab->req);
|
||||
|
Loading…
Reference in New Issue
Block a user