]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Add support for VPN_RD sets
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 25 Oct 2018 09:26:58 +0000 (11:26 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 25 Oct 2018 09:26:58 +0000 (11:26 +0200)
filter/config.Y
filter/test.conf

index bbb8a6405e0374b08fbdc1604dc4a7511161cdda..93ad8d8bdccba1f85328600349a3c1850cec7f6c 100644 (file)
@@ -35,6 +35,7 @@ f_valid_set_type(int type)
   case T_IP:
   case T_EC:
   case T_LC:
+  case T_RD:
     return 1;
 
   default:
@@ -492,6 +493,7 @@ type:
          case T_QUAD:
          case T_EC:
          case T_LC:
+         case T_RD:
          case T_IP:
               $$ = T_SET;
               break;
@@ -641,9 +643,10 @@ fipa:
  */
 
 set_atom:
-   NUM   { $$.type = T_INT; $$.val.i = $1; }
- | fipa  { $$ = $1; }
- | ENUM  { $$.type = pair_a($1); $$.val.i = pair_b($1); }
+   NUM    { $$.type = T_INT; $$.val.i = $1; }
+ | fipa   { $$ = $1; }
+ | VPN_RD { $$.type = T_RD; $$.val.ec = $1; }
+ | ENUM   { $$.type = pair_a($1); $$.val.i = pair_b($1); }
  | '(' term ')' {
      $$ = f_eval($2, cfg_mem);
      if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type");
index 989dab14b4dcafb4b3284688ed3331b693ebf8d1..39b349cc463ae2febbcc308405fdc59a551c9b80 100644 (file)
@@ -1005,6 +1005,59 @@ bt_test_suite(t_lclist_set, "Testing sets of large communities");
 
 
 
+/*
+ *     Testing Route Distinguishers
+ *     ----------------------------
+ */
+
+function t_rd()
+rd x;
+{
+       x = 12345:20000;
+       bt_assert(format(x) = "12345:20000");
+
+       bt_assert(x = 12345:20000);
+       bt_assert(x < 12345:20010);
+       bt_assert(x != 12346:20000);
+       bt_assert(x != 2:12345:20000);
+       bt_assert(!(x > 12345:200010));
+
+       bt_assert(format(10.0.0.1:1000) = "10.0.0.1:1000");
+       bt_assert(format(100000:20000) = "100000:20000");
+       bt_assert(format(2:100000:20000) = "100000:20000");
+       bt_assert(format(2:1000:1000) = "2:1000:1000");
+}
+
+bt_test_suite(t_rd, "Testing route distinguishers");
+
+
+
+
+/*
+ *     Testing sets of Route Distinguishers
+ *     ------------------------------------
+ */
+
+function t_rd_set()
+rd set rds;
+{
+       rds = [10:20, 100000:100..100000:200];
+       bt_assert(format(rds)  = "[10:20, 100000:100..100000:200]");
+
+       bt_assert(10:20  ~ rds);
+       bt_assert(10:21 !~ rds);
+       bt_assert(100000:90 !~ rds);
+       bt_assert(100000:100 ~ rds);
+       bt_assert(100000:128 ~ rds);
+       bt_assert(100000:200 ~ rds);
+       bt_assert(100010:150 !~ rds);
+}
+
+bt_test_suite(t_rd_set, "Testing sets of route distinguishers");
+
+
+
+
 /*
  *     Testing defined() function
  *     --------------------------