Skip to content

Commit 6f6dd63

Browse files
committed
net-test: packetdrill: make loose segmentation sequence errors more usable
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
1 parent 036f7cc commit 6f6dd63

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

gtests/net/packetdrill/run_packet.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,47 @@ static int verify_packet_fragments(
14721472
return STATUS_OK;
14731473
}
14741474

1475+
static void dump_one_sniffed_packet(struct state *state,
1476+
struct packet *sniffed_packet,
1477+
int packet_index,
1478+
char **error)
1479+
{
1480+
s64 actual_usecs = live_time_to_script_time_usecs(
1481+
state, sniffed_packet->time_usecs);
1482+
char *packet_desc;
1483+
1484+
asprintf(&packet_desc, "actual #%d", packet_index);
1485+
add_packet_dump(error, packet_desc, sniffed_packet, actual_usecs,
1486+
DUMP_SHORT);
1487+
free(packet_desc);
1488+
}
1489+
1490+
/* Write a human-readable message for cases where a sequence of sniffed packets
1491+
* does not match an expected TSO/GSO jumbogram.
1492+
*/
1493+
static void dump_packet_fragment_mismatch(
1494+
struct state *state,
1495+
struct packet_list *sniffed_packets_start,
1496+
struct packet *sniffed_packet_latest,
1497+
struct packet *script_packet,
1498+
char **error)
1499+
{
1500+
struct packet_list *sniffed_iter = NULL;
1501+
int packet_index = 0;
1502+
1503+
add_packet_dump(error, " script", script_packet,
1504+
state->event->time_usecs, DUMP_SHORT);
1505+
1506+
for (sniffed_iter = sniffed_packets_start; sniffed_iter != NULL;
1507+
sniffed_iter = sniffed_iter->next) {
1508+
dump_one_sniffed_packet(state, sniffed_iter->packet,
1509+
packet_index, error);
1510+
packet_index++;
1511+
}
1512+
dump_one_sniffed_packet(state, sniffed_packet_latest,
1513+
packet_index, error);
1514+
}
1515+
14751516
/* Sniff the next outbound live packet and return it. */
14761517
static int sniff_outbound_live_packet(
14771518
struct state *state, struct socket *expected_socket,
@@ -1693,6 +1734,12 @@ static int do_outbound_script_packet(
16931734
sniffed_payload_len,
16941735
expected_payload_len,
16951736
error)) {
1737+
dump_packet_fragment_mismatch(
1738+
state,
1739+
sniffed_packets_start,
1740+
sniffed->packet,
1741+
packet,
1742+
error);
16961743
packet_list_free(sniffed);
16971744
goto out;
16981745
}

0 commit comments

Comments
 (0)