From 7fed29e7c2096a3da5c8eb6c726a2f6cdc9d6355 Mon Sep 17 00:00:00 2001 From: hoelscher <jens.hoelscher@fh-muenster.de> Date: Sat, 31 Oct 2015 05:47:48 +0100 Subject: [PATCH] implement cmsg for sctp_sndrcv and sctp_init --- gtests/net/packetdrill/lexer.l | 1 + gtests/net/packetdrill/parser.y | 21 ++- gtests/net/packetdrill/run_system_call.c | 176 +++++++++++++++--- gtests/net/packetdrill/script.c | 5 + gtests/net/packetdrill/script.h | 1 + gtests/net/packetdrill/symbols_freebsd.c | 1 + .../sctp/notifications/sctp_notifications.pkt | 2 +- .../sctp_notifications_stopped_event.pkt | 17 -- .../tests/bsd/sctp/sctp_recvmsg.pkt | 5 +- .../packetdrill/tests/bsd/sctp/sendmsg.pkt | 14 ++ 10 files changed, 192 insertions(+), 51 deletions(-) delete mode 100644 gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications_stopped_event.pkt diff --git a/gtests/net/packetdrill/lexer.l b/gtests/net/packetdrill/lexer.l index 08ff374e..163f890a 100644 --- a/gtests/net/packetdrill/lexer.l +++ b/gtests/net/packetdrill/lexer.l @@ -274,6 +274,7 @@ sinfo_context return SINFO_CONTEXT; sinfo_timetolive return SINFO_TIMETOLIVE; sinfo_tsn return SINFO_TSN; sinfo_cumtsn return SINFO_CUMTSN; +sinfo_assoc_id return SINFO_ASSOC_ID; pr_policy return PR_POLICY; pr_value return PR_VALUE; sendv_flags return SENDV_FLAGS; diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y index 357bdc61..b75dd85b 100644 --- a/gtests/net/packetdrill/parser.y +++ b/gtests/net/packetdrill/parser.y @@ -540,7 +540,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string, %token <reserved> SASOC_LOCAL_RWND SASOC_COOKIE_LIFE SE_TYPE SE_ON %token <reserved> SND_SID SND_FLAGS SND_PPID SND_CONTEXT SND_ASSOC_ID SSB_ADAPTATION_IND %token <reserved> BAD_CRC32C NULL_ -%token <reserved> SINFO_STREAM SINFO_SSN SINFO_FLAGS SINFO_PPID SINFO_CONTEXT +%token <reserved> SINFO_STREAM SINFO_SSN SINFO_FLAGS SINFO_PPID SINFO_CONTEXT SINFO_ASSOC_ID %token <reserved> SINFO_TIMETOLIVE SINFO_TSN SINFO_CUMTSN %token <reserved> PR_POLICY PR_VALUE AUTH_KEYNUMBER SENDV_FLAGS SENDV_SNDINFO %token <reserved> SENDV_PRINFO SENDV_AUTHINFO @@ -615,7 +615,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string, %type <expression> sctp_sndinfo snd_sid snd_flags snd_ppid snd_assoc_id snd_context %type <expression> sctp_event se_type se_on sctp_setadaptation null %type <expression> sctp_sndrcvinfo sinfo_stream sinfo_ssn sinfo_flags sinfo_ppid sinfo_context -%type <expression> sinfo_timetolive sinfo_tsn sinfo_cumtsn +%type <expression> sinfo_timetolive sinfo_tsn sinfo_cumtsn sinfo_assoc_id %type <expression> sctp_prinfo sctp_authinfo pr_policy sctp_sendv_spa %type <expression> sctp_rcvinfo rcv_sid rcv_ssn rcv_flags rcv_ppid rcv_tsn rcv_cumtsn rcv_context %type <expression> sctp_nxtinfo nxt_sid nxt_flags nxt_ppid nxt_length sctp_recvv_rn @@ -2678,7 +2678,9 @@ cmsg_type ; cmsg_data -: CMSG_DATA '=' sctp_sndinfo { $$ = $3; } +: CMSG_DATA '=' sctp_initmsg { $$ = $3; } +| CMSG_DATA '=' sctp_sndrcvinfo { $$ = $3; } +| CMSG_DATA '=' sctp_sndinfo { $$ = $3; } | CMSG_DATA '=' sctp_prinfo { $$ = $3; } | CMSG_DATA '=' sctp_authinfo { $$ = $3; } | CMSG_DATA '=' sockaddr { $$ = $3; } @@ -3432,8 +3434,18 @@ sinfo_cumtsn | SINFO_CUMTSN '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } ; +sinfo_assoc_id +: SINFO_ASSOC_ID '=' INTEGER { + if (!is_valid_u32($3)) { + semantic_error("sinfo_assoc_id out of range"); + } + $$ = new_integer_expression($3, "%u"); +} +| SINFO_ASSOC_ID '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + sctp_sndrcvinfo -: '{' sinfo_stream ',' sinfo_ssn ',' sinfo_flags ',' sinfo_ppid ',' sinfo_context ',' sinfo_timetolive ',' sinfo_tsn ',' sinfo_cumtsn '}' { +: '{' sinfo_stream ',' sinfo_ssn ',' sinfo_flags ',' sinfo_ppid ',' sinfo_context ',' sinfo_timetolive ',' sinfo_tsn ',' sinfo_cumtsn ',' sinfo_assoc_id '}' { $$ = new_expression(EXPR_SCTP_SNDRCVINFO); $$->value.sctp_sndrcvinfo = calloc(1, sizeof(struct sctp_sndrcvinfo_expr)); $$->value.sctp_sndrcvinfo->sinfo_stream = $2; @@ -3444,6 +3456,7 @@ sctp_sndrcvinfo $$->value.sctp_sndrcvinfo->sinfo_timetolive = $12; $$->value.sctp_sndrcvinfo->sinfo_tsn = $14; $$->value.sctp_sndrcvinfo->sinfo_cumtsn = $16; + $$->value.sctp_sndrcvinfo->sinfo_assoc_id = $18; }; rcv_sid diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index d99284a6..3d9a5d72 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -53,17 +53,30 @@ static int check_sctp_notification(struct iovec *iov, struct expression *iovec_e char **error); #endif #if defined(__FreeBSD__) +static int parse_expression_to_sctp_initmsg(struct expression *expr, struct sctp_initmsg *init, + char **error); static int parse_expression_to_sctp_sndinfo(struct expression *expr, struct sctp_sndinfo *info, char **error); static int parse_expression_to_sctp_prinfo(struct expression *expr, struct sctp_prinfo *info, char **error); static int parse_expression_to_sctp_authinfo(struct expression *expr, struct sctp_authinfo *info, char **error); +static int parse_expression_to_sctp_sndrcvinfo(struct expression *expr, struct sctp_sndrcvinfo *info, + char **error); #endif #if defined(SCTP_DEFAULT_SNDINFO) || defined(SCTP_SNDINFO) static int check_sctp_sndinfo(struct sctp_sndinfo_expr *expr, struct sctp_sndinfo *sctp_sndinfo, char **error); #endif +#if defined(SCTP_INITMSG) || defined(SCTP_INIT) +static int check_sctp_initmsg(struct sctp_initmsg_expr *expr, struct sctp_initmsg *sctp_initmsg, + char **error); +#endif +#if defined(Linux) || defined(__FreeBSD__) +static int check_sctp_sndrcvinfo(struct sctp_sndrcvinfo_expr *expr, + struct sctp_sndrcvinfo *sctp_sndrcvinfo, + char** error); +#endif /* Provide a wrapper for the Linux gettid() system call (glibc does not). */ static pid_t gettid(void) @@ -695,15 +708,31 @@ static int cmsg_new(struct expression *expression, struct expression *cmsg_expr; cmsg_expr = get_arg(list, i, error); switch (cmsg_expr->value.cmsghdr->cmsg_data->type) { +#ifdef SCTP_INIT + case EXPR_SCTP_INITMSG: + cmsg_size += CMSG_SPACE(sizeof(struct sctp_initmsg)); + break; +#endif +#ifdef SCTP_SNDRCV + case EXPR_SCTP_SNDRCVINFO: + cmsg_size += CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); + break; +#endif +#ifdef SCTP_SNDINFO case EXPR_SCTP_SNDINFO: cmsg_size += CMSG_SPACE(sizeof(struct sctp_sndinfo)); break; +#endif +#ifdef SCTP_PRINFO case EXPR_SCTP_PRINFO: cmsg_size += CMSG_SPACE(sizeof(struct sctp_prinfo)); break; +#endif +#ifdef SCTP_AUTHINFO case EXPR_SCTP_AUTHINFO: cmsg_size += CMSG_SPACE(sizeof(struct sctp_authinfo)); break; +#endif case EXPR_SOCKET_ADDRESS_IPV4: cmsg_size += CMSG_SPACE(sizeof(struct in_addr)); break; @@ -715,11 +744,10 @@ static int cmsg_new(struct expression *expression, return STATUS_ERR; } } - *cmsg_len_ptr = cmsg_size; cmsg = calloc(1, cmsg_size); *cmsg_ptr = (void *)cmsg; - + for (i = 0; i < list_len; i++) { struct expression *expr; struct cmsghdr_expr *cmsg_expr; @@ -736,6 +764,29 @@ static int cmsg_new(struct expression *expression, goto error_out; switch(cmsg_expr->cmsg_data->type) { +#ifdef SCTP_INIT + case EXPR_SCTP_INITMSG: { + struct sctp_initmsg init; + if (parse_expression_to_sctp_initmsg(cmsg_expr->cmsg_data, &init, error)) { + goto error_out; + } + memcpy(CMSG_DATA(cmsg), &init, sizeof(struct sctp_initmsg)); + cmsg = (struct cmsghdr *) ((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_initmsg))); + break; + } +#endif +#ifdef SCTP_SNDRCV + case EXPR_SCTP_SNDRCVINFO: { + struct sctp_sndrcvinfo info; + if (parse_expression_to_sctp_sndrcvinfo(cmsg_expr->cmsg_data, &info, error)) { + goto error_out; + } + memcpy(CMSG_DATA(cmsg), &info, sizeof(struct sctp_sndrcvinfo)); + cmsg = (struct cmsghdr *) ((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))); + break; + } +#endif +#ifdef SCTP_SNDINFO case EXPR_SCTP_SNDINFO: { struct sctp_sndinfo info; if (parse_expression_to_sctp_sndinfo(cmsg_expr->cmsg_data, &info, error)) { @@ -745,6 +796,8 @@ static int cmsg_new(struct expression *expression, cmsg = (struct cmsghdr *) ((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo))); break; } +#endif +#ifdef SCTP_PRINFO case EXPR_SCTP_PRINFO: { struct sctp_prinfo info; if (parse_expression_to_sctp_prinfo(cmsg_expr->cmsg_data, &info, error)) { @@ -753,7 +806,9 @@ static int cmsg_new(struct expression *expression, memcpy(CMSG_DATA(cmsg), &info, sizeof(struct sctp_prinfo)); cmsg = (struct cmsghdr *) ((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_prinfo))); break; - } + } +#endif +#ifdef SCTP_AUTHINFO case EXPR_SCTP_AUTHINFO: { struct sctp_authinfo info; if (parse_expression_to_sctp_authinfo(cmsg_expr->cmsg_data, &info, error)) { @@ -762,7 +817,8 @@ static int cmsg_new(struct expression *expression, memcpy(CMSG_DATA(cmsg), &info, sizeof(struct sctp_authinfo)); cmsg = (struct cmsghdr *) ((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_authinfo))); break; - } + } +#endif case EXPR_SOCKET_ADDRESS_IPV4: memcpy(CMSG_DATA(cmsg), &cmsg_expr->cmsg_data->value.socket_address_ipv4->sin_addr, sizeof(struct in_addr)); cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct in_addr))); @@ -1883,7 +1939,7 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char struct expression_list *list; struct expression *cmsg_expr; struct cmsghdr *cmsg_ptr; - int cnt=0; + int cnt = 0; assert(expr_list->type == EXPR_LIST); @@ -1907,6 +1963,24 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char continue; } switch(cmsg_ptr->cmsg_type) { +#ifdef SCTP_INITMSG + case SCTP_INITMSG: + if (check_sctp_initmsg(expr->cmsg_data->value.sctp_initmsg, + (struct sctp_initmsg *) CMSG_DATA(cmsg_ptr), + error)) { + return STATUS_ERR; + } + break; +#endif +#ifdef SCTP_SNDRCV + case SCTP_SNDRCV: + if (check_sctp_sndrcvinfo(expr->cmsg_data->value.sctp_sndrcvinfo, + (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg_ptr), + error)) { + return STATUS_ERR; + } + break; +#endif #ifdef SCTP_SNDINFO case SCTP_SNDINFO: if (check_sctp_sndinfo(expr->cmsg_data->value.sctp_sndinfo, @@ -1920,20 +1994,23 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char case SCTP_PRINFO: if (check_u16_expr(expr->cmsg_data->value.sctp_prinfo->pr_policy, ((struct sctp_prinfo *)CMSG_DATA(cmsg_ptr))->pr_policy, - "prinfo.pr_policy", error)) + "prinfo.pr_policy", error)) { return STATUS_ERR; + } if (check_u32_expr(expr->cmsg_data->value.sctp_prinfo->pr_value, ((struct sctp_prinfo *)CMSG_DATA(cmsg_ptr))->pr_value, - "prinfo.pr_value", error)) + "prinfo.pr_value", error)) { return STATUS_ERR; + } break; #endif #ifdef SCTP_AUTHINFO case SCTP_AUTHINFO: if (check_u16_expr(expr->cmsg_data->value.sctp_authinfo->auth_keynumber, ((struct sctp_authinfo *)CMSG_DATA(cmsg_ptr))->auth_keynumber, - "authinfo.auth_keynumber", error)) + "authinfo.auth_keynumber", error)) { return STATUS_ERR; + } break; #endif #ifdef SCTP_DSTADDRV4 @@ -1963,8 +2040,7 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char asprintf(error, "sockaddr_in6 from.sin6_addr. expected: %s actual %s", expected_addr, live_addr); return STATUS_ERR; - } - + } } break; #endif @@ -2019,7 +2095,7 @@ static int syscall_sendmsg(struct state *state, struct syscall_spec *syscall, if (end_syscall(state, syscall, CHECK_EXACT, result, error)) goto error_out; - status = check_cmsghdr(msg_expression->value.msghdr->msg_control, msg, error); + status = check_cmsghdr(msg_expression->value.msghdr->msg_control, msg, error); error_out: msghdr_free(msg, iov_len); @@ -2196,7 +2272,7 @@ static int check_sctp_rtoinfo(struct sctp_rtoinfo_expr *expr, } #endif -#ifdef SCTP_INITMSG +#if defined(SCTP_INITMSG) || defined(SCTP_INIT) static int check_sctp_initmsg(struct sctp_initmsg_expr *expr, struct sctp_initmsg *sctp_initmsg, char **error) { @@ -2890,20 +2966,7 @@ static int syscall_setsockopt(struct state *state, struct syscall_spec *syscall, #endif #ifdef SCTP_INITMSG case EXPR_SCTP_INITMSG: - if (get_u16(val_expression->value.sctp_initmsg->sinit_num_ostreams, - &initmsg.sinit_num_ostreams, error)) { - return STATUS_ERR; - } - if (get_u16(val_expression->value.sctp_initmsg->sinit_max_instreams, - &initmsg.sinit_max_instreams, error)) { - return STATUS_ERR; - } - if (get_u16(val_expression->value.sctp_initmsg->sinit_max_attempts, - &initmsg.sinit_max_attempts, error)) { - return STATUS_ERR; - } - if (get_u16(val_expression->value.sctp_initmsg->sinit_max_init_timeo, - &initmsg.sinit_max_init_timeo, error)) { + if(parse_expression_to_sctp_initmsg(val_expression, &initmsg, error)) { return STATUS_ERR; } optval = &initmsg; @@ -3291,10 +3354,12 @@ static int check_sctp_sndrcvinfo(struct sctp_sndrcvinfo_expr *expr, if (check_u32_expr(expr->sinfo_cumtsn, sctp_sndrcvinfo->sinfo_cumtsn, "sctp_sndrcvinfo.sinfo_cumtsn", error)) return STATUS_ERR; + if (check_u32_expr(expr->sinfo_assoc_id, sctp_sndrcvinfo->sinfo_assoc_id, + "sctp_sndrcvinfo.sinfo_assoc_id", error)) + return STATUS_ERR; return STATUS_OK; } - #endif static int syscall_sctp_recvmsg(struct state *state, struct syscall_spec *syscall, @@ -3400,6 +3465,63 @@ static int parse_expression_to_sctp_sndinfo(struct expression *expr, struct sctp return STATUS_OK; } +static int parse_expression_to_sctp_initmsg(struct expression *expr, struct sctp_initmsg *init, char **error) { + if (expr->type == EXPR_SCTP_INITMSG) { + struct sctp_initmsg_expr *init_expr = expr->value.sctp_initmsg; + if (get_u16(init_expr->sinit_num_ostreams, &init->sinit_num_ostreams, error)) { + return STATUS_ERR; + } + if (get_u16(init_expr->sinit_max_instreams, &init->sinit_max_instreams, error)) { + return STATUS_ERR; + } + if (get_u16(init_expr->sinit_max_attempts, &init->sinit_max_attempts, error)) { + return STATUS_ERR; + } + if (get_u16(init_expr->sinit_max_init_timeo, &init->sinit_max_init_timeo, error)) { + return STATUS_ERR; + } + } else { + return STATUS_ERR; + } + return STATUS_OK; +} + +static int parse_expression_to_sctp_sndrcvinfo(struct expression *expr, struct sctp_sndrcvinfo *info, char **error) { + if (expr->type == EXPR_SCTP_SNDRCVINFO) { + struct sctp_sndrcvinfo_expr *sndrcvinfo_expr = expr->value.sctp_sndrcvinfo; + if (get_u16(sndrcvinfo_expr->sinfo_stream, &info->sinfo_stream, error)) { + return STATUS_ERR; + } + if (get_u16(sndrcvinfo_expr->sinfo_ssn, &info->sinfo_ssn, error)) { + return STATUS_ERR; + } + if (get_u16(sndrcvinfo_expr->sinfo_flags, &info->sinfo_flags, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_ppid, &info->sinfo_ppid, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_context, &info->sinfo_context, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_timetolive, &info->sinfo_timetolive, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_tsn, &info->sinfo_tsn, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_cumtsn, &info->sinfo_cumtsn, error)) { + return STATUS_ERR; + } + if (get_u32(sndrcvinfo_expr->sinfo_assoc_id, &info->sinfo_assoc_id, error)) { + return STATUS_ERR; + } + } else { + return STATUS_ERR; + } + return STATUS_OK; +} + static int parse_expression_to_sctp_authinfo(struct expression *expr, struct sctp_authinfo *info, char **error) { if (expr->type == EXPR_SCTP_AUTHINFO) { struct sctp_authinfo_expr *auth_expr = expr->value.sctp_authinfo; diff --git a/gtests/net/packetdrill/script.c b/gtests/net/packetdrill/script.c index 58604198..4508038f 100644 --- a/gtests/net/packetdrill/script.c +++ b/gtests/net/packetdrill/script.c @@ -409,6 +409,7 @@ void free_expression(struct expression *expression) free_expression(expression->value.sctp_sndrcvinfo->sinfo_timetolive); free_expression(expression->value.sctp_sndrcvinfo->sinfo_tsn); free_expression(expression->value.sctp_sndrcvinfo->sinfo_cumtsn); + free_expression(expression->value.sctp_sndrcvinfo->sinfo_assoc_id); break; case EXPR_SCTP_PRINFO: free_expression(expression->value.sctp_prinfo->pr_policy); @@ -1279,6 +1280,10 @@ static int evaluate_sctp_sndrcvinfo_expression(struct expression *in, &out_info->sinfo_cumtsn, error)) return STATUS_ERR; + if (evaluate(in_info->sinfo_assoc_id, + &out_info->sinfo_assoc_id, + error)) + return STATUS_ERR; return STATUS_OK; } diff --git a/gtests/net/packetdrill/script.h b/gtests/net/packetdrill/script.h index 5dccd49c..3a9942d5 100644 --- a/gtests/net/packetdrill/script.h +++ b/gtests/net/packetdrill/script.h @@ -304,6 +304,7 @@ struct sctp_sndrcvinfo_expr { struct expression *sinfo_timetolive; struct expression *sinfo_tsn; struct expression *sinfo_cumtsn; + struct expression *sinfo_assoc_id; }; /* Parse tree for sctp_prinfo in sctp_sendv syscall. */ diff --git a/gtests/net/packetdrill/symbols_freebsd.c b/gtests/net/packetdrill/symbols_freebsd.c index b8d5288b..135d9e19 100644 --- a/gtests/net/packetdrill/symbols_freebsd.c +++ b/gtests/net/packetdrill/symbols_freebsd.c @@ -222,6 +222,7 @@ struct int_symbol platform_symbols_table[] = { { SCTP_ADDR_UNREACHABLE, "SCTP_ADDR_UNREACHABLE" }, { SCTP_ADDR_REMOVED, "SCTP_ADDR_REMOVED" }, { SCTP_ADDR_MADE_PRIM, "SCTP_ADDR_MADE_PRIM" }, + { SCTP_SNDRCV, "SCTP_SNDRCV" }, { SCTP_SNDINFO, "SCTP_SNDINFO" }, { SCTP_PRINFO, "SCTP_PRINFO" }, { SCTP_AUTHINFO, "SCTP_AUTHINFO" }, diff --git a/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications.pkt b/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications.pkt index 8d6d7145..6df07bee 100644 --- a/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications.pkt +++ b/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications.pkt @@ -43,7 +43,7 @@ sctp_sender_dry_event=0}, 11) = 0 * > sctp: DATA[flgs=BE, len=1016, tsn=1, sid=0, ssn=0, ppid=0] * > sctp: DATA[flgs=BE, len=1016, tsn=1, sid=0, ssn=0, ppid=0] +1.0 sctp_recvv(3, [{iov_base={ssfe_type=SCTP_SEND_FAILED_EVENT, ssfe_flags=SCTP_DATA_SENT, ssfe_length=1032, ssfe_error=0, -ssfe_info={snd_sid=0, snd_flags=3, snd_ppid=htonl(0), snd_context=0}, ssfe_assoc_id=3, ssfe_data=...}, iov_len=1000}], +ssfe_info={snd_sid=0, snd_flags=3, snd_ppid=htonl(0), snd_context=0, snd_assoc_id=...}, ssfe_assoc_id=3, ssfe_data=...}, iov_len=1000}], 1, ..., 20, NULL, [0], [SCTP_RECVV_NOINFO], [MSG_NOTIFICATION]) = 1000 +0.0 setsockopt(3, IPPROTO_SCTP, SCTP_EVENT, {se_type=SCTP_SEND_FAILED_EVENT, se_on=0}, 8) = 0 diff --git a/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications_stopped_event.pkt b/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications_stopped_event.pkt deleted file mode 100644 index 6adecb8f..00000000 --- a/gtests/net/packetdrill/tests/bsd/sctp/notifications/sctp_notifications_stopped_event.pkt +++ /dev/null @@ -1,17 +0,0 @@ -+0.0 socket(..., SOCK_STREAM, IPPROTO_SCTP) = 3 -+0.0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) -+0.0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 -// Check the handshake with an empty(!) cookie -+0.1 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) -+0.0 setsockopt(3, IPPROTO_SCTP, SCTP_EVENT, {se_type=SCTP_ADAPTATION_INDICATION, se_on=1}, 8) = 0 -+0.0 getsockopt(3, IPPROTO_SCTP, SCTP_EVENT, {se_type=SCTP_ADAPTATION_INDICATION, se_on=1}, [8]) = 0 -+0.0 setsockopt(3, IPPROTO_SCTP, SCTP_EVENT, {se_type=SCTP_NOTIFICATIONS_STOPPED_EVENT, se_on=1}, 8) = 0 - -+0.0 > sctp: INIT[flgs=0, tag=1, a_rwnd=..., os=..., is=..., tsn=1, ...] -+0.1 < sctp: INIT_ACK[flgs=0, tag=2, a_rwnd=1500, os=1, is=1, tsn=1, STATE_COOKIE[len=4, val=...]] -+0.0 > sctp: COOKIE_ECHO[flgs=0, len=4, val=...] -+0.1 < sctp: COOKIE_ACK[flgs=0] -// No implementation provides this messages, so it can't be tested -// as discribed in rfc, create an notification storm so that the implementation disable notifications -+0.0 sctp_recvv(3, [{iov_base={sn_type=SCTP_NOTIFICATIONS_STOPPED_EVENT, sn_flags=0, sn_length=8}, iov_len=1000}], 1, -..., 20, NULL, [0], [SCTP_RECVV_NOINFO],[MSG_NOTIFICATION|MSG_EOR]) = 21 diff --git a/gtests/net/packetdrill/tests/bsd/sctp/sctp_recvmsg.pkt b/gtests/net/packetdrill/tests/bsd/sctp/sctp_recvmsg.pkt index c972405b..7ece5c29 100644 --- a/gtests/net/packetdrill/tests/bsd/sctp/sctp_recvmsg.pkt +++ b/gtests/net/packetdrill/tests/bsd/sctp/sctp_recvmsg.pkt @@ -17,12 +17,13 @@ +0.0 < sctp: DATA[flgs=BE, len=1016, tsn=2, sid=0, ssn=1, ppid=1234] * > sctp: SACK[flgs=0, cum_tsn=2, a_rwnd=..., gaps=[], dups=[]] -+0.0 sctp_recvmsg(3, ..., 1000, ..., ..., {sinfo_stream=0, sinfo_ssn=1, sinfo_flags=0, sinfo_ppid=htonl(1234), sinfo_context=0, sinfo_timetolive=0, sinfo_tsn=2, sinfo_cumtsn=2}, 8) = 1000 ++0.0 sctp_recvmsg(3, ..., 1000, ..., ..., {sinfo_stream=0, sinfo_ssn=1, sinfo_flags=0, sinfo_ppid=htonl(1234), sinfo_context=0, sinfo_timetolive=0, sinfo_tsn=2, +sinfo_cumtsn=2, sinfo_assoc_id=3}, 8) = 1000 +0.0 < sctp: DATA[flgs=BE, len=1016, tsn=3, sid=0, ssn=2, ppid=0] * > sctp: SACK[flgs=0, cum_tsn=3, a_rwnd=..., gaps=[], dups=[]] +0.0 sctp_recvmsg(3, ..., 1000, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("192.0.2.1")}, 16, -{sinfo_stream=0, sinfo_ssn=2, sinfo_flags=0, sinfo_ppid=htonl(0), sinfo_context=0, sinfo_timetolive=0, sinfo_tsn=3, sinfo_cumtsn=3}, 8) = 1000 +{sinfo_stream=0, sinfo_ssn=2, sinfo_flags=0, sinfo_ppid=htonl(0), sinfo_context=0, sinfo_timetolive=0, sinfo_tsn=3, sinfo_cumtsn=3, sinfo_assoc_id=3}, 8) = 1000 +0.0 close(3) = 0 +0.0 > sctp: SHUTDOWN[flgs=0, cum_tsn=3] diff --git a/gtests/net/packetdrill/tests/bsd/sctp/sendmsg.pkt b/gtests/net/packetdrill/tests/bsd/sctp/sendmsg.pkt index a8639456..a763cd77 100644 --- a/gtests/net/packetdrill/tests/bsd/sctp/sendmsg.pkt +++ b/gtests/net/packetdrill/tests/bsd/sctp/sendmsg.pkt @@ -12,6 +12,9 @@ +0.0 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 //sendmsg(sd, msghdr, flags) ++0.0 setsockopt(3, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, {spp_address={sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("192.0.2.1")}, +spp_hbinterval=0, spp_pathmaxrxt=8, spp_pathmtu=1468, spp_flags=SPP_HB_DISABLE, spp_ipv6_flowlabel=0, spp_dscp=0}, 152) = 0 + +1.0 sendmsg(3, {msg_name(...)=..., msg_iov(1)=[{iov_base=..., iov_len=1000}], msg_control(0)=[], msg_flags=0}, 0) = 1000 * > sctp: DATA[flgs=BE, len=1016, tsn=1, sid=0, ssn=0, ppid=0] +0.0 < sctp: SACK[flgs=0, cum_tsn=1, a_rwnd=1500, gaps=[], dups=[]] @@ -64,6 +67,17 @@ * > sctp: DATA[flgs=BE, len=1016, tsn=5, sid=2, ssn=3, ppid=6] +0.0 < sctp: SACK[flgs=0, cum_tsn=5, a_rwnd=1500, gaps=[], dups=[]] +//test for sndrcvinfo ++1.0 sendmsg(3, {msg_name(...)=..., msg_iov(1)=[{iov_base=..., iov_len=1000}], msg_control(168)= + [{cmsg_len=28, cmsg_level=IPPROTO_SCTP, cmsg_type=SCTP_SNDINFO, cmsg_data= + {snd_sid=2, snd_flags=0, snd_ppid=htonl(6), snd_context=2, snd_assoc_id=0} + },{cmsg_len=140, cmsg_level=IPPROTO_SCTP, cmsg_type=SCTP_SNDRCV, cmsg_data= + {sinfo_stream=3, sinfo_ssn=3, sinfo_flags=0, sinfo_ppid=htonl(7), sinfo_context=0, sinfo_timetolive=0, sinfo_tsn=6, sinfo_cumtsn=6, sinfo_assoc_id=3} + }], + msg_flags=0}, 0) = 1000 +* > sctp: DATA[flgs=BE, len=1016, tsn=6, sid=3, ssn=0, ppid=7] ++0.0 < sctp: SACK[flgs=0, cum_tsn=6, a_rwnd=1500, gaps=[], dups=[]] + +0.0 close(3) = 0 +0.0 > sctp: SHUTDOWN[flgs=0, cum_tsn=0] +0.1 < sctp: SHUTDOWN_ACK[flgs=0] -- GitLab