Skip to content

Commit 3465ec4

Browse files
committed
IP: Enable TSO (TCP Segmentation Offload) support
It's a follow-up to c862396. 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.
1 parent 7d5de0b commit 3465ec4

File tree

8 files changed

+34
-20
lines changed

8 files changed

+34
-20
lines changed

netdissect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ extern void igmp_print(netdissect_options *, const u_char *, u_int);
664664
extern void igrp_print(netdissect_options *, const u_char *, u_int);
665665
extern void ip6_print(netdissect_options *, const u_char *, u_int);
666666
extern void ipN_print(netdissect_options *, const u_char *, u_int);
667-
extern void ip_print(netdissect_options *, const u_char *, u_int);
667+
extern void ip_print(netdissect_options *, const u_char *, const u_int);
668668
extern void ipcomp_print(netdissect_options *, const u_char *);
669669
extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
670670
extern void ipx_print(netdissect_options *, const u_char *, u_int);

print-ip.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static const struct tok ip_frag_values[] = {
318318
void
319319
ip_print(netdissect_options *ndo,
320320
const u_char *bp,
321-
u_int length)
321+
const u_int length)
322322
{
323323
const struct ip *ip;
324324
u_int off;
@@ -329,6 +329,7 @@ ip_print(netdissect_options *ndo,
329329
uint16_t sum, ip_sum;
330330
const char *p_name;
331331
int truncated = 0;
332+
int presumed_tso = 0;
332333

333334
ndo->ndo_protocol = "ip";
334335
ip = (const struct ip *)bp;
@@ -350,22 +351,14 @@ ip_print(netdissect_options *ndo,
350351
nd_print_invalid(ndo);
351352
ND_PRINT(" ");
352353
}
353-
ND_TCHECK_SIZE(ip);
354-
if (len < hlen) {
355-
#ifdef GUESS_TSO
356-
if (len) {
357-
ND_PRINT("bad-len %u", len);
358-
return;
359-
} else {
360-
/* we guess that it is a TSO send */
361-
len = length;
362-
}
363-
#else
364-
ND_PRINT("bad-len %u", len);
365-
return;
366-
#endif /* GUESS_TSO */
367-
}
354+
if (len == 0) {
355+
/* we guess that it is a TSO send */
356+
len = length;
357+
presumed_tso = 1;
358+
} else
359+
ND_ICHECKMSG_U("total length", len, <, hlen);
368360

361+
ND_TCHECK_SIZE(ip);
369362
/*
370363
* Cut off the snapshot length to the end of the IP payload.
371364
*/
@@ -418,7 +411,10 @@ ip_print(netdissect_options *ndo,
418411
tok2str(ipproto_values, "unknown", ip_proto),
419412
ip_proto);
420413

421-
ND_PRINT(", length %u", GET_BE_U_2(ip->ip_len));
414+
if (presumed_tso)
415+
ND_PRINT(", length %u [was 0, presumed TSO]", length);
416+
else
417+
ND_PRINT(", length %u", GET_BE_U_2(ip->ip_len));
422418

423419
if ((hlen - sizeof(struct ip)) > 0) {
424420
ND_PRINT(", options (");

tcpdump.1.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2121
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2222
.\"
23-
.TH TCPDUMP 1 "09 Sep 2023"
23+
.TH TCPDUMP 1 "20 September 2023"
2424
.SH NAME
2525
tcpdump \- dump traffic on a network
2626
.SH SYNOPSIS
@@ -1288,7 +1288,8 @@ part of a fragmented datagram or not.
12881288
and \fBDF\fP is reported if F is set. If neither are set, \fB.\fP is
12891289
reported.
12901290
\fIproto\fP is the protocol ID field.
1291-
\fIlength\fP is the total length field.
1291+
\fIlength\fP is the total length field; if the packet is a presumed TSO
1292+
(TCP Segmentation Offload) send, [was 0, presumed TSO] is reported.
12921293
\fIoptions\fP are the IP options, if any.
12931294
.LP
12941295
Next, for TCP and UDP packets, the source and destination IP addresses

tests/TESTLIST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ ipv4_invalid_length ipv4_invalid_length.pcap ipv4_invalid_length.out -v
351351
ipv4_invalid_hdr_length ipv4_invalid_hdr_length.pcap ipv4_invalid_hdr_length.out -v
352352
ipv4_invalid_total_length ipv4_invalid_total_length.pcap ipv4_invalid_total_length.out -v
353353
ipv4_tcp_http_xml ipv4_tcp_http_xml.pcap ipv4_tcp_http_xml.out -v
354+
ipv4_invalid_total_length_2 ipv4_invalid_total_length_2.pcap ipv4_invalid_total_length_2.out -v
355+
ipv4_tcp_http_xml_tso ipv4_tcp_http_xml_tso.pcap ipv4_tcp_http_xml_tso.out -v
354356

355357
#IPv6 tests
356358
ipv6-bad-version ipv6-bad-version.pcap ipv6-bad-version.out
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 08:57:44.621711 IP [total length 19 < 20] (invalid)
138 Bytes
Binary file not shown.

tests/ipv4_tcp_http_xml_tso.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
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)!)
2+
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
3+
POST http://gwm-ml-a2.wsodqa.com//research/module-loader/module-loader.asp?user_id=test HTTP/1.1
4+
Content-Type: text/xml; charset=utf-8
5+
SOAPAction: ""
6+
User-Agent: Axis/1.4-LISA
7+
lisaFrameRoot: true
8+
lisaFrameRemoteIP: 169.254.169.30
9+
lisaFrameID: 3ae1f0b0-0293-11e2-aa16-78e7d164f804
10+
Host: gwm-ml-a2.wsodqa.com
11+
Proxy-Connection: Keep-Alive
12+
Content-Length: 1607
13+
14+
<?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>

tests/ipv4_tcp_http_xml_tso.pcap

2.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)