diff --git a/gtests/net/packetdrill/lexer.l b/gtests/net/packetdrill/lexer.l index 0a33a0eb066007977d070c29ca04ba954b079f26..0e01501d8309c1b34b5031ae3a510fe85af9b503 100644 --- a/gtests/net/packetdrill/lexer.l +++ b/gtests/net/packetdrill/lexer.l @@ -599,6 +599,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..51f919647c3d4aa9913e607ef33c4dbe6788ebb0 100644 --- a/gtests/net/packetdrill/packet_to_string_test.c +++ b/gtests/net/packetdrill/packet_to_string_test.c @@ -138,6 +138,7 @@ 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, @@ -275,6 +276,7 @@ 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=...]]; " "INIT_ACK[flgs=0x00, tag=1, a_rwnd=65536, os=15, is=15, tsn=16909060, " diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y index e78a2a866e6038cc6dec7186b4a3991915a1246b..1b8e3ea86ea0133c80dd970673183e48d51b1628 100644 --- a/gtests/net/packetdrill/parser.y +++ b/gtests/net/packetdrill/parser.y @@ -526,7 +526,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 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 @@ -690,6 +690,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 @@ -1897,6 +1898,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; } @@ -2060,6 +2062,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 7ae514f78c77d5bf7c4beb8ced884bd215e1d594..440069842ce2432020f0db7af81148f70fd429dc 100644 --- a/gtests/net/packetdrill/sctp.h +++ b/gtests/net/packetdrill/sctp.h @@ -274,6 +274,7 @@ struct sctp_forward_tsn_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 @@ -408,6 +409,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 5ef8e002c213442b32b6d6ae63c979f602d2a0e8..2cb43820a0a4669f20cfe448500ee3c3dfbdcf61 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, @@ -600,6 +617,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 eb75c3a0763017d122920d2fea48af7123e346dc..1ffe7182d188fc44a1881726656c0d5832adbce0 100644 --- a/gtests/net/packetdrill/sctp_packet.c +++ b/gtests/net/packetdrill/sctp_packet.c @@ -2193,6 +2193,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 b9e4e2e87557a0d91b171df58e90145480fe1c47..137a4de244fcb1effe6c1154f77d49d4a0af33ef 100644 --- a/gtests/net/packetdrill/sctp_packet.h +++ b/gtests/net/packetdrill/sctp_packet.h @@ -396,6 +396,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