HomeFreeBSD

in_pcb: limit the effect of wraparound in TCP random port allocation check

Description

in_pcb: limit the effect of wraparound in TCP random port allocation check

The check to see if TCP port allocation should change from random to
sequential port allocation mode may incorrectly cause a false positive
due to negative wraparound.
Example:

V_ipport_tcpallocs = 2147483585 (0x7fffffc1)
V_ipport_tcplastcount = 2147483553 (0x7fffffa1)
V_ipport_randomcps = 100

The original code would compare (2147483585 <= -2147483643) and thus
incorrectly move to sequential allocation mode.

Compute the delta first before comparing against the desired limit to
limit the wraparound effect (since tcplastcount is always a snapshot
of a previous tcpallocs).

Details

Provenance
peter.lei_ieee.orgAuthored on Dec 3 2021, 8:38 PM
glebiusCommitted on Dec 3 2021, 8:38 PM
Parents
rGf32357be53d0: sctp: use the correct traffic class when sending SCTP/IPv6 packets
Branches
Unknown
Tags
Unknown