From nobody Thu Oct 13 18:38:57 2022 X-Original-To: dev-commits-src-main@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 4MpJFY607pz4fMdt; Thu, 13 Oct 2022 18:38:57 +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 4MpJFY5Tgwz3w2l; Thu, 13 Oct 2022 18:38:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665686337; 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=B3y26d0DNRqhOMTDJ/eQQrsZW875aazsQHwaXh5bnh8=; b=TCee7tlhKRVH1XX0Mnlaqk9Fzu3Y/vqTEypybXkPUE94rJPbNH4vKU3B+1IW+ET/xDXnpM OOiibmj/cMmPHApbELtHuwJVi445/E3KVWC4JYh1XjL37WTwj3FFQtp0xEkNXzmqcblYfP +X3BX/bBiTsRAnjNCtnGEPA3wR1bvTeNol37xDziNpazyhbnKmuaqzeYGmUql06QOnb88e C4iqZXXifiOrUDRbBHHhQjeSZjZOmhbB7C7ih0kUnfcad4NFQac+jPCAtEKGzIu8TBtdIX 5K7K0nHcXXpdHrZbVRKXpofXcjSqiH9qc7cjZR5HLk1Z1bLQgEWJ92w+d9jh0Q== 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 4MpJFY4YT0zWlD; Thu, 13 Oct 2022 18:38:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29DIcvPJ035250; Thu, 13 Oct 2022 18:38:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29DIcvRs035249; Thu, 13 Oct 2022 18:38:57 GMT (envelope-from git) Date: Thu, 13 Oct 2022 18:38:57 GMT Message-Id: <202210131838.29DIcvRs035249@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 3ba34b07a4c0 - main - inpcb: provide in_pcbremhash() to reduce copy-paste List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ba34b07a4c031245362602e1d057c19c992bad2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665686337; 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=B3y26d0DNRqhOMTDJ/eQQrsZW875aazsQHwaXh5bnh8=; b=loAaSF1ce/QddHxgdKO2MhZVIM/XrO/BZ/J7qkbYZg3pxQHST1P1S932zOhd5g/Vk/Np6t JaTsRhR5/0DaCGvkEN8Wk1PkgT53jMubRmf4GLd64X7bC6b60rhl0cTw+v7YE1uAG+EIWs UEXGJB8/6wHkZn/1MoBNwwnt/BXikJda6/rtuMGJbsYXaXfxIVzGrsgaGWYryZ+8b+NG/H lEz+DZCmIvdQvW4qTxvlI8W8q7azfzmp6+pU7cDoBG6vuCD18pjD5nCh0Wd7q9GIxhJi70 yMR3F9uzIxDGWXhrOeW7egafcHgRkibdRa4TMZMrWy0N+hFb+wZ3MEITW3RGGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665686337; a=rsa-sha256; cv=none; b=banQQKrKao1l5xAclFFm8Z4kGqJXnyBpaA8lvdrqnoGQHFwHTRRARFHUYzgg+twKcwJaj7 BiQWQ1uGPfMOc8BontEgAF8h8IrJH1eZzSP9aHERHjPVzInpe4SF4YzUFBKWyPHVt2wnnS XWnzCfPG1iV6vIggIs/07b+6CXSKTAH2zrHzINSd2IH609u2tb+1uz+asjDP1Hu7J7RYJo Cmj+phNa5n+napajFuxRUu6DY8CSH25DZidpQoCaF4269reiuaHMTV2dEnSNFadhHlFtPY rFzRywJVFk4USLZPLBWgUisi21zU+c/7rOk3cmHbisOy6vLasxS7b5EiEMPGsQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3ba34b07a4c031245362602e1d057c19c992bad2 commit 3ba34b07a4c031245362602e1d057c19c992bad2 Author: Gleb Smirnoff AuthorDate: 2022-10-13 16:03:38 +0000 Commit: Gleb Smirnoff CommitDate: 2022-10-13 16:03:38 +0000 inpcb: provide in_pcbremhash() to reduce copy-paste --- sys/netinet/in_pcb.c | 61 +++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 75889b2011ac..25c8d70843d5 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -258,6 +258,8 @@ in_pcbhashseed_init(void) VNET_SYSINIT(in_pcbhashseed_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, in_pcbhashseed_init, 0); +static void in_pcbremhash(struct inpcb *); + /* * in_pcb.c: manage the Protocol Control Blocks. * @@ -1839,22 +1841,8 @@ in_pcbfree(struct inpcb *inp) CK_LIST_REMOVE(inp, inp_list); INP_INFO_WUNLOCK(pcbinfo); - if (inp->inp_flags & INP_INHASHLIST) { - struct inpcbport *phd = inp->inp_phd; - - INP_HASH_WLOCK(pcbinfo); - /* XXX: Only do if SO_REUSEPORT_LB set? */ - in_pcbremlbgrouphash(inp); - - CK_LIST_REMOVE(inp, inp_hash); - CK_LIST_REMOVE(inp, inp_portlist); - if (CK_LIST_FIRST(&phd->phd_pcblist) == NULL) { - CK_LIST_REMOVE(phd, phd_hash); - uma_zfree_smr(pcbinfo->ipi_portzone, phd); - } - INP_HASH_WUNLOCK(pcbinfo); - inp->inp_flags &= ~INP_INHASHLIST; - } + if (inp->inp_flags & INP_INHASHLIST) + in_pcbremhash(inp); RO_INVALIDATE_CACHE(&inp->inp_route); #ifdef MAC @@ -1936,25 +1924,9 @@ in_pcbdrop(struct inpcb *inp) MPASS(inp->inp_refcount > 1); #endif - /* - * XXXRW: Possibly we should protect the setting of INP_DROPPED with - * the hash lock...? - */ inp->inp_flags |= INP_DROPPED; - if (inp->inp_flags & INP_INHASHLIST) { - struct inpcbport *phd = inp->inp_phd; - - INP_HASH_WLOCK(inp->inp_pcbinfo); - in_pcbremlbgrouphash(inp); - CK_LIST_REMOVE(inp, inp_hash); - CK_LIST_REMOVE(inp, inp_portlist); - if (CK_LIST_FIRST(&phd->phd_pcblist) == NULL) { - CK_LIST_REMOVE(phd, phd_hash); - uma_zfree_smr(inp->inp_pcbinfo->ipi_portzone, phd); - } - INP_HASH_WUNLOCK(inp->inp_pcbinfo); - inp->inp_flags &= ~INP_INHASHLIST; - } + if (inp->inp_flags & INP_INHASHLIST) + in_pcbremhash(inp); } #ifdef INET @@ -2534,6 +2506,27 @@ in_pcbinshash(struct inpcb *inp) return (0); } +static void +in_pcbremhash(struct inpcb *inp) +{ + struct inpcbport *phd = inp->inp_phd; + + INP_WLOCK_ASSERT(inp); + MPASS(inp->inp_flags & INP_INHASHLIST); + + INP_HASH_WLOCK(inp->inp_pcbinfo); + /* XXX: Only do if SO_REUSEPORT_LB set? */ + in_pcbremlbgrouphash(inp); + CK_LIST_REMOVE(inp, inp_hash); + CK_LIST_REMOVE(inp, inp_portlist); + if (CK_LIST_FIRST(&phd->phd_pcblist) == NULL) { + CK_LIST_REMOVE(phd, phd_hash); + uma_zfree_smr(inp->inp_pcbinfo->ipi_portzone, phd); + } + INP_HASH_WUNLOCK(inp->inp_pcbinfo); + inp->inp_flags &= ~INP_INHASHLIST; +} + /* * Move PCB to the proper hash bucket when { faddr, fport } have been * changed. NOTE: This does not handle the case of the lport changing (the