]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed minor bugs in handling some route attributes
authorMaria Matejka <mq@ucw.cz>
Mon, 27 Jun 2022 09:04:57 +0000 (11:04 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 27 Jun 2022 10:32:47 +0000 (12:32 +0200)
filter/config.Y
filter/f-inst.c
nest/rt-attr.c

index ca79259338b6de78ec9b52568bf747f00cf2cc35..8cecf9361442be23b36ce5e5c1c5d9f7908553ed 100644 (file)
@@ -27,6 +27,9 @@ static inline u32 pair_b(u32 p) { return p & 0xFFFF; }
     cf_error("Can't empty %s: not an attribute", sym->name); \
   f_generate_complex(fi_code, sym->attribute, arg); \
 })
+
+#define f_generate_complex_default(fi_code, da, arg, def) \
+  f_new_inst(FI_EA_SET, f_new_inst(fi_code, f_new_inst(FI_DEFAULT, f_new_inst(FI_EA_GET, da), f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = def })), arg), da)
   
 
 /*
@@ -902,10 +905,10 @@ cmd:
    }
  | attr_bit '=' term ';' {
      $$ = f_new_inst(FI_CONDITION, $3,
-       f_generate_complex(FI_BITOR, $1.class,
-             f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)})),
-       f_generate_complex(FI_BITAND, $1.class,
-             f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}))
+       f_generate_complex_default(FI_BITOR, $1.class,
+             f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)}), 0),
+       f_generate_complex_default(FI_BITAND, $1.class,
+             f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}), 0)
      );
    }
  | break_command print_list ';' {
index 9ff5f79ab29f23ee4205993cdaee80b70573bf5c..e7b642abfff422fbaac59dbcfec6ad846851bd3f 100644 (file)
     ea_unset_attr(fs->eattrs, 1, da);
   }
 
+  INST(FI_DEFAULT, 2, 1) {
+    ARG_ANY(1);
+    ARG_ANY(2);
+
+    log(L_INFO "Type of arg 1 is: %d", v1.type);
+
+    if (v1.type == T_VOID)
+      RESULT_VAL(v2);
+    else
+      RESULT_VAL(v1);
+  }
+
   INST(FI_LENGTH, 1, 1) {      /* Get length of */
     ARG_ANY(1);
     switch(v1.type) {
index ed3aaf01288a5df4aecb5cd62b3c8edc446202f1..cec1d7cfdd72983ddd831bb0f09934beeb964705 100644 (file)
@@ -836,7 +836,7 @@ ea_normalize(ea_list *e, int overlay)
   ea_merge(e, t, overlay);
   ea_sort(t);
 
-  return t->count ? t : NULL;
+  return t->count ? t : t->next;
 }
 
 /**
@@ -1075,11 +1075,6 @@ ea_show(struct cli *c, const eattr *e)
   struct ea_class *cls = ea_class_global[e->id];
   ASSERT_DIE(cls);
 
-  pos += bsprintf(pos, "%s", cls->name);
-
-  *pos++ = ':';
-  *pos++ = ' ';
-
   if (e->undef)
     return;
   else if (cls->format)
@@ -1115,7 +1110,7 @@ ea_show(struct cli *c, const eattr *e)
          bsprintf(pos, "<type %02x>", e->type);
       }
 
-  cli_printf(c, -1012, "\t%s", buf);
+  cli_printf(c, -1012, "\t%s: %s", cls->name, buf);
 }
 
 static void