]> The Tcpdump Group git mirrors - tcpdump/commitdiff
TCP: Fix Reset segment processing
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 1 Nov 2024 21:20:24 +0000 (22:20 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 2 Nov 2024 15:11:03 +0000 (16:11 +0100)
When a received RST segment contains data, this is diagnostic data that
explains the cause of the RST.

So we have to stop processing, even if we don't print the data (no "-v").

Rename two test outputs, with "-v" in the names.
Add two test cases (existing pcap printed without "-v").

(cherry picked from commit 7f9a48502c3003fd80e0be79d80f572bf667216a)

print-tcp.c
tests/TESTLIST
tests/tcp_rst_data-trunc-v.out [new file with mode: 0644]
tests/tcp_rst_data-trunc.out
tests/tcp_rst_data-v.out [new file with mode: 0644]
tests/tcp_rst_data.out

index 5680d4324da9a4cf160c279381a9022219074752..aa75602150526b2f627f94113ec5d194d4b10c0c 100644 (file)
@@ -720,8 +720,11 @@ tcp_print(netdissect_options *ndo,
                 nd_trunc_longjmp(ndo);
         }
         bp += header_len;
-        if ((flags & TH_RST) && ndo->ndo_vflag) {
-                print_tcp_rst_data(ndo, bp, length);
+        if (flags & TH_RST) {
+                if(ndo->ndo_vflag)
+                        print_tcp_rst_data(ndo, bp, length);
+                else
+                        ND_TCHECK_LEN(bp, length);
                 return;
         }
 
index fc0bb4b90c8b79cb09d6935bfff9ecacdc693c92..a42f5d32c91eaf5a622d1ac4f425b89c22f90620 100644 (file)
@@ -20,9 +20,11 @@ print-A              print-flags.pcap        print-A.out     -A
 print-AA       print-flags.pcap        print-AA.out    -AA
 
 # TCP with data in the RST segment
-tcp_rst_data tcp_rst_data.pcap tcp_rst_data.out -v
+tcp_rst_data tcp_rst_data.pcap tcp_rst_data-v.out -v
+tcp_rst_data tcp_rst_data.pcap tcp_rst_data.out
 # TCP with data in the RST segment, truncated example
-tcp_rst_data-trunc tcp_rst_data-trunc.pcap tcp_rst_data-trunc.out -v
+tcp_rst_data-trunc tcp_rst_data-trunc.pcap tcp_rst_data-trunc-v.out -v
+tcp_rst_data-trunc tcp_rst_data-trunc.pcap tcp_rst_data-trunc.out
 
 # BGP tests
 bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -v
diff --git a/tests/tcp_rst_data-trunc-v.out b/tests/tcp_rst_data-trunc-v.out
new file mode 100644 (file)
index 0000000..0f25b0b
--- /dev/null
@@ -0,0 +1,2 @@
+    1  2013-02-26 22:03:19.190965 IP (tos 0x20, ttl 243, id 8243, offset 0, flags [DF], proto TCP (6), length 98)
+    199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], seq 1617159969:1617160027, ack 1936660873, win 5785, length 58 [!RST+ BIG-IP: [0x11c5672:3045] {peer]
index 0f25b0b475068aa75745bca705d4fe32c444cd33..e368f365ffc01c41e18425b7642f95e85f433349 100644 (file)
@@ -1,2 +1 @@
-    1  2013-02-26 22:03:19.190965 IP (tos 0x20, ttl 243, id 8243, offset 0, flags [DF], proto TCP (6), length 98)
-    199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], seq 1617159969:1617160027, ack 1936660873, win 5785, length 58 [!RST+ BIG-IP: [0x11c5672:3045] {peer]
+    1  2013-02-26 22:03:19.190965 IP 199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], seq 1617159969:1617160027, ack 1936660873, win 5785, length 58 [|tcp]
diff --git a/tests/tcp_rst_data-v.out b/tests/tcp_rst_data-v.out
new file mode 100644 (file)
index 0000000..13f7700
--- /dev/null
@@ -0,0 +1,2 @@
+    1  2013-02-26 22:03:19.190965 IP (tos 0x20, ttl 243, id 8243, offset 0, flags [DF], proto TCP (6), length 98)
+    199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], cksum 0x8471 (correct), seq 1617159969:1617160027, ack 1936660873, win 5785, length 58 [RST+ BIG-IP: [0x11c5672:3045] {peer]
index 13f77006044eba81e274913558d14e2da9ac0364..d43424c286b03f181210a260f1e5549688fe1f97 100644 (file)
@@ -1,2 +1 @@
-    1  2013-02-26 22:03:19.190965 IP (tos 0x20, ttl 243, id 8243, offset 0, flags [DF], proto TCP (6), length 98)
-    199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], cksum 0x8471 (correct), seq 1617159969:1617160027, ack 1936660873, win 5785, length 58 [RST+ BIG-IP: [0x11c5672:3045] {peer]
+    1  2013-02-26 22:03:19.190965 IP 199.204.31.89.80 > 172.16.133.41.52875: Flags [R.], seq 1617159969:1617160027, ack 1936660873, win 5785, length 58