From owner-dev-commits-src-all@freebsd.org Mon Apr 12 15:28:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20CED5D4648; Mon, 12 Apr 2021 15:28:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJt1T07nvz4b1B; Mon, 12 Apr 2021 15:28:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9D4C19A3C; Mon, 12 Apr 2021 15:28:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13CFSi3G076227; Mon, 12 Apr 2021 15:28:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13CFSixm076226; Mon, 12 Apr 2021 15:28:44 GMT (envelope-from git) Date: Mon, 12 Apr 2021 15:28:44 GMT Message-Id: <202104121528.13CFSixm076226@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 8d5719aa74f1 - main - syncache: simplify syncache_add() KPI to return struct socket pointer directly, not overwriting the listen socket pointer argument. Not a functional change. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d5719aa74f1d1441ee5ee365d45d53f934e81d6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 15:28:45 -0000 The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=8d5719aa74f1d1441ee5ee365d45d53f934e81d6 commit 8d5719aa74f1d1441ee5ee365d45d53f934e81d6 Author: Gleb Smirnoff AuthorDate: 2021-03-19 05:05:22 +0000 Commit: Gleb Smirnoff CommitDate: 2021-04-12 15:27:40 +0000 syncache: simplify syncache_add() KPI to return struct socket pointer directly, not overwriting the listen socket pointer argument. Not a functional change. --- sys/netinet/tcp_input.c | 3 ++- sys/netinet/tcp_syncache.c | 32 +++++++++++++++----------------- sys/netinet/tcp_syncache.h | 4 ++-- sys/netinet/toecore.c | 4 ++-- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index f69262230a05..cfb0989a7203 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1341,7 +1341,8 @@ tfo_socket_result: #endif TCP_PROBE3(debug__input, tp, th, m); tcp_dooptions(&to, optp, optlen, TO_SYN); - if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL, iptos)) + if ((so = syncache_add(&inc, &to, th, inp, so, m, NULL, NULL, + iptos)) != NULL) goto tfo_socket_result; /* diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index b1a0c1f7e229..7c6bad415d7d 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1322,24 +1322,25 @@ failed: return (0); } -static void -syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m, +static struct socket * +syncache_tfo_expand(struct syncache *sc, struct socket *lso, struct mbuf *m, uint64_t response_cookie) { struct inpcb *inp; struct tcpcb *tp; unsigned int *pending_counter; + struct socket *so; NET_EPOCH_ASSERT(); - pending_counter = intotcpcb(sotoinpcb(*lsop))->t_tfo_pending; - *lsop = syncache_socket(sc, *lsop, m); - if (*lsop == NULL) { + pending_counter = intotcpcb(sotoinpcb(lso))->t_tfo_pending; + so = syncache_socket(sc, lso, m); + if (so == NULL) { TCPSTAT_INC(tcps_sc_aborted); atomic_subtract_int(pending_counter, 1); } else { - soisconnected(*lsop); - inp = sotoinpcb(*lsop); + soisconnected(so); + inp = sotoinpcb(so); tp = intotcpcb(inp); tp->t_flags |= TF_FASTOPEN; tp->t_tfo_cookie.server = response_cookie; @@ -1348,6 +1349,8 @@ syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m, tp->t_tfo_pending = pending_counter; TCPSTAT_INC(tcps_sc_completed); } + + return (so); } /* @@ -1369,20 +1372,19 @@ syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m, * be ACKed either when the application sends response data or the delayed * ACK timer expires, whichever comes first. */ -int +struct socket * syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, - struct inpcb *inp, struct socket **lsop, struct mbuf *m, void *tod, + struct inpcb *inp, struct socket *so, struct mbuf *m, void *tod, void *todctx, uint8_t iptos) { struct tcpcb *tp; - struct socket *so; + struct socket *rv = NULL; struct syncache *sc = NULL; struct syncache_head *sch; struct mbuf *ipopts = NULL; u_int ltflags; int win, ip_ttl, ip_tos; char *s; - int rv = 0; #ifdef INET6 int autoflowlabel = 0; #endif @@ -1405,7 +1407,6 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, * Combine all so/tp operations very early to drop the INP lock as * soon as possible. */ - so = *lsop; KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so)); tp = sototcpcb(so); cred = crhold(so->so_cred); @@ -1734,9 +1735,8 @@ skip_alloc: SCH_UNLOCK(sch); if (tfo_cookie_valid) { - syncache_tfo_expand(sc, lsop, m, tfo_response_cookie); + rv = syncache_tfo_expand(sc, so, m, tfo_response_cookie); /* INP_RUNLOCK(inp) will be performed by the caller */ - rv = 1; goto tfo_expanded; } @@ -1761,10 +1761,8 @@ skip_alloc: done: TCP_PROBE5(receive, NULL, NULL, m, NULL, th); donenoprobe: - if (m) { - *lsop = NULL; + if (m) m_freem(m); - } /* * If tfo_pending is not NULL here, then a TFO SYN that did not * result in a new socket was processed and the associated pending diff --git a/sys/netinet/tcp_syncache.h b/sys/netinet/tcp_syncache.h index 37575a14467c..c56dce55f1c1 100644 --- a/sys/netinet/tcp_syncache.h +++ b/sys/netinet/tcp_syncache.h @@ -43,8 +43,8 @@ void syncache_destroy(void); void syncache_unreach(struct in_conninfo *, tcp_seq); int syncache_expand(struct in_conninfo *, struct tcpopt *, struct tcphdr *, struct socket **, struct mbuf *); -int syncache_add(struct in_conninfo *, struct tcpopt *, - struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *, +struct socket * syncache_add(struct in_conninfo *, struct tcpopt *, + struct tcphdr *, struct inpcb *, struct socket *, struct mbuf *, void *, void *, uint8_t); void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *); void syncache_badack(struct in_conninfo *); diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c index 28cbd8b43e4f..f602319ef701 100644 --- a/sys/netinet/toecore.c +++ b/sys/netinet/toecore.c @@ -348,11 +348,11 @@ void toe_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, struct inpcb *inp, void *tod, void *todctx, uint8_t iptos) { - struct socket *lso = inp->inp_socket; INP_WLOCK_ASSERT(inp); - syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx, iptos); + (void )syncache_add(inc, to, th, inp, inp->inp_socket, NULL, tod, + todctx, iptos); } int