TCP connection ignore RST

From: Rozhuk Ivan <rozhuk.im_at_gmail.com>
Date: Fri, 03 Sep 2021 23:37:30 UTC
Hi!


I have strange case: FreeBSD 12.2 ignore TCP RST from windows host and continue retransmitting packets.
sockstat show that socket connected even after many tcp rst packets received.

Any ideas how to fix it?


System build from:
commit 8c01699f9194cfa3805ac734ae912529a10c063a
CommitDate: Wed Jan 20 14:40:13 2021 +0100
Add some examples to script.1...


root@sa# sockstat -P tcp -v -s -S -p 389
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS       PATH STATE   CONN STATE   STACK                           
a        s          2583  35 tcp4   192.168.33.89:62284   192.168.33.200:389                 ESTABLISHED  freebsd



root@sa# tcpdump -n -vvvvvvvv -i vmx0 tcp port 389
tcpdump: listening on vmx0, link-type EN10MB (Ethernet), capture size 262144 bytes
01:32:19.128521 IP (tos 0x0, ttl 128, id 40117, offset 0, flags [none], proto TCP (6), length 60)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [S], cksum 0xc4a0 (incorrect -> 0x4ba5), seq 3223907587, win 65535, options [mss 1460,nop,wscale 10,sackOK,TS val 3640114415 ecr 0], length 0
01:32:19.128918 IP (tos 0x0, ttl 128, id 22220, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [S.], cksum 0xca32 (correct), seq 1489249264, ack 3223907588, win 8192, options [mss 1460,nop,wscale 8,sackOK,TS val 124116297 ecr 3640114415], length 0
01:32:19.128949 IP (tos 0x0, ttl 128, id 42613, offset 0, flags [none], proto TCP (6), length 52)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [.], cksum 0xc498 (incorrect -> 0x10ff), seq 1, ack 1, win 2049, options [nop,nop,TS val 3640114415 ecr 124116297], length 0
01:32:19.129431 IP (tos 0x0, ttl 128, id 24596, offset 0, flags [none], proto TCP (6), length 86)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4ba (incorrect -> 0xe4b3), seq 1:35, ack 1, win 2049, options [nop,nop,TS val 3640114415 ecr 124116297], length 34
01:32:19.130310 IP (tos 0x0, ttl 128, id 22221, offset 0, flags [DF], proto TCP (6), length 74)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [P.], cksum 0x35bb (correct), seq 1:23, ack 35, win 260, options [nop,nop,TS val 124116297 ecr 3640114415], length 22
01:32:19.131230 IP (tos 0x0, ttl 128, id 54687, offset 0, flags [none], proto TCP (6), length 163)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc507 (incorrect -> 0x37f8), seq 35:146, ack 23, win 2049, options [nop,nop,TS val 3640114415 ecr 124116297], length 111
01:32:19.131560 IP (tos 0x0, ttl 128, id 22222, offset 0, flags [DF], proto TCP (6), length 585)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [P.], cksum 0x943d (correct), seq 23:556, ack 146, win 259, options [nop,nop,TS val 124116297 ecr 3640114415], length 533
01:32:19.133323 IP (tos 0x0, ttl 128, id 50714, offset 0, flags [none], proto TCP (6), length 198)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc52a (incorrect -> 0x0ba5), seq 146:292, ack 556, win 2049, options [nop,nop,TS val 3640114415 ecr 124116297], length 146
01:32:19.133861 IP (tos 0x0, ttl 128, id 22223, offset 0, flags [DF], proto TCP (6), length 471)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [P.], cksum 0x3b5d (correct), seq 556:975, ack 292, win 259, options [nop,nop,TS val 124116298 ecr 3640114415], length 419
01:32:19.135305 IP (tos 0x0, ttl 128, id 43284, offset 0, flags [none], proto TCP (6), length 115)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4d7 (incorrect -> 0xac6a), seq 292:355, ack 975, win 2049, options [nop,nop,TS val 3640114415 ecr 124116298], length 63
01:32:19.135900 IP (tos 0x0, ttl 128, id 22224, offset 0, flags [DF], proto TCP (6), length 1500)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [.], cksum 0x5ffb (correct), seq 975:2423, ack 355, win 258, options [nop,nop,TS val 124116298 ecr 3640114415], length 1448
01:32:19.135913 IP (tos 0x0, ttl 128, id 22225, offset 0, flags [DF], proto TCP (6), length 299)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [P.], cksum 0x7cb3 (correct), seq 2423:2670, ack 355, win 258, options [nop,nop,TS val 124116298 ecr 3640114415], length 247
01:32:19.135935 IP (tos 0x0, ttl 128, id 32903, offset 0, flags [none], proto TCP (6), length 52)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [.], cksum 0xc498 (incorrect -> 0x0530), seq 355, ack 2670, win 2048, options [nop,nop,TS val 3640114415 ecr 124116298], length 0
01:32:19.139239 IP (tos 0x0, ttl 128, id 64896, offset 0, flags [none], proto TCP (6), length 148)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4f8 (incorrect -> 0xd163), seq 355:451, ack 2670, win 2049, options [nop,nop,TS val 3640114425 ecr 124116298], length 96
01:32:19.139753 IP (tos 0x0, ttl 128, id 22226, offset 0, flags [DF], proto TCP (6), length 1218)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [P.], cksum 0x1c85 (correct), seq 2670:3836, ack 451, win 258, options [nop,nop,TS val 124116298 ecr 3640114425], length 1166
01:32:19.141672 IP (tos 0x0, ttl 128, id 37692, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xaddf), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640114425 ecr 124116298], length 7
01:32:19.141924 IP (tos 0x0, ttl 128, id 22227, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R.], cksum 0xbbe5 (correct), seq 3836, ack 458, win 0, length 0
01:32:19.408167 IP (tos 0x0, ttl 128, id 51302, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xacd0), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640114696 ecr 124116298], length 7
01:32:19.408464 IP (tos 0x0, ttl 128, id 22241, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:19.748075 IP (tos 0x0, ttl 128, id 56645, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xab7c), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640115036 ecr 124116298], length 7
01:32:19.748381 IP (tos 0x0, ttl 128, id 22244, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:20.228076 IP (tos 0x0, ttl 128, id 16474, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xa99c), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640115516 ecr 124116298], length 7
01:32:20.228470 IP (tos 0x0, ttl 128, id 22247, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:20.988094 IP (tos 0x0, ttl 128, id 51707, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xa6a4), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640116276 ecr 124116298], length 7
01:32:20.988405 IP (tos 0x0, ttl 128, id 22250, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:22.308132 IP (tos 0x0, ttl 128, id 29337, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0xa17c), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640117596 ecr 124116298], length 7
01:32:22.308280 IP (tos 0x0, ttl 128, id 22340, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:24.748054 IP (tos 0x0, ttl 128, id 14340, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0x97f4), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640120036 ecr 124116298], length 7
01:32:24.748345 IP (tos 0x0, ttl 128, id 22370, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:29.428068 IP (tos 0x0, ttl 128, id 33249, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0x85ac), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640124716 ecr 124116298], length 7
01:32:29.428395 IP (tos 0x0, ttl 128, id 22375, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:38.588058 IP (tos 0x0, ttl 128, id 30609, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0x61e4), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640133876 ecr 124116298], length 7
01:32:38.588490 IP (tos 0x0, ttl 128, id 22377, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:32:56.708045 IP (tos 0x0, ttl 128, id 37650, offset 0, flags [none], proto TCP (6), length 59)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc49f (incorrect -> 0x1b1c), seq 451:458, ack 3836, win 2049, options [nop,nop,TS val 3640151996 ecr 124116298], length 7
01:32:56.708403 IP (tos 0x0, ttl 128, id 22381, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:33:26.829653 IP (tos 0x0, ttl 128, id 6370, offset 0, flags [none], proto TCP (6), length 86)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4ba (incorrect -> 0xc579), seq 458:492, ack 3836, win 2049, options [nop,nop,TS val 3640182115 ecr 124116298], length 34
01:33:26.829919 IP (tos 0x0, ttl 128, id 22406, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:33:32.748171 IP (tos 0x0, ttl 128, id 54306, offset 0, flags [none], proto TCP (6), length 93)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4c1 (incorrect -> 0x6cff), seq 451:492, ack 3836, win 2049, options [nop,nop,TS val 3640188036 ecr 124116298], length 41
01:33:32.748576 IP (tos 0x0, ttl 128, id 22407, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:34:08.788230 IP (tos 0x0, ttl 128, id 31457, offset 0, flags [none], proto TCP (6), length 93)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4c1 (incorrect -> 0xe036), seq 451:492, ack 3836, win 2049, options [nop,nop,TS val 3640224076 ecr 124116298], length 41
01:34:08.788496 IP (tos 0x0, ttl 128, id 22427, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:34:44.828060 IP (tos 0x0, ttl 128, id 8424, offset 0, flags [none], proto TCP (6), length 93)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [P.], cksum 0xc4c1 (incorrect -> 0x536e), seq 451:492, ack 3836, win 2049, options [nop,nop,TS val 3640260116 ecr 124116298], length 41
01:34:44.828384 IP (tos 0x0, ttl 128, id 22429, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.33.200.389 > 192.168.33.89.62284: Flags [R], cksum 0xdf3b (correct), seq 1489253100, win 0, length 0
01:35:20.868093 IP (tos 0x0, ttl 128, id 1379, offset 0, flags [none], proto TCP (6), length 52)
    192.168.33.89.62284 > 192.168.33.200.389: Flags [R.], cksum 0xc498 (incorrect -> 0x4225), seq 492, ack 3836, win 0, options [nop,nop,TS val 3640296156 ecr 124116298], length 0