]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
rt-show.c: fixed OBSREF_SET after cf_error(), changed message when 'show route export... rt_show_fixup
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Tue, 19 Nov 2024 09:33:49 +0000 (10:33 +0100)
committerKaterina Kubecova <katerina.kubecova@nic.cz>
Tue, 19 Nov 2024 09:33:49 +0000 (10:33 +0100)
nest/cli.c
nest/config.Y
nest/rt-show.c

index 24535e3f740a34e257890c7bdefb069d4cbd6970..e40ae1d971f2975fc27f84416b460f3b8f5ae25f 100644 (file)
@@ -267,6 +267,8 @@ cli_event(void *data)
 
   if (c->tx_pos)
     cli_write_trigger(c);
+  else
+    ev_schedule(c->event);
 }
 
 cli *
index a0a10daf43c54d2bc012f5bfe97976568a826faf..ad4c0793023fca50cd62dda51d64703b6eee1d95 100644 (file)
@@ -734,7 +734,6 @@ r_args:
      $$ = cfg_allocz(sizeof(struct rt_show_data));
      init_list(&($$->tables));
      $$->filter = FILTER_ACCEPT;
-     OBSREF_SET($$->running_on_config, this_cli->main_config);
      $$->cli = this_cli;
      $$->tf_route = this_cli->main_config->tf_route;
    }
index 2bed1afcb80e57efc9e280a99d20c3793c9f58ed..4d83668dc8ec831005e2187754ee52f1e56ab80f 100644 (file)
@@ -361,14 +361,25 @@ rt_show_get_default_tables(struct rt_show_data *d)
 
   if (d->export_protocol)
   {
+    int only_static = 1; // if all seen tabs were from static protocol(s), used to error message if no export tabs found
+    int tab_found = 0;
     WALK_LIST(c, d->export_protocol->channels)
     {
+      tab_found = 1;
       if (rt_export_get_state(&c->out_req) == TES_DOWN)
-       continue;
-
+      {
+        if (c->proto->proto != &proto_static)
+          only_static = 0;
+        continue;
+      }
+      only_static = 0;
       tab = rt_show_add_table(d, c->table);
       tab->export_channel = c;
     }
+    if (only_static && tab_found){
+      cf_error("'show route export' command makes no sence with static protocols.");
+      return;
+    }
     return;
   }
 
@@ -410,8 +421,8 @@ rt_show_prepare_tables(struct rt_show_data *d)
 
       if (!tab->export_channel)
       {
-       if (d->tables_defined_by & RSD_TDB_NMN)
-         cf_error("No export channel for table %s", tab->name);
+        if (d->tables_defined_by & RSD_TDB_NMN)
+          cf_error("No export channel for table %s", tab->name);
 
        rem_node(&(tab->n));
        continue;
@@ -422,7 +433,7 @@ rt_show_prepare_tables(struct rt_show_data *d)
     if (d->addr && (ex->net_type != d->addr->type))
     {
       if (d->tables_defined_by & RSD_TDB_NMN)
-       cf_error("Incompatible type of prefix/ip for table %s", tab->name);
+        cf_error("Incompatible type of prefix/ip for table %s", tab->name);
 
       rem_node(&(tab->n));
       continue;
@@ -460,6 +471,11 @@ rt_show(struct rt_show_data *d)
 
   d->tab = HEAD(d->tables);
 
+  /* OBSREF_SET should not be called sooner than the last cf_error() may occur.
+     If cf_error() called after OBSREF_SET, the crreated obstacle may not be removed at all.
+     (cf_error() contains long jump.) */
+  OBSREF_SET(d->running_on_config, this_cli->main_config);
+
   this_cli->cleanup = rt_show_cleanup;
   this_cli->rover = d;
   this_cli->cont = rt_show_cont;