From nobody Tue Jul 02 13:22:34 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 4WD3Vf2GDKz5QRhl; Tue, 02 Jul 2024 13:22:34 +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 4WD3Vf1Ks8z4ylP; Tue, 2 Jul 2024 13:22:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719926554; 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=TfOIPUkOS3dOIFwDL1oMOO+xwWnqPy7YL8yt3W/+yVw=; b=MpOIQSo9Gn0CF+VLTmeLoWEIoh/K3zMVenBvlz1qf4IawyVx6KcN+sValaAgi9eMHDVVYj y21yISCiF5Li05eG4ak3R0rZlgxLTawVuqIoeXre4LHu6A9r0NiiKhTE/kS69aWMJvoS1B 6i7fCqkYYOQQRLNRbjdy45EXquud6RYYy8ya20YkR0v9Zmwz/jYGYaNI+5iu8OwLJojW+7 RZHJ6taIM4Ei/gWe8XzDx208vOK7jeyQaxdh+3U3JguaNfsIR+F8yM75jukI73TMjdOSXQ yCalV/idwM/Y7k6WkIN1T+/5V3Uo2qRA55J/bTQrdbd8eYqEdN2kJR2rgFUImg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719926554; a=rsa-sha256; cv=none; b=uamIWNV6SflAMHQqHJKJ1XBUtyzN84MfrkjRatMX1Iq+SVU9V3zW7H1Lh9nkY6YU7yxoUB wiOBeEHKeLLNNkFPxh9UR+NmWMFr2Vk/jd/SAbfl6VTRcOvuf0CG6f3IwhCHqBd3+LfV8K ll14cCm/BU2hqYZ2QDMnTcrcl9xrbaAQJ6CEO0zy0NJRFymub5A/jAgbibyjW2n6Idwjgc ep/40cLVrUXICo3h2HEk/hdjjvONcPbq56a24gU62NGR0fCIL5dkZ6khbzDL31+b7KkAMb G634DjYtQ+6O73BFVujYGJwGUoTZv8U9Q/jOWsyUGl3jmyMOWAszowyQslLXcQ== 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=1719926554; 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=TfOIPUkOS3dOIFwDL1oMOO+xwWnqPy7YL8yt3W/+yVw=; b=DM0QsCja2IhyRVbSO5nGZYcmtfugNdbXAXMBGF8stHNuCdfcF7zXNUz4iwlvi0V/F7Bi2r Yru50P5846LItTqi/Q5+oIp5xenIKtk2qNyKaf/GNjzTUIVTomPTLdpTcMFsEZyp0bZYrd tPcqJddAHRUeVrnU+Qni2N64gkyTFBwwS4rxT8offFLbBlFfI7OfQq9nxmpPESFi9MKREy L/5zEMgw7Z1JW3jMGvtDsvHYKXk40+VS4jKYDaCo+SMc3hr3ofpHZpwQt8SefCykMvxAcY sbDoRsDfZKFTNuc455jBkgCC8BLsAA4XGBNKpswfr6cMjwvxG2cY9TbQ2eJagA== 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 4WD3Vf0yDrzqQ5; Tue, 2 Jul 2024 13:22:34 +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 462DMYGM021126; Tue, 2 Jul 2024 13:22:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 462DMYfT021123; Tue, 2 Jul 2024 13:22:34 GMT (envelope-from git) Date: Tue, 2 Jul 2024 13:22:34 GMT Message-Id: <202407021322.462DMYfT021123@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: 18babd824e11 - stable/14 - pf: Sprinkle const qualifiers in state lookup routines 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: 18babd824e112d89057a01e2a21359dd5f464f0c Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=18babd824e112d89057a01e2a21359dd5f464f0c commit 18babd824e112d89057a01e2a21359dd5f464f0c Author: Mark Johnston AuthorDate: 2024-06-24 14:46:55 +0000 Commit: Mark Johnston CommitDate: 2024-07-02 13:19:29 +0000 pf: Sprinkle const qualifiers in state lookup routines State keys are trivially const in lookup routines, so annotate them as such. No functional change intended. Reviewed by: kp MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Modirum Differential Revision: https://reviews.freebsd.org/D45671 (cherry picked from commit 66b8cac8d837c0ca3fd38d0a66259ca932a1c430) --- sys/net/pfvar.h | 8 +++++--- sys/netpfil/pf/pf.c | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 27428ad161f8..1c932026aeb3 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -2231,9 +2231,11 @@ pf_release_staten(struct pf_kstate *s, u_int n) } extern struct pf_kstate *pf_find_state_byid(uint64_t, uint32_t); -extern struct pf_kstate *pf_find_state_all(struct pf_state_key_cmp *, +extern struct pf_kstate *pf_find_state_all( + const struct pf_state_key_cmp *, u_int, int *); -extern bool pf_find_state_all_exists(struct pf_state_key_cmp *, +extern bool pf_find_state_all_exists( + const struct pf_state_key_cmp *, u_int); extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *, struct pf_krule *, sa_family_t, @@ -2514,7 +2516,7 @@ struct pf_krule *pf_get_translation(struct pf_pdesc *, struct mbuf *, struct pf_state_key *pf_state_key_setup(struct pf_pdesc *, struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t); -struct pf_state_key *pf_state_key_clone(struct pf_state_key *); +struct pf_state_key *pf_state_key_clone(const struct pf_state_key *); void pf_rule_to_actions(struct pf_krule *, struct pf_rule_actions *); int pf_normalize_mss(struct mbuf *m, int off, diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index ae0c5dcf8128..6671839fc5ab 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -361,7 +361,7 @@ static void pf_print_state_parts(struct pf_kstate *, static void pf_patch_8(struct mbuf *, u_int16_t *, u_int8_t *, u_int8_t, bool, u_int8_t); static struct pf_kstate *pf_find_state(struct pfi_kkif *, - struct pf_state_key_cmp *, u_int); + const struct pf_state_key_cmp *, u_int); static int pf_src_connlimit(struct pf_kstate **); static void pf_overload_task(void *v, int pending); static u_short pf_insert_src_node(struct pf_ksrc_node **, @@ -627,11 +627,11 @@ pf_packet_rework_nat(struct mbuf *m, struct pf_pdesc *pd, int off, } static __inline uint32_t -pf_hashkey(struct pf_state_key *sk) +pf_hashkey(const struct pf_state_key *sk) { uint32_t h; - h = murmur3_32_hash32((uint32_t *)sk, + h = murmur3_32_hash32((const uint32_t *)sk, sizeof(struct pf_state_key_cmp)/sizeof(uint32_t), V_pf_hashseed); @@ -1477,7 +1477,7 @@ pf_state_key_setup(struct pf_pdesc *pd, struct pf_addr *saddr, } struct pf_state_key * -pf_state_key_clone(struct pf_state_key *orig) +pf_state_key_clone(const struct pf_state_key *orig) { struct pf_state_key *sk; @@ -1576,7 +1576,8 @@ pf_find_state_byid(uint64_t id, uint32_t creatorid) * Returns with ID hash slot locked on success. */ static struct pf_kstate * -pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) +pf_find_state(struct pfi_kkif *kif, const struct pf_state_key_cmp *key, + u_int dir) { struct pf_keyhash *kh; struct pf_state_key *sk; @@ -1585,7 +1586,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); - kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; + kh = &V_pf_keyhash[pf_hashkey((const struct pf_state_key *)key)]; PF_HASHROW_LOCK(kh); LIST_FOREACH(sk, &kh->keys, entry) @@ -1623,7 +1624,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) * Returns with ID hash slot locked on success. */ struct pf_kstate * -pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) +pf_find_state_all(const struct pf_state_key_cmp *key, u_int dir, int *more) { struct pf_keyhash *kh; struct pf_state_key *sk; @@ -1632,7 +1633,7 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); - kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; + kh = &V_pf_keyhash[pf_hashkey((const struct pf_state_key *)key)]; PF_HASHROW_LOCK(kh); LIST_FOREACH(sk, &kh->keys, entry) @@ -1689,7 +1690,7 @@ second_run: * removing it. */ bool -pf_find_state_all_exists(struct pf_state_key_cmp *key, u_int dir) +pf_find_state_all_exists(const struct pf_state_key_cmp *key, u_int dir) { struct pf_kstate *s;