Skip to content

Commit

Permalink
net-test: packetdrill: make loose segmentation sequence errors more u…
Browse files Browse the repository at this point in the history
…sable

With loose segementation (on by default), and a script line like:

+0 > . 3001:6001(3000) ack 1

...you could get a mystifying error message referring to a mysterious expected
sequence number of 12001 that the script did not really expect, without any
dumping of the expected or actual skbs to explain why:

  bbr-fr-startup-sacks-grow-inflight.pkt:45: error handling packet:
   live packet field tcp_seq: expected: 12001 (0x2ee1) vs actual: 3001 (0xbb9)

Now with this commit the error message dumps the full sequence of sniffed skbs,
along with the expected skb:

  bbr-fr-startup-sacks-grow-inflight.pkt:45: error handling packet:
  live packet field tcp_seq: expected: 12001 (0x2ee1) vs actual: 3001 (0xbb9)
     script packet:  0.042528 . 3001:6001(3000) ack 1
  actual #0 packet:  0.042468 . 10001:12001(2000) ack 1 win 256
  actual #1 packet:  0.043177 . 3001:4001(1000) ack 1 win 256

With this info, the reader can see why a sequence of 12001 was expected by
packetdrill.

Signed-off-by: Neal Cardwell <[email protected]>
Change-Id: I932ce693a674efd320588fb6ab8b0aa67a961111
  • Loading branch information
nealcardwell committed Aug 21, 2022
1 parent 036f7cc commit 6f6dd63
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions gtests/net/packetdrill/run_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,47 @@ static int verify_packet_fragments(
return STATUS_OK;
}

static void dump_one_sniffed_packet(struct state *state,
struct packet *sniffed_packet,
int packet_index,
char **error)
{
s64 actual_usecs = live_time_to_script_time_usecs(
state, sniffed_packet->time_usecs);
char *packet_desc;

asprintf(&packet_desc, "actual #%d", packet_index);
add_packet_dump(error, packet_desc, sniffed_packet, actual_usecs,
DUMP_SHORT);
free(packet_desc);
}

/* Write a human-readable message for cases where a sequence of sniffed packets
* does not match an expected TSO/GSO jumbogram.
*/
static void dump_packet_fragment_mismatch(
struct state *state,
struct packet_list *sniffed_packets_start,
struct packet *sniffed_packet_latest,
struct packet *script_packet,
char **error)
{
struct packet_list *sniffed_iter = NULL;
int packet_index = 0;

add_packet_dump(error, " script", script_packet,
state->event->time_usecs, DUMP_SHORT);

for (sniffed_iter = sniffed_packets_start; sniffed_iter != NULL;
sniffed_iter = sniffed_iter->next) {
dump_one_sniffed_packet(state, sniffed_iter->packet,
packet_index, error);
packet_index++;
}
dump_one_sniffed_packet(state, sniffed_packet_latest,
packet_index, error);
}

/* Sniff the next outbound live packet and return it. */
static int sniff_outbound_live_packet(
struct state *state, struct socket *expected_socket,
Expand Down Expand Up @@ -1693,6 +1734,12 @@ static int do_outbound_script_packet(
sniffed_payload_len,
expected_payload_len,
error)) {
dump_packet_fragment_mismatch(
state,
sniffed_packets_start,
sniffed->packet,
packet,
error);
packet_list_free(sniffed);
goto out;
}
Expand Down

0 comments on commit 6f6dd63

Please sign in to comment.