Date: Thu, 31 Oct 2024 16:59:15 GMT From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 5818c74e34a8 - stable/13 - tcp: small cleanup Message-ID: <202410311659.49VGxFdw072281@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=5818c74e34a8e5139cda8d57cea51b23d24dfde5 commit 5818c74e34a8e5139cda8d57cea51b23d24dfde5 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2024-10-01 15:32:18 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2024-10-31 16:58:53 +0000 tcp: small cleanup No functional change intended. Reviewed by: cc, glebius, markj, rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D46850 (cherry picked from commit 2eacb0841c7dfc92030abc433e53cd31383a0648) --- sys/netinet/tcp_syncache.c | 59 ++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index b5b7e90ebefd..f3d7d626b7ca 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1609,49 +1609,46 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, goto donenoprobe; } - if (tfo_cookie_valid) { - bzero(&scs, sizeof(scs)); - sc = &scs; - goto skip_alloc; - } - + KASSERT(sc == NULL, ("sc(%p) != NULL", sc)); /* * Skip allocating a syncache entry if we are just going to discard * it later. */ - if (!locked) { + if (!locked || tfo_cookie_valid) { bzero(&scs, sizeof(scs)); sc = &scs; - } else - sc = uma_zalloc(V_tcp_syncache.zone, M_NOWAIT | M_ZERO); - if (sc == NULL) { - /* - * The zone allocator couldn't provide more entries. - * Treat this as if the cache was full; drop the oldest - * entry and insert the new one. - */ - TCPSTAT_INC(tcps_sc_zonefail); - if ((sc = TAILQ_LAST(&sch->sch_bucket, sch_head)) != NULL) { - sch->sch_last_overflow = time_uptime; - syncache_drop(sc, sch); - syncache_pause(inc); - } + } else { sc = uma_zalloc(V_tcp_syncache.zone, M_NOWAIT | M_ZERO); if (sc == NULL) { - if (V_tcp_syncookies) { - bzero(&scs, sizeof(scs)); - sc = &scs; - } else { - KASSERT(locked, - ("%s: bucket unexpectedly unlocked", - __func__)); - SCH_UNLOCK(sch); - goto done; + /* + * The zone allocator couldn't provide more entries. + * Treat this as if the cache was full; drop the oldest + * entry and insert the new one. + */ + TCPSTAT_INC(tcps_sc_zonefail); + sc = TAILQ_LAST(&sch->sch_bucket, sch_head); + if (sc != NULL) { + sch->sch_last_overflow = time_uptime; + syncache_drop(sc, sch); + syncache_pause(inc); + } + sc = uma_zalloc(V_tcp_syncache.zone, M_NOWAIT | M_ZERO); + if (sc == NULL) { + if (V_tcp_syncookies) { + bzero(&scs, sizeof(scs)); + sc = &scs; + } else { + KASSERT(locked, + ("%s: bucket unexpectedly unlocked", + __func__)); + SCH_UNLOCK(sch); + goto done; + } } } } -skip_alloc: + KASSERT(sc != NULL, ("sc == NULL")); if (!tfo_cookie_valid && tfo_response_cookie_valid) sc->sc_tfo_cookie = &tfo_response_cookie;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410311659.49VGxFdw072281>