From nobody Sat Aug 03 22:51:47 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wbych0xGjz5RTr1; Sat, 03 Aug 2024 22:51:48 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wbycg5ZyTz4L49; Sat, 3 Aug 2024 22:51:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722725507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FsfX2SKPBOez9pcjN6CnowrUTufRkkpt6goTuko2/oU=; b=ZbK2kPwGERsz0McmJLBBv6D+1utc5yPX7wDJnWnt8V8fpvu0ySOLs2Ug1RyFaC/HFYGRrs yTbB434FudFURrTi533pWE26lAPPsds5sbjdTYo54X4eP2ettr2KWIDILV6NTuPgpj8qbH Rs3GJAyMNx1MpBKp3xs0Dr90AAuLw8iUhAIx3nxtSn5JlltXKCfxCjBVhmyi1roaGqYfH2 4czeCyxPtoGer5nnIJNPf0pFvDSrZodZwklQvCWGivEWM/rprk4FAkVv7sl4afo09fWCXY 9PtERMroYGUkaPc0ZmyyNp4vbonAuM5lldSCLOXc5d3rxa6P3b6dfF0UUexUgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722725507; a=rsa-sha256; cv=none; b=RTMouPkNuJampds8HqleA6bMpRQJ0XimaWnblolc5BIcOJ25gGvhvbAEQP0Tcmp1XPdfjQ YO3dLDIQp9dM+Fsgg98KmMRL0EdnIZPNnqao6cBTaHJAo2e0PZMEQlR7evlvWO44T30Add UwKxn1JJ1W75cktUjCTNN762XXTNjlDiy1FMorPP5o25zHMWUFMagrcBaa/qwlSlkfiY+o gGZcKBLwWDckR0zO3aNgyzE68BUkK+GVoLhTXeq7pTlr7wMCigLKhU7E/hpbEkqRqlV4Iv 7/PFwNB+WE50VocE1Plq4byIX7vQzUAMj673NMCoZ3HByB0tLfiy5FljDYGdlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722725507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FsfX2SKPBOez9pcjN6CnowrUTufRkkpt6goTuko2/oU=; b=bLIOdRfsQrIspJC0Ws7wDjExjXffDOXozgmggnlvsWBW6p+DtuPPuXY0WpzqNO8HMvt2lv L9sQMVfLQzvilkeBdb4gGu+MJijeUQJT1eHvs+djQ2my1fE0C9DbnqKBPcYEfCAyBLKiHl HVbapQ6DP8lUtltfEgvubpMEWdloh6WCZZssOCOBrMzmiuOnNGxFhOtCJWvY4dGfIglQLb Bcsxy09iTwPeoBe72/zMazYDFqRt96JhOVUH17yBSqVZEUZZ84IqF4IEaf7n2ofspFi37B ErIDegavLAWh/oiXY2NagK1LR/Bl4wYCXF0cLdIgBiB7SiuvPVk9xSAfPI6Dcw== 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 4Wbycg4KZVzWkd; Sat, 3 Aug 2024 22:51:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 473Mpl7a073399; Sat, 3 Aug 2024 22:51:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 473Mpl2F073396; Sat, 3 Aug 2024 22:51:47 GMT (envelope-from git) Date: Sat, 3 Aug 2024 22:51:47 GMT Message-Id: <202408032251.473Mpl2F073396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 94508d2fe471 - stable/14 - tcp: minor cleanup List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 94508d2fe471bb30520799843e47309f08cd90f9 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=94508d2fe471bb30520799843e47309f08cd90f9 commit 94508d2fe471bb30520799843e47309f08cd90f9 Author: Michael Tuexen AuthorDate: 2024-06-29 09:06:35 +0000 Commit: Michael Tuexen CommitDate: 2024-08-03 22:51:19 +0000 tcp: minor cleanup Fix two KASSERTs to catch the condition they are intended to, add two asserts to ensure that the appropriate locking is in place and fix some things related to style. No functional change intended. Sponsored by: Netflix, Inc. (cherry picked from commit 811d831050d172a39c714a3f676722cf9a496a6f) --- sys/netinet/tcp_subr.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 8785963cc7d0..8ae9018f1e5d 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -437,23 +437,25 @@ static struct tcp_function_block * find_tcp_functions_locked(struct tcp_function_set *fs) { struct tcp_function *f; - struct tcp_function_block *blk=NULL; + struct tcp_function_block *blk = NULL; + rw_assert(&tcp_function_lock, RA_LOCKED); TAILQ_FOREACH(f, &t_functions, tf_next) { if (strcmp(f->tf_name, fs->function_set_name) == 0) { blk = f->tf_fb; break; } } - return(blk); + return (blk); } static struct tcp_function_block * find_tcp_fb_locked(struct tcp_function_block *blk, struct tcp_function **s) { - struct tcp_function_block *rblk=NULL; + struct tcp_function_block *rblk = NULL; struct tcp_function *f; + rw_assert(&tcp_function_lock, RA_LOCKED); TAILQ_FOREACH(f, &t_functions, tf_next) { if (f->tf_fb == blk) { rblk = blk; @@ -476,7 +478,7 @@ find_and_ref_tcp_functions(struct tcp_function_set *fs) if (blk) refcount_acquire(&blk->tfb_refcnt); rw_runlock(&tcp_function_lock); - return(blk); + return (blk); } struct tcp_function_block * @@ -489,7 +491,7 @@ find_and_ref_tcp_fb(struct tcp_function_block *blk) if (rblk) refcount_acquire(&rblk->tfb_refcnt); rw_runlock(&tcp_function_lock); - return(rblk); + return (rblk); } /* Find a matching alias for the given tcp_function_block. */ @@ -690,7 +692,7 @@ out: static int sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) { - int error=ENOENT; + int error = ENOENT; struct tcp_function_set fs; struct tcp_function_block *blk; @@ -708,7 +710,7 @@ sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) /* Check for error or no change */ if (error != 0 || req->newptr == NULL) - return(error); + return (error); rw_wlock(&tcp_function_lock); blk = find_tcp_functions_locked(&fs); @@ -1217,9 +1219,9 @@ register_tcp_functions_as_names(struct tcp_function_block *blk, int wait, struct tcp_function_set fs; int error, i; - KASSERT(names != NULL && *num_names > 0, - ("%s: Called with 0-length name list", __func__)); KASSERT(names != NULL, ("%s: Called with NULL name list", __func__)); + KASSERT(*num_names > 0, + ("%s: Called with non-positive length of name list", __func__)); KASSERT(rw_initialized(&tcp_function_lock), ("%s: called too early", __func__)); @@ -1266,7 +1268,7 @@ register_tcp_functions_as_names(struct tcp_function_block *blk, int wait, tcp_fb_cnt++; rw_wunlock(&tcp_function_lock); } - return(0); + return (0); cleanup: /* @@ -4378,7 +4380,7 @@ tcp_req_check_for_stale_entries(struct tcpcb *tp, uint64_t ts, int rm_oldest) uint64_t time_delta, oldest_delta; int i, oldest, oldest_set = 0, cnt_rm = 0; - for(i = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0; i < MAX_TCP_TRK_REQ; i++) { ent = &tp->t_tcpreq_info[i]; if (ent->flags != TCP_TRK_TRACK_FLG_USED) { /* @@ -4421,15 +4423,15 @@ tcp_req_check_for_stale_entries(struct tcpcb *tp, uint64_t ts, int rm_oldest) int tcp_req_check_for_comp(struct tcpcb *tp, tcp_seq ack_point) { - int i, ret=0; + int i, ret = 0; struct tcp_sendfile_track *ent; /* Clean up any old closed end requests that are now completed */ if (tp->t_tcpreq_req == 0) - return(0); + return (0); if (tp->t_tcpreq_closed == 0) - return(0); - for(i = 0; i < MAX_TCP_TRK_REQ; i++) { + return (0); + for (i = 0; i < MAX_TCP_TRK_REQ; i++) { ent = &tp->t_tcpreq_info[i]; /* Skip empty ones */ if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) @@ -4452,11 +4454,11 @@ int tcp_req_is_entry_comp(struct tcpcb *tp, struct tcp_sendfile_track *ent, tcp_seq ack_point) { if (tp->t_tcpreq_req == 0) - return(-1); + return (-1); if (tp->t_tcpreq_closed == 0) - return(-1); + return (-1); if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) - return(-1); + return (-1); if (SEQ_GEQ(ack_point, ent->end_seq)) { return (1); } @@ -4478,7 +4480,7 @@ tcp_req_find_a_req_that_is_completed_by(struct tcpcb *tp, tcp_seq th_ack, int *i /* none open */ return (NULL); } - for(i = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0; i < MAX_TCP_TRK_REQ; i++) { ent = &tp->t_tcpreq_info[i]; if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) continue; @@ -4502,7 +4504,7 @@ tcp_req_find_req_for_seq(struct tcpcb *tp, tcp_seq seq) /* none open */ return (NULL); } - for(i = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0; i < MAX_TCP_TRK_REQ; i++) { ent = &tp->t_tcpreq_info[i]; tcp_req_log_req_info(tp, ent, i, TCP_TRK_REQ_LOG_SEARCH, (uint64_t)seq, 0); @@ -4550,7 +4552,7 @@ tcp_req_alloc_req_full(struct tcpcb *tp, struct tcp_snd_req *req, uint64_t ts, i (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ)); /* Check to see if this is a duplicate of one not started */ if (tp->t_tcpreq_req) { - for(i = 0, allocated = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0, allocated = 0; i < MAX_TCP_TRK_REQ; i++) { fil = &tp->t_tcpreq_info[i]; if (fil->flags != TCP_TRK_TRACK_FLG_USED) continue; @@ -4565,20 +4567,20 @@ tcp_req_alloc_req_full(struct tcpcb *tp, struct tcp_snd_req *req, uint64_t ts, i * a 4xx of some sort and its going to age * out, lets not duplicate it. */ - return(fil); + return (fil); } } } /* Ok if there is no room at the inn we are in trouble */ if (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ) { tcp_trace_point(tp, TCP_TP_REQ_LOG_FAIL); - for(i = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0; i < MAX_TCP_TRK_REQ; i++) { tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_ALLOCFAIL, 0, 0); } return (NULL); } - for(i = 0, allocated = 0; i < MAX_TCP_TRK_REQ; i++) { + for (i = 0, allocated = 0; i < MAX_TCP_TRK_REQ; i++) { fil = &tp->t_tcpreq_info[i]; if (fil->flags == TCP_TRK_TRACK_FLG_EMPTY) { allocated = 1;