Skip to content

Commit f9f27bf

Browse files
committed
tests: Add coverage for GSO/TSO and BIG TCP
This commit adds coverage that affirms the current behavior of tcpdump when it parses packets captured in Linux with aggregation offloads enabled (such as GRO, GSO, TSO and BIG TCP). New tests include: 1. GRO/GSO/TSO TCP packets. These have ip_len (IPv4) or payload_len (IPv6) set to a value bigger than MTU, but smaller than 64k (fits the width of the length field, which is 16 bits). 2. BIG TCP packets, as currently implemented in Linux. These aggregated packets are larger than 64k. In IPv4, ip_len is just set to 0. In IPv6, payload_len is also set to 0, and the real length of the payload is indicated in the Jumbo option of the Hop-by-hop extension header, immediately following the IPv6 header. 3. A corner case: a small (<64k) IPv4 packet with ip_len set to 0. Turns out that both tcpdump and wireshark treat such packets as valid, regardless of the transport protocol, simply printing a message that TSO was presumed. While my tests show that TSO actually fills in the correct (non-zero) value into the ip_len field, the test suite already contains a test called ipv4_tcp_http_xml_tso with a 2030-byte TCP/IPv4 packet that has ip_len = 0, but it's treated as a valid packet. The packet was captured in 2012, and the exact circumstances of why it has a zero ip_len are unclear to me, but if such packets are considered valid by both tcpdump and wireshark, I'm extending the coverage by adding an ICMP packet with ip_len = 0, which was manually crafted. Signed-off-by: Maxim Mikityanskiy <[email protected]>
1 parent a26f940 commit f9f27bf

File tree

11 files changed

+15
-0
lines changed

11 files changed

+15
-0
lines changed

tests/TESTLIST

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,3 +1053,10 @@ LINKTYPE_IPV6_invalid-e LINKTYPE_IPV6_invalid.pcap LINKTYPE_IPV6_invalid-e.out -
10531053
# ipv6_mobility_1.pcap is built with scapy
10541054
ipv6_mobility_1 ipv6_mobility_1.pcap ipv6_mobility_1.out
10551055
ipv6_mobility_1-v ipv6_mobility_1.pcap ipv6_mobility_1-v.out -v
1056+
1057+
# Aggregation offloads (GSO, BIG TCP)
1058+
gso-ipv4 gso-ipv4.pcap gso-ipv4.out -v
1059+
gso-ipv6 gso-ipv6.pcap gso-ipv6.out -v
1060+
bigtcp-ipv4 bigtcp-ipv4.pcap bigtcp-ipv4.out -v
1061+
bigtcp-ipv6-hbh bigtcp-ipv6-hbh.pcap bigtcp-ipv6-hbh.out -v
1062+
icmp-length-zero icmp-length-zero.pcap icmp-length-zero.out -v

tests/bigtcp-ipv4.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 2025-10-02 15:05:40.030951 IP (tos 0x0, ttl 64, id 12031, offset 0, flags [DF], proto TCP (6), length 80052 [was 0, presumed TSO])
2+
10.25.132.13.35871 > 10.25.132.11.36425: Flags [P.], cksum 0x54f2 (incorrect -> 0x199e), seq 4155358606:4155438606, ack 17023525, win 635, options [nop,nop,TS val 3921144597 ecr 3152931631], length 80000

tests/bigtcp-ipv4.pcap

78.2 KB
Binary file not shown.

tests/bigtcp-ipv6-hbh.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-10-06 14:13:27.172200 IP6 (flowlabel 0xa31ee, hlim 64, next-header HBH (0), payload length 0) 2604:1380:4091:ce00::d > 2604:1380:4091:ce00::b: HBH (jumbo: 80040) 41851 > 43913: Flags [P.], cksum 0xc8eb (incorrect -> 0x3146), seq 592820498:592900498, ack 2512896041, win 2128, options [nop,nop,TS val 1186840160 ecr 4237097528], length 80000

tests/bigtcp-ipv6-hbh.pcap

78.3 KB
Binary file not shown.

tests/gso-ipv4.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 2025-10-03 16:26:52.155133 IP (tos 0x0, ttl 61, id 41110, offset 0, flags [DF], proto TCP (6), length 7292)
2+
10.25.132.11.38407 > 10.25.132.13.39701: Flags [P.], cksum 0x38b9 (incorrect -> 0xb3af), seq 964901299:964908539, ack 2308918948, win 166, options [nop,nop,TS val 3244203756 ecr 4012416721], length 7240

tests/gso-ipv4.pcap

7.17 KB
Binary file not shown.

tests/gso-ipv6.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-10-03 16:27:33.363746 IP6 (flowlabel 0x6e481, hlim 61, next-header TCP (6), payload length 7172) 2604:1380:4091:ce00::b.36539 > 2604:1380:4091:ce00::d.45393: Flags [P.], cksum 0xac4e (incorrect -> 0xd25e), seq 1110639583:1110646723, ack 3034762532, win 169, options [nop,nop,TS val 3655207884 ecr 3954243053], length 7140

tests/gso-ipv6.pcap

7.1 KB
Binary file not shown.

tests/icmp-length-zero.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 2025-10-06 13:09:13.000001 IP (tos 0x0, ttl 61, id 19706, offset 0, flags [DF], proto ICMP (1), length 84 [was 0, presumed TSO])
2+
10.25.132.11 > 10.25.132.13: ICMP echo request, id 12931, seq 1, length 64

0 commit comments

Comments
 (0)