]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter refactoring: Drop the roa check specific f_inst
authorMaria Matejka <mq@ucw.cz>
Thu, 20 Dec 2018 15:07:59 +0000 (16:07 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 20 Feb 2019 21:30:54 +0000 (22:30 +0100)
filter/f-inst.c
filter/f-util.c
filter/filter.c
filter/filter.h

index fb2f043cb0444dad01ef10dfa4624b6656192727..37de2a1e27ef5dff08c334dc8c83a48dfe260b4e 100644 (file)
       as_path_get_last(e->u.ptr, &as);
     }
 
-    struct rtable *table = ((struct f_inst_roa_check *) what)->rtc->table;
+    struct rtable *table = what->a[2].rtc->table;
     if (!table)
       runtime("Missing ROA table");
 
index d7678fa13b62044375703a6408d5409abacab232..11a5e97e274fc8c4745f7c14292e841aed74d2a6 100644 (file)
@@ -66,18 +66,16 @@ f_generate_complex(int operation, int operation_aux, struct f_dynamic_attr da, s
 struct f_inst *
 f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn)
 {
-  struct f_inst_roa_check *ret = cfg_allocz(sizeof(struct f_inst_roa_check));
-  ret->i.fi_code = FI_ROA_CHECK;
-  ret->i.lineno = ifs->lino;
-  ret->i.arg1 = prefix;
-  ret->i.arg2 = asn;
+  struct f_inst *ret = f_new_inst(FI_ROA_CHECK);
+  ret->arg1 = prefix;
+  ret->arg2 = asn;
   /* prefix == NULL <-> asn == NULL */
 
   if (table->addr_type != NET_ROA4 && table->addr_type != NET_ROA6)
     cf_error("%s is not a ROA table", table->name);
-  ret->rtc = table;
+  ret->arg3 = table;
 
-  return &ret->i;
+  return ret;
 }
 
 static const char * const f_instruction_name_str[] = {
index c54bedea91727122eb8aaa0ff29dfb3e5f0ed49d..c2184f0bd4f09e64f22968869233b2f91a57ea24 100644 (file)
@@ -826,9 +826,9 @@ i_same(struct f_inst *f1, struct f_inst *f2)
   case FI_AS_PATH_LAST_NAG: ONEARG; break;
   case FI_ROA_CHECK:
     TWOARGS;
-    /* Does not really make sense - ROA check results may change anyway */
-    if (strcmp(((struct f_inst_roa_check *) f1)->rtc->name,
-              ((struct f_inst_roa_check *) f2)->rtc->name))
+    /* FIXME: ROA check results may change anyway */
+    if (strcmp(f1->a[2].rtc->name,
+              f2->a[2].rtc->name))
       return 0;
     break;
   case FI_FORMAT: ONEARG; break;
index e483d223cf7d81e27c1f5a86ca1590d3424b1290..06e87a8f321b46bdc87f961c8dd347146c6eeeba 100644 (file)
@@ -124,6 +124,7 @@ struct f_inst {             /* Instruction */
     union {
       uint i;
       void *p;
+      struct rtable_config *rtc;
     } a[3];            /* The three arguments */
     struct f_val val;  /* The value if FI_CONSTANT */
   };
@@ -134,11 +135,6 @@ struct f_inst {            /* Instruction */
 #define arg2 a[1].p
 #define arg3 a[2].p
 
-/* Not enough fields in f_inst for three args used by roa_check() */
-struct f_inst_roa_check {
-  struct f_inst i;
-  struct rtable_config *rtc;
-};
 struct filter {
   char *name;
   struct f_inst *root;