Date: Thu, 1 Apr 2021 15:20:32 GMT From: Richard Scheffenegger <rscheff@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 9aef4e7c2bd4 - main - tcp: Shouldn't drain empty sbuf Message-ID: <202104011520.131FKWvR059439@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=9aef4e7c2bd4371e526e4e3feb26064d361ad8ce commit 9aef4e7c2bd4371e526e4e3feb26064d361ad8ce Author: Richard Scheffenegger <rscheff@FreeBSD.org> AuthorDate: 2021-04-01 15:18:04 +0000 Commit: Richard Scheffenegger <rscheff@FreeBSD.org> CommitDate: 2021-04-01 15:18:38 +0000 tcp: Shouldn't drain empty sbuf MFC after: 2 weeks Reviewed By: tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29524 --- sys/netinet/tcp_hostcache.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index 36439e90a611..a8c4b2b178cd 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -644,6 +644,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) const int linesize = 128; struct sbuf sb; int i, error, len; + bool do_drain = false; struct hc_metrics *hc_entry; char ip4buf[INET_ADDRSTRLEN]; #ifdef INET6 @@ -701,9 +702,16 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) hc_entry->rmx_hits, hc_entry->rmx_updates, hc_entry->rmx_expire); + do_drain = true; } THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); - sbuf_drain(&sb); + /* Need to track if sbuf has data, to avoid + * a KASSERT when calling sbuf_drain. + */ + if (do_drain) { + sbuf_drain(&sb); + do_drain = false; + } } #undef msec error = sbuf_finish(&sb); @@ -769,7 +777,7 @@ tcp_hc_purge_internal(int all) KASSERT(V_tcp_hostcache.hashbase[i].hch_length > 0 && V_tcp_hostcache.hashbase[i].hch_length <= V_tcp_hostcache.bucket_limit, - ("tcp_hostcache: bucket langth out of range at %u: %u", + ("tcp_hostcache: bucket length out of range at %u: %u", i, V_tcp_hostcache.hashbase[i].hch_length)); if (all || hc_entry->rmx_expire <= 0) { TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104011520.131FKWvR059439>