From: Maria Matejka Date: Thu, 13 Jun 2024 14:58:41 +0000 (+0200) Subject: CLI: Show symbols, route and mpls explicitly passes the actual config to the show... X-Git-Tag: v3.0.0~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73ad0e2dcb88647b9b3d3240fa87ac081de6ae44;p=thirdparty%2Fbird.git CLI: Show symbols, route and mpls explicitly passes the actual config to the show function --- diff --git a/nest/cmds.c b/nest/cmds.c index de65e9d5e..6f8796350 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -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)) diff --git a/nest/cmds.h b/nest/cmds.h index 194a9d7ff..f0bcb38e1 100644 --- a/nest/cmds.h +++ b/nest/cmds.h @@ -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; diff --git a/nest/config.Y b/nest/config.Y index cabfaf8e4..24e96a037 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -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; } diff --git a/nest/mpls.Y b/nest/mpls.Y index 286c0a569..43332e03c 100644 --- a/nest/mpls.Y +++ b/nest/mpls.Y @@ -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; } ; diff --git a/nest/route.h b/nest/route.h index 54763c624..12edf1a59 100644 --- a/nest/route.h +++ b/nest/route.h @@ -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; diff --git a/nest/rt-show.c b/nest/rt-show.c index b5141068c..ef1363714 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -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; idef_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);