]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CLI: Show symbols, route and mpls explicitly passes the actual config to the show...
authorMaria Matejka <mq@ucw.cz>
Thu, 13 Jun 2024 14:58:41 +0000 (16:58 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 14 Jun 2024 21:16:07 +0000 (23:16 +0200)
nest/cmds.c
nest/cmds.h
nest/config.Y
nest/mpls.Y
nest/route.h
nest/rt-show.c

index de65e9d5e08b69755f507e1bd96c13e9032425b3..6f8796350461f3992d73710b55c93e91b1b2703e 100644 (file)
@@ -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))
index 194a9d7ffe49841372628bac9b08a6876f36c61e..f0bcb38e18bc6310c24c897db98b3e67ac933888 100644 (file)
@@ -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;
index cabfaf8e47984d7a0729bd58bf750cbd4cf8fabf..24e96a037ec94d31d75b0eb2fc36f19a2a38ddf6 100644 (file)
@@ -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; }
index 286c0a569f9212fe950cc1f0d693c07526eece6b..43332e03c35f4296467fb7bdf1808456ae704d5d 100644 (file)
@@ -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;
    }
  ;
index 54763c624e3c6361ddfa234ebd6f6aaf226b8b70..12edf1a59445d3c466c5315cc397c8136d6da759 100644 (file)
@@ -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;
index b5141068ce7cb2ab49d86a58866f7f438e35cf43..ef1363714a05e5b4051aa3290b570901a8c1dc0c 100644 (file)
@@ -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);