From nobody Thu Jul 14 21:31:55 2022 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 4LkSP74BN8z4Sys7; Thu, 14 Jul 2022 21:31:55 +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 4LkSP73lJKz3fvl; Thu, 14 Jul 2022 21:31:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657834315; 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=MZEeyHLeTwDiem9MXAZtD5SG4Lyo36OwadJiD08PXpM=; b=cuBwIHMnjRMGV1JW1a5f4L1PVYRchbj/Gr4dEAFTyEipEm1747pyexxOXaTJBxbrVzL9IS PtEXK0vOHUXOoAeomDE4GV6ikakUnIb0bDhtSUO0mPT0LoFa7cL/LxVBPTVM6ZxDntNWt7 oY2OI7m+QuJg1LD8sEROfI247zdpohHDExg4p2tHunXaj08jwAxDYYOZfJoPQOm+KLj46E nmnRvwFRiB+tUdwgdR+9mg473F/VlgxPdcoTxALGx8r3XMAxdXHPvy1NNN9VrX22e/hyKn HB+LWQYSbP4nBCkTpy6zfYTfCrfOHxCqTmUn9jmWwEA+F67jP+H01q1zIv2FNA== 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 4LkSP72pQtzJ1F; Thu, 14 Jul 2022 21:31:55 +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 26ELVtYg093868; Thu, 14 Jul 2022 21:31:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26ELVtus093867; Thu, 14 Jul 2022 21:31:55 GMT (envelope-from git) Date: Thu, 14 Jul 2022 21:31:55 GMT Message-Id: <202207142131.26ELVtus093867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: bb4cbd0fcf3e - stable/12 - Simplify dynamic ipfilter sysctls. 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: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bb4cbd0fcf3ecb4b09f6fea9df174073bca20345 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657834315; 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=MZEeyHLeTwDiem9MXAZtD5SG4Lyo36OwadJiD08PXpM=; b=r0U9mQL1EMsfLdOa5p+OwkI0o672pbcNAfsjX2mkevpnOzB+ROsUB8y2oWErC1n40OheE5 Z1BKQ/JlaYwlaM7UD9YBBTBdiNYTAJBlsyj0M5PMxlXsm3L/y8+8IfIlI5bW70DD7ZVP6W OYl8V8YH7ZVs5tkII9jU863XOcsSuwgub8coDKsGnJpAmIxxIPuRDz0m35mJxZHtotptPb pReIOjglprBm6UDU5BBjkWaqIuhDgbDAkvYZ1xTgtXivsJSgWgqRVM7wy5pxZBk3E8DSdJ s7qDgIAWP6OYVb7wvrBpAEjKt52RlL2EkMX2fiwu64y6XrCtoftO7SzKFLLLYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657834315; a=rsa-sha256; cv=none; b=Z3+ZmbLQKaK/S4rueVP1o3F9pXUXHZPWKlhBsp1lFPCq/AxAAclBRzCot48Efe6P9yp+Rs Ck7a22QKinp5oEjknV/Rh2+3+fZtVWO/sK516MCnairX/nZuts1LIdyIfA1A/K4iG3GQzd rVEFb4WZy2gpPE6aOc5jpS6rL6gMQmBGcjUcKygIggRqiyKHsMuK49yCHvJLgDpT3NS2xl WJtfqIQeqHWXqNrhiQybRQTzw7s6t4xtjVxy9zsvAw8fmh/0lzTW3cX9bEVOodLTyT/YYO kOP3bgtjfAttlyx+xsOHVAHwfPeUQd3lNRTN4IMGpNX0r7x5mr4obSNBKZkHKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=bb4cbd0fcf3ecb4b09f6fea9df174073bca20345 commit bb4cbd0fcf3ecb4b09f6fea9df174073bca20345 Author: John Baldwin AuthorDate: 2021-01-21 00:33:34 +0000 Commit: Cy Schubert CommitDate: 2022-07-14 13:20:26 +0000 Simplify dynamic ipfilter sysctls. Pass the structure offset in arg2 instead of arg1. This avoids having to undo the pointer arithmetic on arg1. Instead arg2 can be used directly as an offset relative to the desired structure. Reviewed by: cy Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27961 (cherry picked from commit d86d3194955c3063baeed27de4bc84dfe7a7187d) --- sys/netpfil/ipfilter/netinet/mlfk_ipl.c | 86 ++++++++++++--------------------- 1 file changed, 30 insertions(+), 56 deletions(-) diff --git a/sys/netpfil/ipfilter/netinet/mlfk_ipl.c b/sys/netpfil/ipfilter/netinet/mlfk_ipl.c index bf511eb0483f..36ddc29453be 100644 --- a/sys/netpfil/ipfilter/netinet/mlfk_ipl.c +++ b/sys/netpfil/ipfilter/netinet/mlfk_ipl.c @@ -363,77 +363,51 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS ) } /* - * In the VIMAGE case kern_sysctl.c already adds the vnet base address given - * we set CTLFLAG_VNET to get proper access checks. Have to undo this. - * Then we add the given offset to the specific malloced struct hanging off - * virtualized ipmain struct. + * arg2 holds the offset of the relevant member in the virtualized + * ipfmain structure. */ static int sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS ) { + ipf_nat_softc_t *nat_softc; - if (arg1) { - ipf_nat_softc_t *nat_softc; + nat_softc = V_ipfmain.ipf_nat_soft; + arg1 = (void *)((uintptr_t)nat_softc + arg2); - nat_softc = V_ipfmain.ipf_nat_soft; -#ifdef VIMAGE - arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); -#endif - arg1 = (void *)((uintptr_t)nat_softc + (uintptr_t)arg1); - } - - return (sysctl_ipf_int(oidp, arg1, arg2, req)); + return (sysctl_ipf_int(oidp, arg1, 0, req)); } static int sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS ) { + ipf_state_softc_t *state_softc; - if (arg1) { - ipf_state_softc_t *state_softc; - - state_softc = V_ipfmain.ipf_state_soft; -#ifdef VIMAGE - arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); -#endif - arg1 = (void *)((uintptr_t)state_softc + (uintptr_t)arg1); - } + state_softc = V_ipfmain.ipf_state_soft; + arg1 = (void *)((uintptr_t)state_softc + arg2); - return (sysctl_ipf_int(oidp, arg1, arg2, req)); + return (sysctl_ipf_int(oidp, arg1, 0, req)); } static int sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS ) { + ipf_auth_softc_t *auth_softc; - if (arg1) { - ipf_auth_softc_t *auth_softc; + auth_softc = V_ipfmain.ipf_auth_soft; + arg1 = (void *)((uintptr_t)auth_softc + arg2); - auth_softc = V_ipfmain.ipf_auth_soft; -#ifdef VIMAGE - arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); -#endif - arg1 = (void *)((uintptr_t)auth_softc + (uintptr_t)arg1); - } - - return (sysctl_ipf_int(oidp, arg1, arg2, req)); + return (sysctl_ipf_int(oidp, arg1, 0, req)); } static int sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS ) { + ipf_frag_softc_t *frag_softc; - if (arg1) { - ipf_frag_softc_t *frag_softc; - - frag_softc = V_ipfmain.ipf_frag_soft; -#ifdef VIMAGE - arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base); -#endif - arg1 = (void *)((uintptr_t)frag_softc + (uintptr_t)arg1); - } + frag_softc = V_ipfmain.ipf_frag_soft; + arg1 = (void *)((uintptr_t)frag_softc + arg2); - return (sysctl_ipf_int(oidp, arg1, arg2, req)); + return (sysctl_ipf_int(oidp, arg1, 0, req)); } #endif @@ -623,29 +597,29 @@ ipf_fbsd_sysctl_create(void) sysctl_ctx_init(&ipf_clist); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "fr_defnatage", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_defage), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_defage), ""); SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statesize", CTLFLAG_RWO, - (void *)offsetof(ipf_state_softc_t, ipf_state_size), 0, ""); + NULL, offsetof(ipf_state_softc_t, ipf_state_size), ""); SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statemax", CTLFLAG_RWO, - (void *)offsetof(ipf_state_softc_t, ipf_state_max), 0, ""); + NULL, offsetof(ipf_state_softc_t, ipf_state_max), ""); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_max", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_max), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_table_max), ""); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_sz", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_sz), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_table_sz), ""); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_natrules_sz", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_maprules_sz), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_maprules_sz), ""); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_rdrrules_sz", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_rdrrules_sz), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_rdrrules_sz), ""); SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_hostmap_sz", CTLFLAG_RWO, - (void *)offsetof(ipf_nat_softc_t, ipf_nat_hostmap_sz), 0, ""); + NULL, offsetof(ipf_nat_softc_t, ipf_nat_hostmap_sz), ""); SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authsize", CTLFLAG_RWO, - (void *)offsetof(ipf_auth_softc_t, ipf_auth_size), 0, ""); + NULL, offsetof(ipf_auth_softc_t, ipf_auth_size), ""); SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authused", CTLFLAG_RD, - (void *)offsetof(ipf_auth_softc_t, ipf_auth_used), 0, ""); + NULL, offsetof(ipf_auth_softc_t, ipf_auth_used), ""); SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_defaultauthage", CTLFLAG_RW, - (void *)offsetof(ipf_auth_softc_t, ipf_auth_defaultage), 0, ""); + NULL, offsetof(ipf_auth_softc_t, ipf_auth_defaultage), ""); SYSCTL_DYN_IPF_FRAG(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW, - (void *)offsetof(ipf_frag_softc_t, ipfr_ttl), 0, ""); + NULL, offsetof(ipf_frag_softc_t, ipfr_ttl), ""); return (0); }