Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Apr 2018 15:44:30 +0000 (UTC)
From:      "Jonathan T. Looney" <jtl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r332829 - stable/11/sys/netinet
Message-ID:  <201804201544.w3KFiUcn097845@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jtl
Date: Fri Apr 20 15:44:29 2018
New Revision: 332829
URL: https://svnweb.freebsd.org/changeset/base/332829

Log:
  MFC r307083:
   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 when processing packets
   received for ESTABLISHED sessions.
  
   If INVARIANTS is defined, the code still needs to access both variables to
   check that so->so_options is consistent with the state.
  
  Sponsored by:	Netflix, Inc.

Modified:
  stable/11/sys/netinet/tcp_input.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/tcp_input.c
==============================================================================
--- stable/11/sys/netinet/tcp_input.c	Fri Apr 20 15:41:33 2018	(r332828)
+++ stable/11/sys/netinet/tcp_input.c	Fri Apr 20 15:44:29 2018	(r332829)
@@ -1071,11 +1071,11 @@ relocked:
 	 * state) we look into the SYN cache if this is a new connection
 	 * attempt or the completion of a previous one.
 	 */
-	if (so->so_options & SO_ACCEPTCONN) {
+	KASSERT(tp->t_state == TCPS_LISTEN || !(so->so_options & SO_ACCEPTCONN),
+	    ("%s: so accepting but tp %p not listening", __func__, tp));
+	if (tp->t_state == TCPS_LISTEN && (so->so_options & SO_ACCEPTCONN)) {
 		struct in_conninfo inc;
 
-		KASSERT(tp->t_state == TCPS_LISTEN, ("%s: so accepting but "
-		    "tp not listening", __func__));
 		bzero(&inc, sizeof(inc));
 #ifdef INET6
 		if (isipv6) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804201544.w3KFiUcn097845>