diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-03-19 05:05:22 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-04-12 15:27:40 +0000 |
commit | 8d5719aa74f1d1441ee5ee365d45d53f934e81d6 (patch) | |
tree | 94ee9db6ccf35cb14496b4ee9220c2778876c7ec /sys/netinet/tcp_syncache.c | |
parent | 08d9c9202755a30f97617758595214a530afcaea (diff) | |
download | src-8d5719aa74f1d1441ee5ee365d45d53f934e81d6.tar.gz src-8d5719aa74f1d1441ee5ee365d45d53f934e81d6.zip |
syncache: simplify syncache_add() KPI to return struct socket pointer
directly, not overwriting the listen socket pointer argument.
Not a functional change.
Diffstat (limited to 'sys/netinet/tcp_syncache.c')
-rw-r--r-- | sys/netinet/tcp_syncache.c | 32 |
1 files changed, 15 insertions, 17 deletions
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 |