diff --git a/conf/flowspec.Y b/conf/flowspec.Y index 4d259763..56a7c5dc 100644 --- a/conf/flowspec.Y +++ b/conf/flowspec.Y @@ -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: diff --git a/filter/test.conf b/filter/test.conf index 653bb82f..3a8804a1 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -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 { }"); } diff --git a/lib/flowspec.c b/lib/flowspec.c index 1445435a..14b42b52 100644 --- a/lib/flowspec.c +++ b/lib/flowspec.c @@ -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; } diff --git a/lib/flowspec_test.c b/lib/flowspec_test.c index 2285075c..ed4afe51 100644 --- a/lib/flowspec_test.c +++ b/lib/flowspec_test.c @@ -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);