From nobody Wed Dec 01 17:10:08 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 6487818CB439; Wed, 1 Dec 2021 17:10:10 +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 4J45Dx2yvzz4dSL; Wed, 1 Dec 2021 17:10:09 +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 7266B5A22; Wed, 1 Dec 2021 17:10:08 +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 1B1HA8Ys016844; Wed, 1 Dec 2021 17:10:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1HA80i016841; Wed, 1 Dec 2021 17:10:08 GMT (envelope-from git) Date: Wed, 1 Dec 2021 17:10:08 GMT Message-Id: <202112011710.1B1HA80i016841@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: 73ef1f7462e9 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: 73ef1f7462e95f12747a6ff33c0cbb2bc4f848b7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638378609; 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=iHQo3swApf5+F/PVRkqGWirT+hqQE5ESd/gRHuZV/+4=; b=ShFAQLHvcT4I/okUjAYgBLdiK4tDV8WAg7hc/xDfiZX7wYB+8So9ckCs6hEVsAJyREhoWV FCcWodlW5ETp+GkOO6qDCiTlf8ziRZSiyVSpg6BYe3K/9o6ia74eLHsAz1wNys8gYtATP5 FQXeIAq4lwgJqk+OaJxdwGL3QUNtNSKZCXM/ERlNjCQwK2uhtMDP0OLLRjJZlGKuVj1hnL cht6RBFl+DXfeS/2gkLf8HlnPGpqJhn7ug81dI7tisdLBPbrQT/97Can3NmIRNlxmDvJFN M293Oragm40j5Z+kJIwciGGDa7zXb72SwR5k4HaypaA5v3sst3/KswdbN6TN+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638378609; a=rsa-sha256; cv=none; b=t1xDq+LdvOfyC+ZSkJjZ5CnyMVFGJAwiyDRmhkl+0OGmt2/jwHXshbxFM4cMgAZjytc/xy 6eN2nXimRpJqlr0bCAJ4Umlg8SDyBIiy0x4Jn9bZzFhauHAqFU3nIUxiOu9TqEhtYYlkbn cMEFHG4jCXBr/1eqPOgPAdIGAoaxln3Vvtx7pOYgH84/IHSQL6IWIakc/fDsKZoGPWHBZj xB9DTXypP3Ja9dBiWz4+ywGnaO8+AGh3t+DQOkpt5s0EmWS2pdQrR67Jazn0EOW6gMA9UN YT3OG6yRNSVgUN/y2hJo8Iztz6I0GTJZl1IBX72L89TAfISWiWUOVF4oIKqRwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=73ef1f7462e95f12747a6ff33c0cbb2bc4f848b7 commit 73ef1f7462e95f12747a6ff33c0cbb2bc4f848b7 Author: Kristof Provost AuthorDate: 2021-11-08 12:25:20 +0000 Commit: Kristof Provost CommitDate: 2021-12-01 12:43:25 +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)