Flowspec: Label field should use numeric operator and not bitmask operator

This commit is contained in:
Ondrej Zajicek (work) 2021-05-18 20:18:06 +02:00
parent dd8481cc1c
commit abc9ccc5cb
4 changed files with 5 additions and 5 deletions

View file

@ -59,12 +59,12 @@ flow_num_type_:
| ICMP CODE { $$ = FLOW_TYPE_ICMP_CODE; } | ICMP CODE { $$ = FLOW_TYPE_ICMP_CODE; }
| LENGTH { $$ = FLOW_TYPE_PACKET_LENGTH; } | LENGTH { $$ = FLOW_TYPE_PACKET_LENGTH; }
| DSCP { $$ = FLOW_TYPE_DSCP; } | DSCP { $$ = FLOW_TYPE_DSCP; }
| LABEL { $$ = FLOW_TYPE_LABEL; }
; ;
flow_num_type: flow_num_type_{ flow_builder_set_type(this_flow, $1); }; 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_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_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: flow_srcdst:
DST { $$ = FLOW_TYPE_DST_PREFIX; } DST { $$ = FLOW_TYPE_DST_PREFIX; }
@ -165,7 +165,6 @@ flow6_item:
| flow_num_type flow_num_opts | flow_num_type flow_num_opts
| flow_flag_type flow_bmk_opts | flow_flag_type flow_bmk_opts
| flow_frag_type flow_frag_opts | flow_frag_type flow_frag_opts
| flow_label_type flow_bmk_opts
; ;
flow4_opts: flow4_opts:

View file

@ -583,6 +583,7 @@ prefix p;
bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }"); bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }");
bt_assert(format(flow6 { dscp = 63; }) = "flow6 { dscp 63; }"); 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 { 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 { }"); bt_assert(format(flow6 { }) = "flow6 { }");
} }

View 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_ICMP_CODE:
case FLOW_TYPE_PACKET_LENGTH: case FLOW_TYPE_PACKET_LENGTH:
case FLOW_TYPE_DSCP: case FLOW_TYPE_DSCP:
case FLOW_TYPE_LABEL:
net_format_flow_num(&b, part); net_format_flow_num(&b, part);
break; break;
case FLOW_TYPE_TCP_FLAGS: case FLOW_TYPE_TCP_FLAGS:
case FLOW_TYPE_FRAGMENT: case FLOW_TYPE_FRAGMENT:
case FLOW_TYPE_LABEL:
net_format_flow_bitmask(&b, part); net_format_flow_bitmask(&b, part);
break; break;
} }

View file

@ -650,14 +650,14 @@ t_formatting6(void)
FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0, FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0,
FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_NEXT_HEADER, 0x81, 0x06,
FLOW_TYPE_PORT, 0x03, 20, 0x45, 40, 0x91, 0x01, 0x11, 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); *nlri = (u8) sizeof(nlri);
net_addr_flow6 *input; net_addr_flow6 *input;
NET_ADDR_FLOW6_(input, ip6_build(0, 1, 0x12345678, 0x98000000), 103, nlri); 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_assert(flow6_net_format(b, sizeof(b), input) == strlen(expect));
bt_debug(" expect: '%s',\n output: '%s'\n", expect, b); bt_debug(" expect: '%s',\n output: '%s'\n", expect, b);