From nobody Sat Sep 09 11:51:17 2023 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 4RjWXQ0DXFz4sGZJ; Sat, 9 Sep 2023 11:51:18 +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 4RjWXP6ZMhz4Ps8; Sat, 9 Sep 2023 11:51:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694260277; 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=iLkRVOPB0Amgfk7hS33VXFd9vZp/QfkNP9ZsxqJvi00=; b=NwxSIQ5zed0Bvn5I2o+zZyXZg+enlX1u0oguphYp0iYc8GWIJ6/09BL0RJQ32HWLFyreWx jYTEJowPuqoHmGOEdrE7H9ZvTTfvMRKel4QNMMvQocsSl87KmrWzQoe5f8amWQk/e4sBYl iePXZK1K6+TlRXMUSsQL64mhwbLuR8HR7xKK297rPX5ycbNfVydhJJaqKXFxR+mrjtByvX aSWStf37bERR2FmHrkzmpSjLiikhCxElzx+zzV1qhoTJ1sRwYutv/H6RtWr/YVjeikqgDN R9amgYFDZ4Iz3kz+hORiu6CzFJZEZXIEQVukcdIvHJQ0EBoQHoS1Hs38vLFxrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694260277; a=rsa-sha256; cv=none; b=rdDgQQmzFa6jVzRL6CRLiMT1qg38DMXqTFhkUd2HdL41p2w0emh5KWRUSJG2xq5hG938Tg GvWZSDIcuTTHki2RqeA836OSCQtbqN17z+jmMnzXWw6Xdx6+AJ0q/2FzM0PtNXYy0SMF7R rqSZg7iN9mmTT36km4xvNGwwnQM1JEXcw2wDnjxUPb1qjx2COP9VnD6hFTclVQS+ZCDQ9l /n3LeR2eAcahw54lTpMzMSzbfledqfanDQZdtnlWhwMZuHnnxlh9GHirFqfuxLZaqzxiaw lzpTlrWtg4cLyX3thY6Q98atgAEZs+DQznnJpCdoeuu7MX8r1x3LbL6+rPMGZw== 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=1694260277; 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=iLkRVOPB0Amgfk7hS33VXFd9vZp/QfkNP9ZsxqJvi00=; b=XgZO3IXWNJZOO9fv2zbyAZKBRJDjXxSeNItKKGSHBrCNNIhdcjPXPxQuy9ZJMFIDWnhsIG IY6ihmVfujwCtHccVfU3KZrxGgvuVgf/ECvcDXDO+VOXs6aovnyS2+Hz3NCrvXeAFGqlOo xLyR+PWLNtlJqK4LAN5zkaMjhRqxXc0iwhucizmWmaOof5/f0vkeWYKfGBo53lvq3h4As0 743akxkmHemN0xDFI4lHtS+EZ3nwjAkqmoH87oJKUmhDw4phFDyFGStDC3qslOgQFTk68k riXXznRTTkY+4E1i1GVwp7MeZSxubJWNlwEiK7Uzx5SlaHAdW/qY+b+nTdADFA== 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 4RjWXP5KXTz7wb; Sat, 9 Sep 2023 11:51:17 +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 389BpHJI099782; Sat, 9 Sep 2023 11:51:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 389BpHh3099779; Sat, 9 Sep 2023 11:51:17 GMT (envelope-from git) Date: Sat, 9 Sep 2023 11:51:17 GMT Message-Id: <202309091151.389BpHh3099779@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: 9a9535e4df50 - stable/14 - libpfctl: implement status counter accessor functions 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9a9535e4df507957fc173208e7c1fd0080bd7a73 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9a9535e4df507957fc173208e7c1fd0080bd7a73 commit 9a9535e4df507957fc173208e7c1fd0080bd7a73 Author: Kristof Provost AuthorDate: 2023-08-29 15:04:17 +0000 Commit: Kristof Provost CommitDate: 2023-09-09 09:05:50 +0000 libpfctl: implement status counter accessor functions The new nvlist-based status call allows us to easily add new counters. However, the libpfctl interface defines a TAILQ, so it's not quite trivial to find the counter consumers are interested in. Provide convenience functions to access the counters. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41649 (cherry picked from commit e3d3d61a7d94a4155ef70048a8b578985fca8383) --- lib/libpfctl/libpfctl.c | 31 +++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7d79d0abb970..1eccf3dfbcdf 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -252,6 +252,37 @@ pfctl_get_status(int dev) return (status); } +static uint64_t +_pfctl_status_counter(struct pfctl_status_counters *counters, uint64_t id) +{ + struct pfctl_status_counter *c; + + TAILQ_FOREACH(c, counters, entry) { + if (c->id == id) + return (c->counter); + } + + return (0); +} + +uint64_t +pfctl_status_counter(struct pfctl_status *status, int id) +{ + return (_pfctl_status_counter(&status->counters, id)); +} + +uint64_t +pfctl_status_fcounter(struct pfctl_status *status, int id) +{ + return (_pfctl_status_counter(&status->fcounters, id)); +} + +uint64_t +pfctl_status_scounter(struct pfctl_status *status, int id) +{ + return (_pfctl_status_counter(&status->scounters, id)); +} + void pfctl_free_status(struct pfctl_status *status) { diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 35c662816f3b..2559fc9c4843 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -385,6 +385,9 @@ struct pfctl_syncookies { }; struct pfctl_status* pfctl_get_status(int dev); +uint64_t pfctl_status_counter(struct pfctl_status *status, int id); +uint64_t pfctl_status_fcounter(struct pfctl_status *status, int id); +uint64_t pfctl_status_scounter(struct pfctl_status *status, int id); void pfctl_free_status(struct pfctl_status *status); int pfctl_get_eth_rulesets_info(int dev,