diff --git a/gtests/net/packetdrill/lexer.l b/gtests/net/packetdrill/lexer.l index 62768487d893bba39e75c24f18f736bc1ea12259..c50570dec2359f2a6c25788a34e70c0124c6a05c 100644 --- a/gtests/net/packetdrill/lexer.l +++ b/gtests/net/packetdrill/lexer.l @@ -600,6 +600,7 @@ HOSTNAME_ADDRESS return HOSTNAME_ADDRESS; SUPPORTED_ADDRESS_TYPES return SUPPORTED_ADDRESS_TYPES; ADAPTATION_INDICATION return ADAPTATION_INDICATION; ECN_CAPABLE return ECN_CAPABLE; +FORWARD_TSN_SUPPORTED return FORWARD_TSN_SUPPORTED; SUPPORTED_EXTENSIONS return SUPPORTED_EXTENSIONS; addr return ADDR; incr return INCR; diff --git a/gtests/net/packetdrill/packet_to_string_test.c b/gtests/net/packetdrill/packet_to_string_test.c index 88f289c8c8196fc04b5631e67d9dafb023967bc2..c2414a393541f08603e347cda0c945b2fa037b67 100644 --- a/gtests/net/packetdrill/packet_to_string_test.c +++ b/gtests/net/packetdrill/packet_to_string_test.c @@ -110,7 +110,7 @@ static void test_sctp_ipv6_packet_to_string(void) /* SCTP Common Header: */ 0x04, 0xd2, 0x1f, 0x90, 0x01, 0x02, 0x03, 0x04, - 0x24, 0x25, 0x51, 0x31, + 0x6b, 0x44, 0x25, 0xe5, /* SCTP DATA Chunk */ 0x00, 0x0f, 0x00, 0x13, 0x01, 0x02, 0x03, 0x04, @@ -138,10 +138,10 @@ static void test_sctp_ipv6_packet_to_string(void) 0x00, 0x05, 0x00, 0x06, 0x00, 0x0b, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, + 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, - 0x80, 0x05, 0x00, 0x10, - 0x50, 0x50, 0x50, 0x50, + 0x80, 0x05, 0x00, 0x0c, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, /* SCTP INIT_ACK Chunk */ @@ -275,8 +275,9 @@ static void test_sctp_ipv6_packet_to_string(void) "HOSTNAME_ADDRESS[addr=\"@A\"], " "SUPPORTED_ADDRESS_TYPES[types=[IPv4, IPv6, HOSTNAME]], " "ECN_CAPABLE[], " + "FORWARD_TSN_SUPPORTED[], " "SUPPORTED_EXTENSIONS[types=[I-DATA]], " - "PAD[len=16, val=...]]; " + "PAD[len=12, val=...]]; " "INIT_ACK[flgs=0x00, tag=1, a_rwnd=65536, os=15, is=15, tsn=16909060, " "STATE_COOKIE[len=7, val=...], " "UNRECOGNIZED_PARAMETER[params=[" @@ -333,8 +334,9 @@ static void test_sctp_ipv6_packet_to_string(void) "HOSTNAME_ADDRESS[addr=\"@A\"], " "SUPPORTED_ADDRESS_TYPES[types=[IPv4, IPv6, HOSTNAME]], " "ECN_CAPABLE[], " + "FORWARD_TSN_SUPPORTED[], " "SUPPORTED_EXTENSIONS[types=[I-DATA]], " - "PAD[len=16, val=...]]; " + "PAD[len=12, val=...]]; " "INIT_ACK[flgs=0x00, tag=1, a_rwnd=65536, os=15, is=15, tsn=16909060, " "STATE_COOKIE[len=7, val=...], " "UNRECOGNIZED_PARAMETER[params=[" @@ -391,8 +393,9 @@ static void test_sctp_ipv6_packet_to_string(void) "HOSTNAME_ADDRESS[addr=\"@A\"], " "SUPPORTED_ADDRESS_TYPES[types=[IPv4, IPv6, HOSTNAME]], " "ECN_CAPABLE[], " + "FORWARD_TSN_SUPPORTED[], " "SUPPORTED_EXTENSIONS[types=[I-DATA]], " - "PAD[len=16, val=...]]; " + "PAD[len=12, val=...]]; " "INIT_ACK[flgs=0x00, tag=1, a_rwnd=65536, os=15, is=15, tsn=16909060, " "STATE_COOKIE[len=7, val=...], " "UNRECOGNIZED_PARAMETER[params=[" @@ -434,14 +437,14 @@ static void test_sctp_ipv6_packet_to_string(void) "0x0000: 60 00 00 00 01 d8 84 ff 00 02 00 00 00 00 00 00 " "\n" "0x0010: 00 00 00 00 00 00 22 22 00 01 00 00 00 00 00 00 " "\n" "0x0020: 00 00 00 00 00 00 11 11 04 d2 1f 90 01 02 03 04 " "\n" - "0x0030: 24 25 51 31 00 0f 00 13 01 02 03 04 00 ff 01 00 " "\n" + "0x0030: 6b 44 25 e5 00 0f 00 13 01 02 03 04 00 ff 01 00 " "\n" "0x0040: 00 00 00 00 00 01 02 00 01 00 00 68 00 00 00 01 " "\n" "0x0050: 00 01 00 00 00 0f 00 0f 01 02 03 04 00 05 00 08 " "\n" "0x0060: 01 02 03 04 00 06 00 14 00 00 00 00 00 00 00 00 " "\n" "0x0070: 00 00 00 00 00 00 00 01 00 09 00 08 00 01 00 00 " "\n" "0x0080: 00 0b 00 06 40 41 00 00 00 0c 00 0a 00 05 00 06 " "\n" - "0x0090: 00 0b 00 00 80 00 00 04 80 08 00 05 40 00 00 00 " "\n" - "0x00a0: 80 05 00 10 50 50 50 50 50 50 50 50 50 50 50 50 " "\n" + "0x0090: 00 0b 00 00 80 00 00 04 c0 00 00 04 80 08 00 05 " "\n" + "0x00a0: 40 00 00 00 80 05 00 0c 50 50 50 50 50 50 50 50 " "\n" "0x00b0: 02 00 00 24 00 00 00 01 00 01 00 00 00 0f 00 0f " "\n" "0x00c0: 01 02 03 04 00 07 00 07 01 02 03 00 00 08 00 08 " "\n" "0x00d0: 80 01 00 04 03 00 00 20 01 02 03 04 00 01 00 00 " "\n" diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y index 398aae264e0bf380e6501a69df61960c70de6d5c..8c6979e6487371564a05cae1e97809eeeed1bb97 100644 --- a/gtests/net/packetdrill/parser.y +++ b/gtests/net/packetdrill/parser.y @@ -524,7 +524,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string, %token <reserved> TAG A_RWND OS IS TSN SID SSN MID PPID FSN CUM_TSN GAPS NR_GAPS DUPS %token <reserved> PARAMETER HEARTBEAT_INFORMATION IPV4_ADDRESS IPV6_ADDRESS %token <reserved> STATE_COOKIE UNRECOGNIZED_PARAMETER COOKIE_PRESERVATIVE -%token <reserved> HOSTNAME_ADDRESS SUPPORTED_ADDRESS_TYPES ECN_CAPABLE +%token <reserved> HOSTNAME_ADDRESS SUPPORTED_ADDRESS_TYPES ECN_CAPABLE FORWARD_TSN_SUPPORTED %token <reserved> SUPPORTED_EXTENSIONS ADAPTATION_CODE_POINT ADAPTATION_INDICATION %token <reserved> OUTGOING_SSN_RESET REQ_SN RESP_SN LAST_TSN SIDS INCOMING_SSN_RESET %token <reserved> RECONFIG_RESPONSE RESULT SENDER_NEXT_TSN RECEIVER_NEXT_TSN @@ -687,6 +687,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string, %type <parameter_list_item> sctp_hostname_address_parameter_spec %type <parameter_list_item> sctp_supported_address_types_parameter_spec %type <parameter_list_item> sctp_ecn_capable_parameter_spec +%type <parameter_list_item> sctp_fornward_tsn_supported_spec %type <parameter_list_item> sctp_supported_extensions_parameter_spec %type <parameter_list_item> sctp_adaptation_indication_parameter_spec %type <parameter_list_item> sctp_pad_parameter_spec @@ -1874,6 +1875,7 @@ sctp_parameter_spec | sctp_hostname_address_parameter_spec { $$ = $1; } | sctp_supported_address_types_parameter_spec { $$ = $1; } | sctp_ecn_capable_parameter_spec { $$ = $1; } +| sctp_fornward_tsn_supported_spec { $$ = $1; } | sctp_supported_extensions_parameter_spec { $$ = $1; } | sctp_adaptation_indication_parameter_spec { $$ = $1; } | sctp_pad_parameter_spec { $$ = $1; } @@ -2037,6 +2039,11 @@ sctp_ecn_capable_parameter_spec $$ = sctp_ecn_capable_parameter_new(); } +sctp_fornward_tsn_supported_spec +: FORWARD_TSN_SUPPORTED '[' ']' { + $$ = sctp_forward_tsn_supported_parameter_new(); +} + chunk_types_list : { $$ = sctp_byte_list_new(); diff --git a/gtests/net/packetdrill/sctp.h b/gtests/net/packetdrill/sctp.h index 54d87e8b66a71ae0343d296f4a5f1477a1504fdb..56d1447f47bc846274cf597c995eb2a412c88d6a 100644 --- a/gtests/net/packetdrill/sctp.h +++ b/gtests/net/packetdrill/sctp.h @@ -286,6 +286,7 @@ struct sctp_reconfig_chunk { #define SCTP_PAD_PARAMETER_TYPE 0x8005 #define SCTP_Set_Primary_Address 0xc004 #define SCTP_ADAPTATION_INDICATION_PARAMETER_TYPE 0xc006 +#define SCTP_FORWARD_TSN_SUPPORTED_PARAMETER_TYPE 0xc000 #define MAX_SCTP_PARAMETER_BYTES 0xffff @@ -420,6 +421,11 @@ struct sctp_reconfig_generic_request_parameter { __u8 value[]; } __packed; +struct sctp_forward_tsn_supported_parameter { + __be16 type; + __be16 length; +} __packed; + #define SCTP_INVALID_STREAM_IDENTIFIER_CAUSE_CODE 0x0001 #define SCTP_MISSING_MANDATORY_PARAMETER_CAUSE_CODE 0x0002 #define SCTP_STALE_COOKIE_ERROR_CAUSE_CODE 0x0003 diff --git a/gtests/net/packetdrill/sctp_chunk_to_string.c b/gtests/net/packetdrill/sctp_chunk_to_string.c index 049d9af3b12a945a514b59c2fc5731e400b3fb66..76bccfca3dc2262562c187776c5cfe5b97250d35 100644 --- a/gtests/net/packetdrill/sctp_chunk_to_string.c +++ b/gtests/net/packetdrill/sctp_chunk_to_string.c @@ -219,6 +219,23 @@ static int sctp_ecn_capable_parameter_to_string( return STATUS_OK; } +static int sctp_forward_tsn_supported_parameter_to_string( + FILE *s, + struct sctp_forward_tsn_supported_parameter *parameter, + char **error) +{ + u16 length; + + length = ntohs(parameter->length); + if (length != sizeof(struct sctp_forward_tsn_supported_parameter)) { + asprintf(error, "FORWARD_TSN_SUPPORTED parameter illegal (length=%u)", + length); + return STATUS_ERR; + } + fputs("FORWARD_TSN_SUPPORTED[]", s); + return STATUS_OK; +} + static int sctp_supported_extensions_parameter_to_string( FILE *s, struct sctp_supported_extensions_parameter *parameter, @@ -603,6 +620,10 @@ static int sctp_parameter_to_string(FILE *s, result = sctp_ecn_capable_parameter_to_string(s, (struct sctp_ecn_capable_parameter *)parameter, error); break; + case SCTP_FORWARD_TSN_SUPPORTED_PARAMETER_TYPE: + result = sctp_forward_tsn_supported_parameter_to_string(s, + (struct sctp_forward_tsn_supported_parameter *)parameter, error); + break; case SCTP_SUPPORTED_EXTENSIONS_PARAMETER_TYPE: result = sctp_supported_extensions_parameter_to_string(s, (struct sctp_supported_extensions_parameter *)parameter, diff --git a/gtests/net/packetdrill/sctp_packet.c b/gtests/net/packetdrill/sctp_packet.c index 2795253ce0c576479084f90441b87473b2fe98ca..9254af5f44dd503bed5f8089678a8f2c30101733 100644 --- a/gtests/net/packetdrill/sctp_packet.c +++ b/gtests/net/packetdrill/sctp_packet.c @@ -2176,6 +2176,20 @@ sctp_ecn_capable_parameter_new(void) 0); } +struct sctp_parameter_list_item * +sctp_forward_tsn_supported_parameter_new() +{ + struct sctp_forward_tsn_supported_parameter *parameter; + + parameter = malloc(sizeof(struct sctp_forward_tsn_supported_parameter)); + assert(parameter != NULL); + parameter->type = htons(SCTP_FORWARD_TSN_SUPPORTED_PARAMETER_TYPE); + parameter->length = htons(sizeof(struct sctp_forward_tsn_supported_parameter)); + return sctp_parameter_list_item_new((struct sctp_parameter *)parameter, + sizeof(struct sctp_forward_tsn_supported_parameter), + 0); +} + struct sctp_parameter_list * sctp_parameter_list_new(void) { diff --git a/gtests/net/packetdrill/sctp_packet.h b/gtests/net/packetdrill/sctp_packet.h index 9a845e0d8656920f07127fa8b154cddf923cfff0..0b1a61a47134304ab257600440bb46c67c8e4a21 100644 --- a/gtests/net/packetdrill/sctp_packet.h +++ b/gtests/net/packetdrill/sctp_packet.h @@ -376,6 +376,9 @@ sctp_supported_address_types_parameter_new(struct sctp_address_type_list *list); struct sctp_parameter_list_item * sctp_ecn_capable_parameter_new(void); +struct sctp_parameter_list_item * +sctp_forward_tsn_supported_parameter_new(); + struct sctp_parameter_list_item * sctp_pad_parameter_new(s64 len, u8 *padding); diff --git a/gtests/net/packetdrill/tests/bsd/sctp/sctp_forward-tsn-supported-parameter.pkt b/gtests/net/packetdrill/tests/bsd/sctp/sctp_forward-tsn-supported-parameter.pkt new file mode 100644 index 0000000000000000000000000000000000000000..04bb619df638b40f5dade323abcdd0a8447751e4 --- /dev/null +++ b/gtests/net/packetdrill/tests/bsd/sctp/sctp_forward-tsn-supported-parameter.pkt @@ -0,0 +1,36 @@ +#ifdef FreeBSD +// disable all extensions except PR-SCTP on FreeBSD + 0.0 `sysctl -w net.inet.sctp.ecn_enable=0` ++0.0 `sysctl -w net.inet.sctp.pr_enable=1` ++0.0 `sysctl -w net.inet.sctp.asconf_enable=0` ++0.0 `sysctl -w net.inet.sctp.auth_enable=0` ++0.0 `sysctl -w net.inet.sctp.reconfig_enable=0` ++0.0 `sysctl -w net.inet.sctp.nrsack_enable=0` ++0.0 `sysctl -w net.inet.sctp.pktdrop_enable=0` +#endif + ++0.0 socket(..., SOCK_STREAM, IPPROTO_SCTP) = 3 ++0.0 bind(3, ..., ...) = 0 ++0.0 listen(3, 1) = 0 ++0.0 < sctp: INIT[flgs=0, tag=1, a_rwnd=1500, os=1, is=1, tsn=0, + FORWARD_TSN_SUPPORTED[]] +#ifdef Linux ++0.0 > sctp: INIT_ACK[flgs=0, tag=2, a_rwnd=..., os=..., is=..., tsn=1, + STATE_COOKIE[len=..., val=...], + FORWARD_TSN_SUPPORTED[]] +#endif +#ifdef FreeBSD ++0.0 > sctp: INIT_ACK[flgs=0, tag=2, a_rwnd=..., os=..., is=..., tsn=1, + FORWARD_TSN_SUPPORTED[], + SUPPORTED_EXTENSIONS[types=[0xc0]], + STATE_COOKIE[len=..., val=...]] +#endif ++0.1 < sctp: COOKIE_ECHO[flgs=0, len=..., val=...] ++0.0 > sctp: COOKIE_ACK[flgs=0] ++0.0 accept(3, ..., ...) = 4 +// Tear down the association ++1.0 < sctp: SHUTDOWN[flgs=0, cum_tsn=0] ++0.0 > sctp: SHUTDOWN_ACK[flgs=0] ++0.0 < sctp: SHUTDOWN_COMPLETE[flgs=0] ++0.0 close(4) = 0 ++0.0 close(3) = 0