Page MenuHomeFreeBSD

Avoid accessing the socket memory in tcp_input() for ESTABLISHED sessions
ClosedPublic

Authored by jtl on Oct 11 2016, 8:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 29, 3:29 AM
Unknown Object (File)
Aug 4 2025, 8:46 PM
Unknown Object (File)
Jun 26 2025, 8:16 AM
Unknown Object (File)
Jun 24 2025, 9:20 PM
Unknown Object (File)
Jun 15 2025, 1:27 PM
Unknown Object (File)
Jun 13 2025, 7:11 PM
Unknown Object (File)
May 30 2025, 3:41 AM
Unknown Object (File)
Apr 21 2025, 10:05 AM
Subscribers

Details

Reviewers
gallatin
rrs
jtl
Group Reviewers
transport
Summary

Currently, when tcp_input() receives a packet on a session that matches a TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or not the socket is a listening socket. However, this causes the code to access a different cacheline. If we first check if the socket is in the LISTEN state, we can avoid accessing so->so_options for ESTABLISHED packets.

If INVARIANTS is defined, the code still needs to access both to check that so->so_options is consistent with the state. (That's just the penalty you pay for running INVARIANTS.)

Test Plan

I tested this with live traffic. It works.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 5550
Build 5784: arc lint + arc unit

Event Timeline

jtl retitled this revision from to Avoid accessing the socket memory in tcp_input() for ESTABLISHED sessions.
jtl updated this object.
jtl edited the test plan for this revision. (Show Details)
jtl added reviewers: rrs, gallatin.
gallatin edited edge metadata.
jtl added a reviewer: jtl.
This revision is now accepted and ready to land.Oct 12 2016, 2:27 AM