From nobody Wed Dec 01 17:10:06 2021 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 EFFDD18CB434; Wed, 1 Dec 2021 17:10:09 +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 4J45Dv56hmz4dPv; Wed, 1 Dec 2021 17:10:07 +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 1F4AF584C; Wed, 1 Dec 2021 17:10:07 +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 1B1HA6iY016533; Wed, 1 Dec 2021 17:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1HA6MQ016531; Wed, 1 Dec 2021 17:10:06 GMT (envelope-from git) Date: Wed, 1 Dec 2021 17:10:06 GMT Message-Id: <202112011710.1B1HA6MQ016531@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: 525205b5d2f1 - stable/13 - pf: ensure we populate dyncnt/tblcnt in struct pf_addr_wrap 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/13 X-Git-Reftype: branch X-Git-Commit: 525205b5d2f12b85c84cf060b5e42d5472e31501 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638378608; 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=z+Y1ojJ6uItlQoI2gpIN/shXU8OGuSWAR39tjROZZBE=; b=vg0P+6DMhEQS0dJxpF3eZbpvuBPF5dkfHIeFYVJafhY5YA34Wj72fCWcs6AmVFb7Za+dIP RvIX/K9NZ6xPEEewQK5mVyPD5kfMzURiiiS/T3QK+B9xwoG7Avda9ItHuv7aEy6GRRAwYl DzfQuDaUv947v5YaXe76mSU82z8q1ykHYjS6r3NpzC9oH7CcTN2ebMKI0XRHL3uhyjqBE1 zBH4fuRvAG2xzVHVeFB+wul5oZ2vUmHXwRj1NDMbN0nHXua9dJkROMOYnSZzDo5Zo3FIjz 1gShabyB3zZacMryHDsIKeBaUc4LwNiAcrtnOqqYBYAAJM6pfOLhZIObV+vcqA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638378608; a=rsa-sha256; cv=none; b=YZ6an2OKKla8Tk/rJvtFdmU6hXSRu2L4xE4ftcxUiD9jtQe+PCqXB/QgpJd9TH8GQLfagn cpRdXgWreVUCdagDNEESMy2TL6M7YDqpIWDDsIEngP/i61HgIYq+O8S/8umP5ywrrhNRQb 2OZEDIDWIxauzieKEA0difMTolEOC+5eBqa01MrdlL6jvKqYZpRtgEHAppvwZUb5S26FoA KnpNE6RdWuVLWG+RzZe2P3DSf72Pd0qZshGRfnWWs/Kd+OOT5xHjt06K/BA2os2DOtKd8u dJlDbbW3IhoCSKHZxyksMl5PKGNs8ANveiGc7r+Ese7uJpMpMV+rLsB5dEKdzw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=525205b5d2f12b85c84cf060b5e42d5472e31501 commit 525205b5d2f12b85c84cf060b5e42d5472e31501 Author: Kristof Provost AuthorDate: 2021-11-08 12:25:20 +0000 Commit: Kristof Provost CommitDate: 2021-12-01 15:53:19 +0000 pf: ensure we populate dyncnt/tblcnt in struct pf_addr_wrap PR: 259689 MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32892 (cherry picked from commit 218a8a491c4980dcc941908f9505d37e7f052868) --- lib/libpfctl/libpfctl.c | 10 ++++++++-- sys/netpfil/pf/pf_nv.c | 21 +++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 96f5ea620f4d..6613708b183c 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -287,14 +287,20 @@ pfctl_nv_add_addr_wrap(nvlist_t *nvparent, const char *name, static void pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr) { + bzero(addr, sizeof(*addr)); + addr->type = nvlist_get_number(nvl, "type"); addr->iflags = nvlist_get_number(nvl, "iflags"); - if (addr->type == PF_ADDR_DYNIFTL) + if (addr->type == PF_ADDR_DYNIFTL) { strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); - if (addr->type == PF_ADDR_TABLE) + addr->p.dyncnt = nvlist_get_number(nvl, "dynctl"); + } + if (addr->type == PF_ADDR_TABLE) { strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"), PF_TABLE_NAME_SIZE); + addr->p.tblcnt = nvlist_get_number(nvl, "tblcnt"); + } pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &addr->v.a.addr); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "mask"), &addr->v.a.mask); diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index b6676be645d7..573544972952 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -327,6 +327,8 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr) { nvlist_t *nvl; nvlist_t *tmp; + uint64_t num; + struct pfr_ktable *kt; nvl = nvlist_create(0); if (nvl == NULL) @@ -334,10 +336,25 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr) nvlist_add_number(nvl, "type", addr->type); nvlist_add_number(nvl, "iflags", addr->iflags); - if (addr->type == PF_ADDR_DYNIFTL) + if (addr->type == PF_ADDR_DYNIFTL) { nvlist_add_string(nvl, "ifname", addr->v.ifname); - if (addr->type == PF_ADDR_TABLE) + num = 0; + if (addr->p.dyn != NULL) + num = addr->p.dyn->pfid_acnt4 + + addr->p.dyn->pfid_acnt6; + nvlist_add_number(nvl, "dyncnt", num); + } + if (addr->type == PF_ADDR_TABLE) { nvlist_add_string(nvl, "tblname", addr->v.tblname); + num = -1; + kt = addr->p.tbl; + if ((kt->pfrkt_flags & PFR_TFLAG_ACTIVE) && + kt->pfrkt_root != NULL) + kt = kt->pfrkt_root; + if (kt->pfrkt_flags & PFR_TFLAG_ACTIVE) + num = kt->pfrkt_cnt; + nvlist_add_number(nvl, "tblcnt", num); + } tmp = pf_addr_to_nvaddr(&addr->v.a.addr); if (tmp == NULL)