When using dtrace to watch TCP state changes, not all transitions are caught.
The problem can be reproduced by running the dtrace script tcpstate.d while executing the packetdrill script close-wait-ipv4.pkt.
Without the patch, tcpstate.d reports while running close-wait-ipv4.pkt:
CPU DELTA(us) CID OLD NEW TIMESTAMP 1 101368577164 fffff8002957ecb0 state-closed -> state-listen 101368577164931 1 101368578541 fffff800294bcae0 state-closed -> state-syn-sent 101368578541920 1 107461 fffff800294bcae0 state-syn-sent -> state-established 101368686003429 1 108026 fffff800294bcae0 state-established -> state-close-wait 101368794029659 1 107957 fffff800294bcae0 state-close-wait -> state-last-ack 101368901986890
The state changes from state-listen to state-closed and from state-last-ack to state-closed are missing.
With the patch the corresponding output is
CPU DELTA(us) CID OLD NEW TIMESTAMP 3 33306868592 fffff800cfc173a0 state-closed -> state-listen 33306868592543 3 33306880517 fffff800cfc161d0 state-closed -> state-syn-sent 33306880517424 3 118265 fffff800cfc161d0 state-syn-sent -> state-established 33306998782931 3 117745 fffff800cfc161d0 state-established -> state-close-wait 33307116528533 3 118165 fffff800cfc161d0 state-close-wait -> state-last-ack 33307234694066 3 117779 fffff800cfc161d0 state-last-ack -> state-closed 33307352473996 3 647722 fffff800cfc173a0 state-listen -> state-closed 33307516315376
which shows these state changes.