Page MenuHomeFreeBSD

tcp: Push bit failure to set in fastpath
ClosedPublic

Authored by rrs on Feb 21 2022, 4:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 11, 11:18 PM
Unknown Object (File)
Mon, Dec 9, 1:18 PM
Unknown Object (File)
Fri, Dec 6, 11:37 PM
Unknown Object (File)
Oct 25 2024, 5:21 AM
Unknown Object (File)
Oct 5 2024, 5:17 AM
Unknown Object (File)
Oct 5 2024, 5:17 AM
Unknown Object (File)
Oct 5 2024, 5:17 AM
Unknown Object (File)
Oct 5 2024, 5:17 AM

Details

Summary

Recently changes were made to the tcp stack to use a macro/function
to set tcp flags. In the process the PUSH bit setting in the fastpath of
rack was broken. This fixes that as well as cleans up a warning that
is occurring when you don't have INVARIANT on (inp used in KASSERT).

We can use the tcp test suite to find this bug the test plan shows the script
that fails due to the missing push bit

Test Plan

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
//

--ip_version=ipv4
--tolerance_usecs=50000

0.00 sysctl -w net.inet.tcp.hostcache.purgenow=1
+0.00 sysctl -w net.inet.tcp.syncookies_only=0
+0.00 sysctl -w net.inet.tcp.syncookies=1
+0.00 sysctl -w net.inet.tcp.rfc1323=0
+0.00 sysctl -w net.inet.tcp.sack.enable=0
+0.00 sysctl -w net.inet.tcp.ecn.enable=2
+0.00 sysctl -w net.inet.tcp.recvspace=65536

+0.00 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.00 fcntl(3, F_GETFL) = 0x02 (flags O_RDWR)
+0.00 fcntl(3, F_SETFL, O_RDWR | O_NONBLOCK) = 0
+0.00 setsockopt(3, IPPROTO_TCP, TCP_NOOPT, [1], 4) = 0
+0.00 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
+0.00 > S 0:0(0) win 65535
+0.05 < S 0:0(0) win 65535 <sackOK,TS val 100 ecr 0>
+0.00 > S. 0:0(0) ack 1 win 65535
+0.00 < . 1:1(0) ack 1 win 65535
+0.00 %{ assert tcpi_state == TCPI_ESTABLISHED }%
+0.00 %{ assert tcpi_options == 0}%
+0.05 write(3, ..., 5360) = 5360
+0.00 > . 1:537(536) ack 1 win 65535
+0.00 > . 537:1073(536) ack 1 win 65535
+0.00 > . 1073:1609(536) ack 1 win 65535
+0.00 > . 1609:2145(536) ack 1 win 65535
+0.00 > . 2145:2681(536) ack 1 win 65535
+0.00 > . 2681:3217(536) ack 1 win 65535
+0.00 > . 3217:3753(536) ack 1 win 65535
+0.00 > . 3753:4289(536) ack 1 win 65535
+0.00 > . 4289:4825(536) ack 1 win 65535
+0.00 > P. 4825:5361(536) ack 1 win 65535

// Validate DupThresh loss recovery works
+0.01 < . 1:1(0) ack 537 win 65535
+0.01 < . 1:1(0) ack 537 win 65535
+0.01 < . 1:1(0) ack 537 win 65535
+0.01 < . 1:1(0) ack 537 win 65535
+0.00 > . 537:1073(536) ack 1 win 65535

// Verify that no SACK block is sent out
+0.00 < . 10:20(10) ack 5361 win 65535
+0.00 > . 5361:5361(0) ack 1 win 65535

+0.01 close(3) = 0

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rrs requested review of this revision.Feb 21 2022, 4:38 PM
rscheff requested changes to this revision.Feb 21 2022, 5:58 PM

Sorry for the oversight.

sys/netinet/tcp_stacks/rack.c
16222

This should have been '''flags |= TH_PUSH''' here, since

16238

down here, tcp_ecn_output_established() will set some of the TCP header flags.

16252

Thus, the flags have to be transferred to the header only after all else.

This revision now requires changes to proceed.Feb 21 2022, 5:58 PM
sys/netinet/tcp_stacks/rack.c
16222

I am fine with that, I will move the line back down.. I was
just following what your earlier code changes had done... I
believe before your changes it *was* a flags |= TH_PUSH :)

changes back to what it was before i.e. a |= and moved the flags
set back down.

rrs marked an inline comment as done.Feb 22 2022, 10:06 PM

Possibly - probably missed this over my iterations. Thanks!

This revision is now accepted and ready to land.Feb 22 2022, 10:20 PM
sys/netinet/tcp_stacks/rack.c
6262

Why not use:

struct inpcb *inp = tp->t_inpcb;

This reduces one #ifdef...

6264

Please keep an empty line between the declarations and the code.

rrs marked 2 inline comments as done.
This revision was automatically updated to reflect the committed changes.