Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net-test: packetdrill: add support of tcp option wildcard "wscale *" #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gtests/net/packetdrill/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,10 @@ tcp_option
}
$$->data.window_scale.shift_count = $2;
}
| WSCALE '*' {
$$ = tcp_option_new(TCPOPT_WINDOW | TCPOPT_WILDCARD, TCPOLEN_WINDOW);
$$->data.window_scale.shift_count = 0;
}
| SACKOK {
$$ = tcp_option_new(TCPOPT_SACK_PERMITTED,
TCPOLEN_SACK_PERMITTED);
Expand Down
9 changes: 7 additions & 2 deletions gtests/net/packetdrill/run_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,12 +1383,17 @@ static int verify_outbound_live_tcp_options(
/* TCP options are expected to be a deterministic order. */
while (a_opt != NULL || s_opt != NULL) {
if (a_opt == NULL || s_opt == NULL ||
a_opt->kind != s_opt->kind) {
(a_opt->kind != s_opt->kind &&
!(s_opt->kind == (TCPOPT_WILDCARD | TCPOPT_WINDOW) &&
a_opt->kind == TCPOPT_WINDOW))) {
asprintf(error, "bad outbound TCP options");
return STATUS_ERR;
}

if (verify_outbound_tcp_option(state, actual_packet,
/* skip byte-to-byte comparison of wildcard option */
if (s_opt->kind == (TCPOPT_WILDCARD | TCPOPT_WINDOW))
;
else if (verify_outbound_tcp_option(state, actual_packet,
script_packet, a_opt, s_opt,
error) != STATUS_OK) {
return STATUS_ERR;
Expand Down
11 changes: 11 additions & 0 deletions gtests/net/packetdrill/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@

#define TCP_MD5_DIGEST_LEN 16 /* bytes in RFC2385 TCP MD5 digest */

/*
* To compare subset of options between script packet and actual packet,
* we use * for "option with any value". For example, "wscale *" in the
* script packet means wscale option of any value.
*
* TCPOPT_WILDCARD is used to mark a option in the script packet as
* "any value". A script packet of kind "TCPOPT_WINDOW | TCPOPT_WILDCARD"
* means "wscale option of any value".
*/
#define TCPOPT_WILDCARD 0x80

/* A portable TCP header definition (Linux and *BSD use different names). */
struct tcp {
__be16 src_port;
Expand Down
1 change: 1 addition & 0 deletions gtests/net/packetdrill/tcp_options_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static int get_expected_tcp_option_length(u8 kind, u8 *expected_length,
break;

case TCPOPT_WINDOW:
case TCPOPT_WINDOW | TCPOPT_WILDCARD:
*expected_length = TCPOLEN_WINDOW;
break;

Expand Down
4 changes: 4 additions & 0 deletions gtests/net/packetdrill/tcp_options_to_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ int tcp_options_to_string(struct packet *packet,
option->data.window_scale.shift_count);
break;

case TCPOPT_WINDOW | TCPOPT_WILDCARD:
fprintf(s, "wscale *");
break;

case TCPOPT_SACK_PERMITTED:
fputs("sackOK", s);
break;
Expand Down