]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IP: Enable TSO (TCP Segmentation Offload) support
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 20 Sep 2023 06:44:09 +0000 (08:44 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 25 Oct 2023 14:19:07 +0000 (16:19 +0200)
It's a follow-up to c8623960f050cb81c12b31107070021f27f14b18.

The support is now enabled by default. No more "#ifdef GUESS_TSO".

Output example:
  length 2016 [was 0, presumed TSO]

Add a test file with presumed TSO.
(From http://cloudshark.org/captures/25e40f73bc1c, found via
https://osqa-ask.wireshark.org/questions/16279/)

Use ND_ICHECKMSG_U() to test an invalid total length < header length.

Output example:
  [total length 19 < 20] (invalid)

Add a test file for this case.

Move ND_TCHECK_SIZE(ip) after the new tests.

Add a const qualifier for the ip_print() parameter 'length'.

Update the man page.

(backported from commit 3465ec4a0c94f3abe774dfdb9874f966403e20ce)

netdissect.h
print-ip.c
tcpdump.1.in
tests/TESTLIST
tests/ipv4_invalid_total_length_2.out [new file with mode: 0644]
tests/ipv4_invalid_total_length_2.pcap [new file with mode: 0644]
tests/ipv4_tcp_http_xml_tso.out [new file with mode: 0644]
tests/ipv4_tcp_http_xml_tso.pcap [new file with mode: 0644]

index e49fef42ab088cc76af4f633e2c809a3b428d880..36efe185658a78698e7f7a3cd99533b85a036c71 100644 (file)
@@ -657,7 +657,7 @@ extern void igmp_print(netdissect_options *, const u_char *, u_int);
 extern void igrp_print(netdissect_options *, const u_char *, u_int);
 extern void ip6_print(netdissect_options *, const u_char *, u_int);
 extern void ipN_print(netdissect_options *, const u_char *, u_int);
-extern void ip_print(netdissect_options *, const u_char *, u_int);
+extern void ip_print(netdissect_options *, const u_char *, const u_int);
 extern void ipcomp_print(netdissect_options *, const u_char *);
 extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
 extern void ipx_print(netdissect_options *, const u_char *, u_int);
index 62daa81a491b6dd01b4c9c37e65fddf2985cf382..f04353d312eb828c65ac9c33081e77111587360a 100644 (file)
@@ -318,7 +318,7 @@ static const struct tok ip_frag_values[] = {
 void
 ip_print(netdissect_options *ndo,
         const u_char *bp,
-        u_int length)
+        const u_int length)
 {
        const struct ip *ip;
        u_int off;
@@ -329,6 +329,7 @@ ip_print(netdissect_options *ndo,
        uint16_t sum, ip_sum;
        const char *p_name;
        int truncated = 0;
+       int presumed_tso = 0;
 
        ndo->ndo_protocol = "ip";
        ip = (const struct ip *)bp;
@@ -350,22 +351,14 @@ ip_print(netdissect_options *ndo,
                nd_print_invalid(ndo);
                ND_PRINT(" ");
        }
-       ND_TCHECK_SIZE(ip);
-       if (len < hlen) {
-#ifdef GUESS_TSO
-            if (len) {
-                ND_PRINT("bad-len %u", len);
-                return;
-            } else {
-                /* we guess that it is a TSO send */
-                len = length;
-            }
-#else
-            ND_PRINT("bad-len %u", len);
-            return;
-#endif /* GUESS_TSO */
-       }
+       if (len == 0) {
+               /* we guess that it is a TSO send */
+               len = length;
+               presumed_tso = 1;
+       } else
+               ND_ICHECKMSG_U("total length", len, <, hlen);
 
+       ND_TCHECK_SIZE(ip);
        /*
         * Cut off the snapshot length to the end of the IP payload.
         */
@@ -418,7 +411,10 @@ ip_print(netdissect_options *ndo,
                          tok2str(ipproto_values, "unknown", ip_proto),
                          ip_proto);
 
-            ND_PRINT(", length %u", GET_BE_U_2(ip->ip_len));
+           if (presumed_tso)
+                ND_PRINT(", length %u [was 0, presumed TSO]", length);
+           else
+                ND_PRINT(", length %u", GET_BE_U_2(ip->ip_len));
 
             if ((hlen - sizeof(struct ip)) > 0) {
                 ND_PRINT(", options (");
index fc9d47062da0fc44ce5f3676135bbda7ad619b1f..4919e044836b6fd6a44cce6df62e1faa1f870ce1 100644 (file)
@@ -1267,7 +1267,8 @@ part of a fragmented datagram or not.
 and \fBDF\fP is reported if F is set.  If neither are set, \fB.\fP is
 reported.
 \fIproto\fP is the protocol ID field.
-\fIlength\fP is the total length field.
+\fIlength\fP is the total length field; if the packet is a presumed TSO
+(TCP Segmentation Offload) send, [was 0, presumed TSO] is reported.
 \fIoptions\fP are the IP options, if any.
 .LP
 Next, for TCP and UDP packets, the source and destination IP addresses
index b820d480cb3e70d6a70c44372427f1fcc65b6ffd..1bd08d1e65fb5350d28079eadef6530fc5b197bf 100644 (file)
@@ -309,6 +309,8 @@ ipv4_invalid_length ipv4_invalid_length.pcap ipv4_invalid_length.out -v
 ipv4_invalid_hdr_length ipv4_invalid_hdr_length.pcap ipv4_invalid_hdr_length.out -v
 ipv4_invalid_total_length ipv4_invalid_total_length.pcap ipv4_invalid_total_length.out -v
 ipv4_tcp_http_xml ipv4_tcp_http_xml.pcap ipv4_tcp_http_xml.out -v
+ipv4_invalid_total_length_2 ipv4_invalid_total_length_2.pcap ipv4_invalid_total_length_2.out -v
+ipv4_tcp_http_xml_tso ipv4_tcp_http_xml_tso.pcap ipv4_tcp_http_xml_tso.out -v
 
 #IPv6 tests
 ipv6-bad-version       ipv6-bad-version.pcap   ipv6-bad-version.out
diff --git a/tests/ipv4_invalid_total_length_2.out b/tests/ipv4_invalid_total_length_2.out
new file mode 100644 (file)
index 0000000..d5136c0
--- /dev/null
@@ -0,0 +1 @@
+    1  08:57:44.621711 IP  [total length 19 < 20] (invalid)
diff --git a/tests/ipv4_invalid_total_length_2.pcap b/tests/ipv4_invalid_total_length_2.pcap
new file mode 100644 (file)
index 0000000..c9111be
Binary files /dev/null and b/tests/ipv4_invalid_total_length_2.pcap differ
diff --git a/tests/ipv4_tcp_http_xml_tso.out b/tests/ipv4_tcp_http_xml_tso.out
new file mode 100644 (file)
index 0000000..16b7110
--- /dev/null
@@ -0,0 +1,14 @@
+    1  19:50:14.587897 IP (tos 0x0, ttl 128, id 17097, offset 0, flags [DF], proto TCP (6), length 2016 [was 0, presumed TSO], bad cksum 0 (->d8df)!)
+    30.7.181.121.39556 > 199.43.68.163.8080: Flags [P.], cksum 0xdf55 (incorrect -> 0x9cf2), seq 1891338696:1891340672, ack 727404759, win 256, length 1976: HTTP, length: 1976
+       POST http://gwm-ml-a2.wsodqa.com//research/module-loader/module-loader.asp?user_id=test HTTP/1.1
+       Content-Type: text/xml; charset=utf-8
+       SOAPAction: ""
+       User-Agent: Axis/1.4-LISA
+       lisaFrameRoot: true
+       lisaFrameRemoteIP: 169.254.169.30
+       lisaFrameID: 3ae1f0b0-0293-11e2-aa16-78e7d164f804
+       Host: gwm-ml-a2.wsodqa.com
+       Proxy-Connection: Keep-Alive
+       Content-Length: 1607
+       
+       <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetResponse xmlns="http://tempuri.org/"><req><wgt wID="143"><inpt><mxRltm>false</mxRltm><hlds><HoldingsCount>0</HoldingsCount></hlds><wtlsts /><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt><wgt wID="151"><inpt><mxRltm>false</mxRltm><lnkUrls><url><key>RUN_RIReviewMarketsUI_RevMktNews</key><val>/RIReviewMarketsUI/RevMktNews.aspx</val></url><url><key>RUN_RIReviewMarketsUI_RevMktNewsFullStory</key><val>/RIReviewMarketsUI/RevMktNewsFullStory.aspx</val></url></lnkUrls><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt><wgt wID="144"><inpt><mxRltm>false</mxRltm><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt><wgt wID="146"><inpt><mxRltm>false</mxRltm><lnkUrls><url><key>RUN_RIStocksUI_RIStocksOverview</key><val>/RIStocksUI/RIStocksOverview.aspx</val></url><url><key>RUN_RIMutualFundsUI_RIMFOverview</key><val>/RIMutualFundsUI/RIMFOverview.aspx</val></url><url><key>RUN_RIEtfsUI_RIEtfsOverview</key><val>/RIEtfsUI/RIEtfsOverview.aspx</val></url><url><key>RUN_RIOptionsUI_RIOptionsOverview</key><val>/RIOptionsUI/RIOptionsOverview.aspx</val></url></lnkUrls><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt><wgt wID="145"><inpt><mxRltm>false</mxRltm><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt><wgt wID="147"><inpt><mxRltm>false</mxRltm><BondType /><IsCollapsed>false</IsCollapsed></inpt></wgt></req></GetResponse></soap:Body></soap:Envelope>
diff --git a/tests/ipv4_tcp_http_xml_tso.pcap b/tests/ipv4_tcp_http_xml_tso.pcap
new file mode 100644 (file)
index 0000000..976a0af
Binary files /dev/null and b/tests/ipv4_tcp_http_xml_tso.pcap differ