]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
TMP mq-trying-to-merge-stats
authorMaria Matejka <mq@ucw.cz>
Sun, 2 Jul 2023 14:09:33 +0000 (16:09 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 26 Sep 2023 08:42:28 +0000 (10:42 +0200)
conf/conf.h
filter/config.Y
filter/f-inst.c
filter/f-inst.h
nest/rt.h

index b6d1598f9a62e43f2d180ca468bcc7e5a230e6c0..43d6ee813bd599b1609a5774910575753498f48d 100644 (file)
@@ -163,6 +163,7 @@ struct bytestring {
 #define SYM_FILTER 4
 #define SYM_TABLE 5
 #define SYM_ATTRIBUTE 6
+#define SYM_VOLATILE 7
 
 #define SYM_VARIABLE 0x100     /* 0x100-0x1ff are variable types */
 #define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
index e590da578b81a3d783414c7b605beac12e1bb104..6dc218b9a7a41bf1ee16dfb1f736c53974aa9e73 100644 (file)
@@ -12,6 +12,7 @@ CF_HDR
 
 #include "filter/f-inst.h"
 #include "filter/data.h"
+#include "nest/volatile.h"
 
 CF_DEFINES
 
@@ -366,16 +367,35 @@ conf: definition ;
 definition:
    DEFINE symbol '=' term ';' {
      struct f_line *line = f_linearize($4, 1);
+     int volat = 0;
      struct filter_iterator fit;
-     FILTER_ITERATE_INIT(&fit, 
-     if 
-
-     struct f_val val;
-     if (f_eval(, &val) > F_RETURN) cf_error("Runtime error");
-     cf_define_symbol($2, SYM_CONSTANT | val.type, val, lp_val_copy(cfg_mem, &val));
+     FILTER_ITERATE_INIT(&fit, line, new_config->pool);
+     FILTER_ITERATE(&fit, fi)
+     {
+       switch (fi->fi_code)
+       {
+        case FI_VOLATILE_ROUTE_COUNTER:
+        case FI_VOLATILE_TERM:
+          volat = 1;
+          break;
+        default:
+          break;
+       }
+     }
+     FILTER_ITERATE_END;
+     FILTER_ITERATE_CLEANUP(&fit);
+
+     if (volat)
+       cf_define_symbol($2, SYM_VOLATILE, volat, f_volatile_term(line));
+     else
+     {
+       struct f_val val;
+       if (f_eval(line, &val) > F_RETURN) cf_error("Runtime error");
+       cf_define_symbol($2, SYM_CONSTANT | val.type, val, lp_val_copy(cfg_mem, &val));
+     }
    }
  | DEFINE symbol '=' COUNT ROUTE r_args ';' {
-     cf_define_symbol($2, SYM_VOLATILE, volat, f_volatile_counter($6));
+     cf_define_symbol($2, SYM_VOLATILE, volat, rt_volatile_route_counter($6));
    }
  ;
 
@@ -820,12 +840,9 @@ symbol_value: symbol_known
       case SYM_ATTRIBUTE:
        $$ = f_new_inst(FI_EA_GET, $1->attribute);
        break;
-      case SYM_COUNTER:
-       $$ = f_new_inst(FI_COUNTER, $1);
-       break;
-      case SYM_COUNTER_TERM:
-       $$ = f_new_inst(FI_COUNTER_TERM, $1);
-       break;
+      case SYM_VOLATILE:
+        $$ = f_copy_inst($1->volat->inst);
+        break;
       default:
        cf_error("Can't get value of symbol %s", $1->name);
     }
index ba202507d8929477621fb64e2024856124e2549f..32d3c053f6a00e40bbef9fd20e83d3b83e70b34e 100644 (file)
     RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
   }
 
-  INST(FI_COUNTER, 0, 1) {
-    SYMBOL;
+  INST(FI_VOLATILE_ROUTE_COUNTER, 0, 1) {
+    FID_MEMBER(struct volatile_route_counter_config *, vrcc, vrcc->vc.sym->flags & SYM_FLAG_SAME, "count route %p", item->vrcc);
+
     NEVER_CONSTANT;
-    RESULT(T_INT, i, stats_get_counter(sym));
+    RESULT(T_INT, i, vrcc->counter_pub);
   }
 
-  INST(FI_COUNTER_TERM, 0, 1) {
+  INST(FI_VOLATILE_TERM, 0, 1) {
     SYMBOL;
     NEVER_CONSTANT;
 
index 44516174776efb2adc196dab3349da32b4fd474d..52e2b8aed533700b2417f7448d1f4d37f72df3e8 100644 (file)
@@ -29,6 +29,15 @@ enum f_instruction_flags {
 #include "filter/inst-gen.h"
 
 #define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
+static inline struct f_inst *
+f_copy_inst(struct f_inst *i)
+{
+  ASSERT_DIE(i->next == NULL);
+  struct f_inst *ii = tmp_allocz(sizeof *ii);
+  memcpy(ii, i, sizeof *ii);
+  ii->lineno = ifs->lino;
+  return ii;
+}
 
 /* Convert the instruction back to the enum name */
 const char *f_instruction_name_(enum f_instruction_code fi);
@@ -94,6 +103,8 @@ void f_add_lines(const struct f_line_item *what, struct filter_iterator *fit);
 
 
 struct filter *f_new_where(struct f_inst *);
+struct volatile_config *f_volatile_term(const struct f_line *);
+
 static inline struct f_static_attr f_new_static_attr(btype type, int code, int readonly)
 { return (struct f_static_attr) { .type = type, .sa_code = code, .readonly = readonly }; }
 struct f_inst *f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn);
index 796940168283fe4133a8dd37c419860a195947d5..839250e7ab4ef9c69c5c2607049d90d7a01044d3 100644 (file)
--- a/nest/rt.h
+++ b/nest/rt.h
@@ -666,6 +666,8 @@ void rt_show(struct rt_show_data *);
 struct rt_show_data_rtable * rt_show_add_exporter(struct rt_show_data *d, struct rt_exporter *t, const char *name);
 struct rt_show_data_rtable * rt_show_add_table(struct rt_show_data *d, rtable *t);
 
+struct volatile_config *rt_volatile_route_counter(struct rt_show_data *);
+
 /* Value of table definition mode in struct rt_show_data */
 #define RSD_TDB_DEFAULT          0             /* no table specified */
 #define RSD_TDB_INDIRECT  0            /* show route ... protocol P ... */