From nobody Sun Jan 07 16:58:08 2024 X-Original-To: dev-commits-src-all@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 4T7Ng43TKqz55Qp9; Sun, 7 Jan 2024 16:58:08 +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 4T7Ng42wf9z4DNR; Sun, 7 Jan 2024 16:58:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704646688; 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=5d+Sol2mtBKJiK0s3Cc7uVBEEbauhL/y0GklwrRl68A=; b=rlqmulJdHKpW9pEANQfTHRhjilhvdEmLskkiYtA3hLbK3eT5IOYKEbanIf9mSxr7BU/mJK SA9gJx2Sz5ez1uGj73zQzDYwYuhUwHQLPHktiKgzx/SI7tjH2L6J8Z3yE7yTJOg3bFNuOF Y8W35xUJF0tlqagQETFSRrRS7kuGmklEsksreyoFUC78s75d35dvlW610XPlxUzH/tAMUC BzHUcxhKMFkpb6ERaTiMbUY1Fn2bGHxEwyGXpYHV4d41tuRdtXYmaUV7eCS7KO1JB/7ZtH 3AuCJTSi0IJOWqjzk4xkOKPijLC/sEfh80OI36c/q26qYGBlYQzou28Pv0bzlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704646688; 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=5d+Sol2mtBKJiK0s3Cc7uVBEEbauhL/y0GklwrRl68A=; b=C3ySAFW4wEIL/9NyBnOf0Asl9CTCn1U5/dlLuQVus7+gog426OTlG8hokUTBtRChyQA1Ox qLqmZqml+OwZdVPLQ85A4wG33wYWVYFH35TkiRgjPMBBJ+Ou5YHGgSmzLspf4mZbnR0E9m OKK3mtewMJdFEFxNuhnBoq9xzp6EO97frLypA22hH66JaBFSiXjwDQ6WpPSpkHjAvaDPZq vAiKcEDoOTWBZ7igU7aeQUFMkzRcD0mCv667aPBVAqafJcGTt8CXpXykVXXBTMgWtsKtgj SWoOc/Legmjf23wiz+l2M2Ox+hWPJenMgfJhiXB6MsiEfK/5jmyOrrU8R2qZsQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704646688; a=rsa-sha256; cv=none; b=S97IWc65vdtcDUptT0Lt4HXbOIaSQejlSpsmGjeAchjan8M2Z2GB5IjAts+IqqAOwKRI5f aVwfEv0OHVd3Q7lPcsiAwXEiReluKG3R7J8N8trUqC2sy1ibf9Jl2AQbbIccv3ef4pyhsX EsYaRqi5CI98z39UVQRAid6asN+NhBTxgZBDlr5/nstgV29DwbRfu0W5mNZ0FE5d8FX9CY FNYPUGBcyfr99R5Xib7zwBSaMqs2j4+1tHiyngkoUcZRQy/MyWaFtvJ4+T4i1tIolW/XJq EwchmCmIZnW+FKa146dkQRKDaeppcS+f5bawkh0ocC2ZGx8YuAismL0AqtrUuw== 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 4T7Ng41y94zXWf; Sun, 7 Jan 2024 16:58:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 407Gw8Y9029007; Sun, 7 Jan 2024 16:58:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 407Gw8jZ029004; Sun, 7 Jan 2024 16:58:08 GMT (envelope-from git) Date: Sun, 7 Jan 2024 16:58:08 GMT Message-Id: <202401071658.407Gw8jZ029004@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e4ca8864c2f3 - stable/14 - frag6: Reduce code duplication List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e4ca8864c2f34ee583483c2c50f2821a565e2b28 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e4ca8864c2f34ee583483c2c50f2821a565e2b28 commit e4ca8864c2f34ee583483c2c50f2821a565e2b28 Author: Mark Johnston AuthorDate: 2023-12-31 16:15:48 +0000 Commit: Mark Johnston CommitDate: 2024-01-07 16:55:40 +0000 frag6: Reduce code duplication The code which removes a fragment queue from the per-VNET hash table was duplicated three times. Factor it out into a function. No functional change intended. Reviewed by: kp, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43228 (cherry picked from commit 0736a38072b52204289c669770a34d0b801a8a7e) --- sys/netinet6/frag6.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index a3a6e7eca14a..fbdbc3ef2f28 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -288,6 +288,20 @@ ip6_deletefraghdr(struct mbuf *m, int offset, int wait __unused) return (0); } +static void +frag6_rmqueue(struct ip6q *q6, uint32_t bucket) +{ + IP6QB_LOCK_ASSERT(bucket); + + TAILQ_REMOVE(IP6QB_HEAD(bucket), q6, ip6q_tq); + V_ip6qb[bucket].count--; +#ifdef MAC + mac_ip6q_destroy(q6); +#endif + free(q6, M_FRAG6); + atomic_subtract_int(&V_frag6_nfragpackets, 1); +} + /* * Free a fragment reassembly header and all associated datagrams. */ @@ -324,14 +338,8 @@ frag6_freef(struct ip6q *q6, uint32_t bucket) free(af6, M_FRAG6); } - TAILQ_REMOVE(IP6QB_HEAD(bucket), q6, ip6q_tq); - V_ip6qb[bucket].count--; atomic_subtract_int(&frag6_nfrags, q6->ip6q_nfrag); -#ifdef MAC - mac_ip6q_destroy(q6); -#endif - free(q6, M_FRAG6); - atomic_subtract_int(&V_frag6_nfragpackets, 1); + frag6_rmqueue(q6, bucket); } /* @@ -637,15 +645,8 @@ frag6_input(struct mbuf **mp, int *offp, int proto) if (q6->ip6q_unfrglen >= 0) { /* The 1st fragment has already arrived. */ if (q6->ip6q_unfrglen + fragoff + frgpartlen > IPV6_MAXPACKET) { - if (only_frag) { - TAILQ_REMOVE(head, q6, ip6q_tq); - V_ip6qb[bucket].count--; - atomic_subtract_int(&V_frag6_nfragpackets, 1); -#ifdef MAC - mac_ip6q_destroy(q6); -#endif - free(q6, M_FRAG6); - } + if (only_frag) + frag6_rmqueue(q6, bucket); IP6QB_UNLOCK(bucket); icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset - sizeof(struct ip6_frag) + @@ -654,15 +655,8 @@ frag6_input(struct mbuf **mp, int *offp, int proto) return (IPPROTO_DONE); } } else if (fragoff + frgpartlen > IPV6_MAXPACKET) { - if (only_frag) { - TAILQ_REMOVE(head, q6, ip6q_tq); - V_ip6qb[bucket].count--; - atomic_subtract_int(&V_frag6_nfragpackets, 1); -#ifdef MAC - mac_ip6q_destroy(q6); -#endif - free(q6, M_FRAG6); - } + if (only_frag) + frag6_rmqueue(q6, bucket); IP6QB_UNLOCK(bucket); icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset - sizeof(struct ip6_frag) +