]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Flowspec: Label field should use numeric operator and not bitmask operator
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 18 May 2021 18:18:06 +0000 (20:18 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 18 May 2021 18:23:08 +0000 (20:23 +0200)
conf/flowspec.Y
filter/test.conf
lib/flowspec.c
lib/flowspec_test.c

index 4d25976374e5dc3fc3a5a8795c8252d739e371a6..56a7c5dcadea1db6f922ca31cfd86a8ef6662927 100644 (file)
@@ -59,12 +59,12 @@ flow_num_type_:
  | ICMP CODE   { $$ = FLOW_TYPE_ICMP_CODE; }
  | LENGTH      { $$ = FLOW_TYPE_PACKET_LENGTH; }
  | DSCP                { $$ = FLOW_TYPE_DSCP; }
+ | LABEL       { $$ = FLOW_TYPE_LABEL; }
  ;
 
 flow_num_type: flow_num_type_{ flow_builder_set_type(this_flow, $1); };
 flow_flag_type: TCP FLAGS    { flow_builder_set_type(this_flow, FLOW_TYPE_TCP_FLAGS); };
 flow_frag_type: FRAGMENT     { flow_builder_set_type(this_flow, FLOW_TYPE_FRAGMENT); };
-flow_label_type: LABEL       { flow_builder_set_type(this_flow, FLOW_TYPE_LABEL); };
 
 flow_srcdst:
    DST         { $$ = FLOW_TYPE_DST_PREFIX; }
@@ -165,7 +165,6 @@ flow6_item:
  | flow_num_type flow_num_opts
  | flow_flag_type flow_bmk_opts
  | flow_frag_type flow_frag_opts
- | flow_label_type flow_bmk_opts
  ;
 
 flow4_opts:
index 653bb82ff8be82779066ad76bcbb8f0025292836..3a8804a1554f20e5c027b86f4ad4813796bb9bea 100644 (file)
@@ -583,6 +583,7 @@ prefix p;
        bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }");
        bt_assert(format(flow6 { dscp = 63; }) = "flow6 { dscp 63; }");
        bt_assert(format(flow6 { fragment is_fragment || !first_fragment; }) = "flow6 { fragment is_fragment || !first_fragment; }");
+       bt_assert(format(flow6 { label 1000..2000; }) = "flow6 { label 1000..2000; }");
        bt_assert(format(flow6 { }) = "flow6 { }");
 }
 
index 1445435a5c8e021fa65ec9841e68f519e34a6127..14b42b52887981d85ad265f42e4d00ea950a38db 100644 (file)
@@ -1351,11 +1351,11 @@ net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
     case FLOW_TYPE_ICMP_CODE:
     case FLOW_TYPE_PACKET_LENGTH:
     case FLOW_TYPE_DSCP:
+    case FLOW_TYPE_LABEL:
       net_format_flow_num(&b, part);
       break;
     case FLOW_TYPE_TCP_FLAGS:
     case FLOW_TYPE_FRAGMENT:
-    case FLOW_TYPE_LABEL:
       net_format_flow_bitmask(&b, part);
       break;
     }
index 2285075c5335ffbd058137386e7426557c7e64b8..ed4afe515af012cb4a766496aa603bfa5cf6c2a5 100644 (file)
@@ -650,14 +650,14 @@ t_formatting6(void)
     FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0,
     FLOW_TYPE_NEXT_HEADER, 0x81, 0x06,
     FLOW_TYPE_PORT, 0x03, 20, 0x45, 40, 0x91, 0x01, 0x11,
-    FLOW_TYPE_LABEL, 0xa0, 0x12, 0x34, 0x56, 0x78,
+    FLOW_TYPE_LABEL, 0xa4, 0x00, 0x07, 0xa1, 0x20,
   };
   *nlri = (u8) sizeof(nlri);
 
   net_addr_flow6 *input;
   NET_ADDR_FLOW6_(input, ip6_build(0, 1, 0x12345678, 0x98000000), 103, nlri);
 
-  const char *expect = "flow6 { dst ::1:1234:5678:9800:0/103 offset 61; src c000::/8; next header 6; port 20..40,273; label !0x0/0x12345678; }";
+  const char *expect = "flow6 { dst ::1:1234:5678:9800:0/103 offset 61; src c000::/8; next header 6; port 20..40,273; label < 500000; }";
 
   bt_assert(flow6_net_format(b, sizeof(b), input) == strlen(expect));
   bt_debug(" expect: '%s',\n output: '%s'\n", expect, b);