]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: CLI command to dump all the linearized filters
authorMaria Matejka <mq@jmq.cz>
Wed, 3 Jul 2019 06:13:07 +0000 (08:13 +0200)
committerMaria Matejka <mq@jmq.cz>
Wed, 3 Jul 2019 06:27:56 +0000 (08:27 +0200)
filter/filter.c
filter/filter.h
nest/config.Y

index ed0b21bc26e51ae4525eea5561855711767aed36..d9c98872ac6d27cf88d5a8b3add641cec8a32943 100644 (file)
@@ -482,3 +482,41 @@ filter_commit(struct config *new, struct config *old)
        break;
     }
 }
+
+void filters_dump_all(void)
+{
+  struct symbol *sym;
+  WALK_LIST(sym, config->symbols) {
+    switch (sym->class) {
+      case SYM_FILTER:
+       debug("Named filter %s:\n", sym->name);
+       f_dump_line(sym->filter->root, 1);
+       break;
+      case SYM_FUNCTION:
+       debug("Function %s:\n", sym->name);
+       f_dump_line(sym->function, 1);
+       break;
+      case SYM_PROTO:
+       {
+         debug("Protocol %s:\n", sym->name);
+         struct channel *c;
+         WALK_LIST(c, sym->proto->proto->channels) {
+           debug(" Channel %s (%s) IMPORT", c->name, net_label[c->net_type]);
+           if (c->in_filter == FILTER_ACCEPT)
+             debug(" ALL\n");
+           else if (c->in_filter == FILTER_REJECT)
+             debug(" NONE\n");
+           else if (c->in_filter == FILTER_UNDEF)
+             debug(" UNDEF\n");
+           else if (c->in_filter->sym) {
+             ASSERT(c->in_filter->sym->filter == c->in_filter);
+             debug(" named filter %s\n", c->in_filter->sym->name);
+           } else {
+             debug("\n");
+             f_dump_line(c->in_filter->root, 2);
+           }
+         }
+       }
+    }
+  }
+}
index 36b63e7c8d37105598292c1019fa873802f88525..9d997efbf9b9c755256d11b2a024dbe4dc39527d 100644 (file)
@@ -64,9 +64,11 @@ int f_same(const struct f_line *f1, const struct f_line *f2);
 
 void filter_commit(struct config *new, struct config *old);
 
+void filters_dump_all(void);
+
 #define FILTER_ACCEPT NULL
-#define FILTER_REJECT ((void *) 1)
-#define FILTER_UNDEF  ((void *) 2)     /* Used in BGP */
+#define FILTER_REJECT ((struct filter *) 1)
+#define FILTER_UNDEF  ((struct filter *) 2)    /* Used in BGP */
 
 #define FF_SILENT 2                    /* Silent filter execution */
 
index 430c9f29379edcfc109655875a1c834717eed869..e97b8fb37d61ed4ba4d759eb2156c0a5a70a0805 100644 (file)
@@ -731,6 +731,8 @@ CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
 { rt_dump_all(); cli_msg(0, ""); } ;
 CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
 { protos_dump_all(); cli_msg(0, ""); } ;
+CF_CLI(DUMP FILTER ALL,,, [[Dump all filters in linearized form]])
+{ filters_dump_all(); cli_msg(0, ""); } ;
 
 CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
 { cmd_eval(f_linearize($2)); } ;