diff --git a/gtests/net/packetdrill/lexer.l b/gtests/net/packetdrill/lexer.l index c4b9e43567dc0910bce37afcb242ae4b0d2f8d62..a308a5720e05004033a48917cbebad037378c826 100644 --- a/gtests/net/packetdrill/lexer.l +++ b/gtests/net/packetdrill/lexer.l @@ -275,6 +275,12 @@ sinfo_timetolive return SINFO_TIMETOLIVE; sinfo_tsn return SINFO_TSN; sinfo_cumtsn return SINFO_CUMTSN; sinfo_assoc_id return SINFO_ASSOC_ID; +sinfo_pr_value return SINFO_PR_VALUE; +serinfo_next_flags return SERINFO_NEXT_FLAGS; +serinfo_next_stream return SERINFO_NEXT_STREAM; +serinfo_next_aid return SERINFO_NEXT_AID; +serinfo_next_length return SERINFO_NEXT_LENGTH; +serinfo_next_ppid return SERINFO_NEXT_PPID; 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 03cfa9bf7f1cc0c70004502bd6fffaed4b55a822..eafcb3291376bf5de6efc486bd7edf25ee6821cb 100644 --- a/gtests/net/packetdrill/parser.y +++ b/gtests/net/packetdrill/parser.y @@ -541,7 +541,8 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string, %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 SINFO_ASSOC_ID -%token <reserved> SINFO_TIMETOLIVE SINFO_TSN SINFO_CUMTSN +%token <reserved> SINFO_TIMETOLIVE SINFO_TSN SINFO_CUMTSN SINFO_PR_VALUE SERINFO_NEXT_FLAGS +%token <reserved> SERINFO_NEXT_STREAM SERINFO_NEXT_AID SERINFO_NEXT_LENGTH SERINFO_NEXT_PPID %token <reserved> PR_POLICY PR_VALUE AUTH_KEYNUMBER SENDV_FLAGS SENDV_SNDINFO %token <reserved> SENDV_PRINFO SENDV_AUTHINFO %token <reserved> RCV_SID RCV_SSN RCV_FLAGS RCV_PPID RCV_TSN RCV_CUMTSN RCV_CONTEXT RCV_ASSOC_ID @@ -615,7 +616,8 @@ 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 sinfo_assoc_id +%type <expression> sinfo_timetolive sinfo_tsn sinfo_cumtsn sinfo_assoc_id sinfo_pr_value serinfo_next_flags +%type <expression> serinfo_next_stream serinfo_next_aid serinfo_next_length serinfo_next_ppid sctp_extrcvinfo %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 rcv_assoc_id %type <expression> sctp_nxtinfo nxt_sid nxt_flags nxt_ppid nxt_length nxt_assoc_id sctp_recvv_rn @@ -2680,6 +2682,7 @@ cmsg_type cmsg_data : CMSG_DATA '=' sctp_initmsg { $$ = $3; } | CMSG_DATA '=' sctp_sndrcvinfo { $$ = $3; } +| CMSG_DATA '=' sctp_extrcvinfo { $$ = $3; } | CMSG_DATA '=' sctp_sndinfo { $$ = $3; } | CMSG_DATA '=' sctp_rcvinfo { $$ = $3; } | CMSG_DATA '=' sctp_nxtinfo { $$ = $3; } @@ -3383,6 +3386,10 @@ sinfo_flags } $$ = new_integer_expression($3, "%u"); } +| SINFO_FLAGS'=' WORD { + $$ = new_expression(EXPR_WORD); + $$->value.string = $3; +} | SINFO_FLAGS '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } ; @@ -3409,7 +3416,7 @@ sinfo_context sinfo_timetolive : SINFO_TIMETOLIVE '=' INTEGER { if (!is_valid_u32($3)) { - semantic_error("snd_timetolive out of range"); + semantic_error("sinfo_timetolive out of range"); } $$ = new_integer_expression($3, "%u"); } @@ -3461,6 +3468,91 @@ sctp_sndrcvinfo $$->value.sctp_sndrcvinfo->sinfo_assoc_id = $18; }; +sinfo_pr_value +: SINFO_PR_VALUE '=' INTEGER { + if (!is_valid_u32($3)) { + semantic_error("sinfo_pr_value out of range"); + } + $$ = new_integer_expression($3, "%u"); +} +| SINFO_PR_VALUE '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + +serinfo_next_stream +: SERINFO_NEXT_STREAM '=' INTEGER { + if (!is_valid_u16($3)) { + semantic_error("serinfo_next_stream out of range"); + } + $$ = new_integer_expression($3, "%hu"); +} +| SERINFO_NEXT_STREAM '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + +serinfo_next_flags +: SERINFO_NEXT_FLAGS'=' WORD { + $$ = new_expression(EXPR_WORD); + $$->value.string = $3; +} +| SERINFO_NEXT_FLAGS '=' INTEGER { + if (!is_valid_u16($3)) { + semantic_error("serinfo_next_flags out of range"); + } + $$ = new_integer_expression($3, "%hu"); +} +| SERINFO_NEXT_FLAGS '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + +serinfo_next_aid +: SERINFO_NEXT_AID '=' INTEGER { + if (!is_valid_u32($3)) { + semantic_error("serinfo_next_aid out of range"); + } + $$ = new_integer_expression($3, "%u"); +} +| SERINFO_NEXT_AID '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; +serinfo_next_length +: SERINFO_NEXT_LENGTH '=' INTEGER { + if (!is_valid_u32($3)) { + semantic_error("serinfo_next_length out of range"); + } + $$ = new_integer_expression($3, "%u"); +} +| SERINFO_NEXT_LENGTH '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + +serinfo_next_ppid +: SERINFO_NEXT_PPID '=' _HTONL_ '(' INTEGER ')' { + if (!is_valid_u32($5)) { + semantic_error("serinfo_next_ppid out of range"); + } + $$ = new_integer_expression(htonl((u32)$5), "%u"); +} +| SERINFO_NEXT_PPID '=' ELLIPSIS { $$ = new_expression(EXPR_ELLIPSIS); } +; + +sctp_extrcvinfo +: '{' sinfo_stream ',' sinfo_ssn ',' sinfo_flags ',' sinfo_ppid ',' sinfo_context ',' sinfo_pr_value ',' sinfo_tsn ',' sinfo_cumtsn ',' +serinfo_next_stream ',' serinfo_next_flags ',' serinfo_next_aid ',' serinfo_next_length ',' serinfo_next_ppid ',' sinfo_assoc_id '}' { + $$ = new_expression(EXPR_SCTP_EXTRCVINFO); + $$->value.sctp_extrcvinfo = calloc(1, sizeof(struct sctp_extrcvinfo_expr)); + $$->value.sctp_extrcvinfo->sinfo_stream = $2; + $$->value.sctp_extrcvinfo->sinfo_ssn = $4; + $$->value.sctp_extrcvinfo->sinfo_flags = $6; + $$->value.sctp_extrcvinfo->sinfo_ppid = $8; + $$->value.sctp_extrcvinfo->sinfo_context = $10; + $$->value.sctp_extrcvinfo->sinfo_pr_value = $12; + $$->value.sctp_extrcvinfo->sinfo_tsn = $14; + $$->value.sctp_extrcvinfo->sinfo_cumtsn = $16; + $$->value.sctp_extrcvinfo->serinfo_next_flags = $18; + $$->value.sctp_extrcvinfo->serinfo_next_stream = $20; + $$->value.sctp_extrcvinfo->serinfo_next_aid = $22; + $$->value.sctp_extrcvinfo->serinfo_next_length = $24; + $$->value.sctp_extrcvinfo->serinfo_next_ppid = $26; + $$->value.sctp_extrcvinfo->sinfo_assoc_id = $28; +}; + + rcv_sid : RCV_SID '=' INTEGER { if (!is_valid_u16($3)) { diff --git a/gtests/net/packetdrill/script.c b/gtests/net/packetdrill/script.c index 2073a5ed4bdb309f554503902aaa9bb372644ff1..47d6c43b72f57f6699bec8c45031b025e24c7218 100644 --- a/gtests/net/packetdrill/script.c +++ b/gtests/net/packetdrill/script.c @@ -98,6 +98,7 @@ struct expression_type_entry expression_type_table[] = { { EXPR_SCTP_SENDER_DRY_EVENT,"sctp_sender_dry_event"}, { EXPR_SCTP_SEND_FAILED_EVENT,"sctp_send_failed_event"}, { EXPR_SCTP_TLV, "sctp_tlv" }, + { EXPR_SCTP_EXTRCVINFO, "sctp_extrcvinfo" }, { NUM_EXPR_TYPES, NULL} }; @@ -531,6 +532,22 @@ void free_expression(struct expression *expression) free_expression(expression->value.sctp_tlv->sn_flags); free_expression(expression->value.sctp_tlv->sn_length); break; + case EXPR_SCTP_EXTRCVINFO: + free_expression(expression->value.sctp_extrcvinfo->sinfo_stream); + free_expression(expression->value.sctp_extrcvinfo->sinfo_ssn); + free_expression(expression->value.sctp_extrcvinfo->sinfo_flags); + free_expression(expression->value.sctp_extrcvinfo->sinfo_ppid); + free_expression(expression->value.sctp_extrcvinfo->sinfo_context); + free_expression(expression->value.sctp_extrcvinfo->sinfo_pr_value); + free_expression(expression->value.sctp_extrcvinfo->sinfo_tsn); + free_expression(expression->value.sctp_extrcvinfo->sinfo_cumtsn); + free_expression(expression->value.sctp_extrcvinfo->serinfo_next_flags); + free_expression(expression->value.sctp_extrcvinfo->serinfo_next_stream); + free_expression(expression->value.sctp_extrcvinfo->serinfo_next_aid); + free_expression(expression->value.sctp_extrcvinfo->serinfo_next_length); + free_expression(expression->value.sctp_extrcvinfo->serinfo_next_ppid); + free_expression(expression->value.sctp_extrcvinfo->sinfo_assoc_id); + break; case EXPR_WORD: assert(expression->value.string); free(expression->value.string); @@ -1971,6 +1988,82 @@ static int evaluate_sctp_tlv_expression(struct expression *in, return STATUS_OK; } +static int evaluate_sctp_extrcvinfo_expression(struct expression *in, + struct expression *out, + char **error) +{ + struct sctp_extrcvinfo_expr *in_info; + struct sctp_extrcvinfo_expr *out_info; + + assert(in->type == EXPR_SCTP_EXTRCVINFO); + assert(in->value.sctp_extrcvinfo); + assert(out->type == EXPR_SCTP_EXTRCVINFO); + + out->value.sctp_extrcvinfo = calloc(1, sizeof(struct sctp_extrcvinfo_expr)); + + in_info = in->value.sctp_extrcvinfo; + out_info = out->value.sctp_extrcvinfo; + + if (evaluate(in_info->sinfo_stream, + &out_info->sinfo_stream, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_ssn, + &out_info->sinfo_ssn, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_flags, + &out_info->sinfo_flags, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_ppid, + &out_info->sinfo_ppid, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_context, + &out_info->sinfo_context, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_pr_value, + &out_info->sinfo_pr_value, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_tsn, + &out_info->sinfo_tsn, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_cumtsn, + &out_info->sinfo_cumtsn, + error)) + return STATUS_ERR; + if (evaluate(in_info->serinfo_next_flags, + &out_info->serinfo_next_flags, + error)) + return STATUS_ERR; + if (evaluate(in_info->serinfo_next_stream, + &out_info->serinfo_next_stream, + error)) + return STATUS_ERR; + if (evaluate(in_info->serinfo_next_aid, + &out_info->serinfo_next_aid, + error)) + return STATUS_ERR; + if (evaluate(in_info->serinfo_next_length, + &out_info->serinfo_next_length, + error)) + return STATUS_ERR; + if (evaluate(in_info->serinfo_next_ppid, + &out_info->serinfo_next_ppid, + error)) + return STATUS_ERR; + if (evaluate(in_info->sinfo_assoc_id, + &out_info->sinfo_assoc_id, + error)) + return STATUS_ERR; + + return STATUS_OK; +} + static int evaluate(struct expression *in, struct expression **out_ptr, char **error) { @@ -2089,6 +2182,9 @@ static int evaluate(struct expression *in, case EXPR_SCTP_TLV: result = evaluate_sctp_tlv_expression(in, out, error); break; + case EXPR_SCTP_EXTRCVINFO: + result = evaluate_sctp_extrcvinfo_expression(in, out, error); + break; case EXPR_WORD: out->type = EXPR_INTEGER; if (symbol_to_int(in->value.string, diff --git a/gtests/net/packetdrill/script.h b/gtests/net/packetdrill/script.h index f14ce4357ef1808ea3d0c423912fea1ede4b3274..00ab1b4b1c1be7cad8b2a3084b82cfb7f03d0888 100644 --- a/gtests/net/packetdrill/script.h +++ b/gtests/net/packetdrill/script.h @@ -78,6 +78,7 @@ enum expression_t { EXPR_SCTP_SENDER_DRY_EVENT, /* expression tree for sctp_sender_dry_event */ EXPR_SCTP_SEND_FAILED_EVENT, /* expression tree for sctp_send_failed_event */ EXPR_SCTP_TLV, /* expression tree for sctp_notifications_stopped_event */ + EXPR_SCTP_EXTRCVINFO, /* expression tree for sctp_extrcvinfo struct in cmsghdr */ NUM_EXPR_TYPES, }; /* Convert an expression type to a human-readable string */ @@ -129,6 +130,7 @@ struct expression { struct sctp_sender_dry_event_expr *sctp_sender_dry_event; struct sctp_send_failed_event_expr *sctp_send_failed_event; struct sctp_tlv_expr *sctp_tlv; + struct sctp_extrcvinfo_expr *sctp_extrcvinfo; } value; const char *format; /* the printf format for printing the value */ }; @@ -461,6 +463,24 @@ struct sctp_tlv_expr { struct expression *sn_length; }; +/* Parse tree for sctp_extrcvinfo struct for cmsg. */ +struct sctp_extrcvinfo_expr { + struct expression *sinfo_stream; + struct expression *sinfo_ssn; + struct expression *sinfo_flags; + struct expression *sinfo_ppid; + struct expression *sinfo_context; + struct expression *sinfo_pr_value; + struct expression *sinfo_tsn; + struct expression *sinfo_cumtsn; + struct expression *serinfo_next_flags; + struct expression *serinfo_next_stream; + struct expression *serinfo_next_aid; + struct expression *serinfo_next_length; + struct expression *serinfo_next_ppid; + struct expression *sinfo_assoc_id; +}; + /* The errno-related info from strace to summarize a system call error */ struct errno_spec { const char *errno_macro; /* errno symbol (C macro name) */