From owner-dev-commits-src-branches@freebsd.org Fri May 7 15:25:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 319C9631683; Fri, 7 May 2021 15:25:49 +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 4FcDmX1Ytsz4jmm; Fri, 7 May 2021 15:25:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 89B2C55E4; Fri, 7 May 2021 15:25:47 +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 147FPltW026387; Fri, 7 May 2021 15:25:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 147FPl8A026386; Fri, 7 May 2021 15:25:47 GMT (envelope-from git) Date: Fri, 7 May 2021 15:25:47 GMT Message-Id: <202105071525.147FPl8A026386@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 1398367b3a89 - stable/13 - libpfctl: Fix u_* counters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1398367b3a89ce2bf882ecbd181d08cfd044a7dc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 15:25:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1398367b3a89ce2bf882ecbd181d08cfd044a7dc commit 1398367b3a89ce2bf882ecbd181d08cfd044a7dc Author: Kristof Provost AuthorDate: 2021-04-08 08:36:18 +0000 Commit: Kristof Provost CommitDate: 2021-05-07 08:15:42 +0000 libpfctl: Fix u_* counters struct pf_rule had a few counter_u64_t counters. Those couldn't be usefully comminicated with userspace, so the fields were doubled up in uint64_t u_* versions. Now that we use struct pfctl_rule (i.e. a fully userspace version) we can safely change the structure and remove this wart. Reviewed by: glebius MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29645 (cherry picked from commit ab5707a5cf86ed66dbd11e03ad9676766da9a47b) --- lib/libpfctl/libpfctl.c | 6 +++--- lib/libpfctl/libpfctl.h | 10 +++------- sbin/pfctl/pfctl.c | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index dc174d8d5b72..2a7b64f1cbc8 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -367,9 +367,9 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) pf_nvdivert_to_divert(nvlist_get_nvlist(nvl, "divert"), rule); - rule->u_states_cur = nvlist_get_number(nvl, "states_cur"); - rule->u_states_tot = nvlist_get_number(nvl, "states_tot"); - rule->u_src_nodes = nvlist_get_number(nvl, "src_nodes"); + rule->states_cur = nvlist_get_number(nvl, "states_cur"); + rule->states_tot = nvlist_get_number(nvl, "states_tot"); + rule->src_nodes = nvlist_get_number(nvl, "src_nodes"); } int diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 996830619489..95f6d4e3c77f 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -81,9 +81,9 @@ struct pfctl_rule { uid_t cuid; pid_t cpid; - counter_u64_t states_cur; - counter_u64_t states_tot; - counter_u64_t src_nodes; + uint64_t states_cur; + uint64_t states_tot; + uint64_t src_nodes; u_int16_t return_icmp; u_int16_t return_icmp6; @@ -129,10 +129,6 @@ struct pfctl_rule { struct pf_addr addr; u_int16_t port; } divert; - - uint64_t u_states_cur; - uint64_t u_states_tot; - uint64_t u_src_nodes; }; TAILQ_HEAD(pfctl_rulequeue, pfctl_rule); diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 548aab0f839e..bc646ab335e1 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -891,12 +891,12 @@ pfctl_print_rule_counters(struct pfctl_rule *rule, int opts) (unsigned long long)(rule->packets[0] + rule->packets[1]), (unsigned long long)(rule->bytes[0] + - rule->bytes[1]), (uintmax_t)rule->u_states_cur); + rule->bytes[1]), (uintmax_t)rule->states_cur); if (!(opts & PF_OPT_DEBUG)) printf(" [ Inserted: uid %u pid %u " "State Creations: %-6ju]\n", (unsigned)rule->cuid, (unsigned)rule->cpid, - (uintmax_t)rule->u_states_tot); + (uintmax_t)rule->states_tot); } } @@ -1012,7 +1012,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, (unsigned long long)rule.bytes[0], (unsigned long long)rule.packets[1], (unsigned long long)rule.bytes[1], - (uintmax_t)rule.u_states_tot); + (uintmax_t)rule.states_tot); } break; case PFCTL_SHOW_RULES: