From nobody Wed May 03 09:59:25 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 4QBC8t20v4z499KM; Wed, 3 May 2023 09:59:26 +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 4QBC8t1RV3z3Lst; Wed, 3 May 2023 09:59:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683107966; 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=IvZzap/NEmOMYAXRli817Ri1xH1cXCe4rpPe3eHr2sE=; b=FuahQTDC+iP+hcc1jeuxRGWfP0cnMntYqmmDBT4/S2i1LYScm+AvSRlP2xZTO2pLDGYbcq cG6QglW6fpst40kl/eDSZ1NjFM2fux2Gq0IZudo09DGEkTX7TF5U9f1Ic9EEjW6f+g4WpX /j5kX5ltsZzdPosBk4M+sr/M6+o25szSfGNu0Aferus3OpmtILUoAvQzF1CWJnQ4u2hCSs oCAujZWvO3+LP6pHGfz9AKnTSBKukafXwrYilU2rQugPm6NfaJ5Ubh4MESpKGSjvjXOQFc hmvE60G6P+zzXSZjNO3QJ7dp64nnPWiiHjKtl/hpz588eauI/s1/MtVsWhEa/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683107966; 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=IvZzap/NEmOMYAXRli817Ri1xH1cXCe4rpPe3eHr2sE=; b=ogbVubsroycfQYrhqChIIyERjQnHJLPJGUYtsCkLvXE8eyisVLB3ZZqpu4thObmnLcAczK aNUNTSr04j8lnyBvqrJy/DTJKtyzQM71TNP95rKO1rLciQeP5SbLCOSysT5VOhruj4RLCN 1w4u8+hZ157jhFIwcBfqGDQfl1HAouCc9LauxC6DvhiJBGo/qCaayEp/gqYfxmsOBXi26l 4MmV9GztIjHfSFJdvrXiWCKgH6DHAGFSfoHITCkPyLz36LWALsne7k6GbOOxW1vCOhVRsD KIfLfJWpaTFBastiLVdAG7swiIyoQ9kpc8fVVweZJ5OpczY5FKZBHb15RblbXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683107966; a=rsa-sha256; cv=none; b=DR8OEU5zXesaLigrpCslRv8rfNBEvgc8gr4oK5d6JeLyzCFDAI7ZXSnkIQMMpLMcUWOL9Y BnSsPJTyXWd5Jk/4z6iNZYhyUXs1uc14Vj9XNoH9n9Kilm2IswiL/gaZWbp/OYfZcizi3i wqru1HWzzd/t2cSmx+GPiAG8kKHsVqszn5HSVGuqiPtZVLBhwT+8ZuKgxN+KwsQlLmXjd0 VbYfJ6KHz9/FMNbiITQuEYqMTKroug9QcrOe9CgYMsHmkXvFIXCsMFWjOQcYgi7PtNLJ/5 B6zWvfRALKaUUUuhSG4TaghgxkB5UhNhthvH9s+V2w4yMpZM+KpbUMLRixl5QQ== 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 4QBC8t0SHPzQtv; Wed, 3 May 2023 09:59:26 +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 3439xPxX014201; Wed, 3 May 2023 09:59:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3439xPpw014200; Wed, 3 May 2023 09:59:25 GMT (envelope-from git) Date: Wed, 3 May 2023 09:59:25 GMT Message-Id: <202305030959.3439xPpw014200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 7b676698856e - main - pf: simplify structs with anonymous unions 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/main X-Git-Reftype: branch X-Git-Commit: 7b676698856ec4604b2b93f4fa917767bfbfa66e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7b676698856ec4604b2b93f4fa917767bfbfa66e commit 7b676698856ec4604b2b93f4fa917767bfbfa66e Author: Kristof Provost AuthorDate: 2023-05-03 06:02:43 +0000 Commit: Kristof Provost CommitDate: 2023-05-03 08:24:20 +0000 pf: simplify structs with anonymous unions Rather than playing preprocessor hacks use actual anonymous unions. No functional change. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/pfvar.h | 24 +++++++++--------------- sys/netpfil/pf/pf.h | 20 +++++--------------- sys/netpfil/pf/pf_table.c | 26 ++++++++++---------------- 3 files changed, 24 insertions(+), 46 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index c1550f2c30e6..412453f8dd25 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1704,32 +1704,26 @@ struct pfioc_state_kill { struct pfioc_states { int ps_len; union { - caddr_t psu_buf; - struct pfsync_state *psu_states; - } ps_u; -#define ps_buf ps_u.psu_buf -#define ps_states ps_u.psu_states + caddr_t ps_buf; + struct pfsync_state *ps_states; + }; }; struct pfioc_states_v2 { int ps_len; uint64_t ps_req_version; union { - caddr_t psu_buf; - struct pf_state_export *psu_states; - } ps_u; -#define ps_buf ps_u.psu_buf -#define ps_states ps_u.psu_states + caddr_t ps_buf; + struct pf_state_export *ps_states; + }; }; struct pfioc_src_nodes { int psn_len; union { - caddr_t psu_buf; - struct pf_src_node *psu_src_nodes; - } psn_u; -#define psn_buf psn_u.psu_buf -#define psn_src_nodes psn_u.psu_src_nodes + caddr_t psn_buf; + struct pf_src_node *psn_src_nodes; + }; }; struct pfioc_if { diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index f226232419f8..fc3ea6c9e1d3 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -233,11 +233,9 @@ struct pfi_kif_cmp { struct pfi_kif { char pfik_name[IFNAMSIZ]; union { - RB_ENTRY(pfi_kif) _pfik_tree; - LIST_ENTRY(pfi_kif) _pfik_list; - } _pfik_glue; -#define pfik_tree _pfik_glue._pfik_tree -#define pfik_list _pfik_glue._pfik_list + RB_ENTRY(pfi_kif) pfik_tree; + LIST_ENTRY(pfi_kif) pfik_list; + }; u_int64_t pfik_packets[2][2][2]; u_int64_t pfik_bytes[2][2][2]; u_int32_t pfik_tzero; @@ -275,12 +273,7 @@ struct pf_addr { u_int8_t addr8[16]; u_int16_t addr16[8]; u_int32_t addr32[4]; - } pfa; /* 128-bit address */ -#define v4 pfa.v4 -#define v6 pfa.v6 -#define addr8 pfa.addr8 -#define addr16 pfa.addr16 -#define addr32 pfa.addr32 + }; /* 128-bit address */ }; #define PFI_AFLAG_NETWORK 0x01 @@ -344,10 +337,7 @@ struct pf_poolhashkey { u_int8_t key8[16]; u_int16_t key16[8]; u_int32_t key32[4]; - } pfk; /* 128-bit hash key */ -#define key8 pfk.key8 -#define key16 pfk.key16 -#define key32 pfk.key32 + }; /* 128-bit hash key */ }; struct pf_mape_portset { diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index ea37b077c651..28d63b54c2d8 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -107,21 +107,15 @@ struct pfr_walktree { PFRW_COUNTERS } pfrw_op; union { - struct pfr_addr *pfrw1_addr; - struct pfr_astats *pfrw1_astats; - struct pfr_kentryworkq *pfrw1_workq; - struct pfr_kentry *pfrw1_kentry; - struct pfi_dynaddr *pfrw1_dyn; - } pfrw_1; + struct pfr_addr *pfrw_addr; + struct pfr_astats *pfrw_astats; + struct pfr_kentryworkq *pfrw_workq; + struct pfr_kentry *pfrw_kentry; + struct pfi_dynaddr *pfrw_dyn; + }; int pfrw_free; int pfrw_flags; }; -#define pfrw_addr pfrw_1.pfrw1_addr -#define pfrw_astats pfrw_1.pfrw1_astats -#define pfrw_workq pfrw_1.pfrw1_workq -#define pfrw_kentry pfrw_1.pfrw1_kentry -#define pfrw_dyn pfrw_1.pfrw1_dyn -#define pfrw_cnt pfrw_free #define senderr(e) do { rv = (e); goto _bad; } while (0) @@ -740,7 +734,7 @@ pfr_enqueue_addrs(struct pfr_ktable *kt, struct pfr_kentryworkq *workq, pfr_walktree, &w)) printf("pfr_enqueue_addrs: IPv6 walktree failed.\n"); if (naddr != NULL) - *naddr = w.pfrw_cnt; + *naddr = w.pfrw_free; } static void @@ -1068,7 +1062,7 @@ pfr_walktree(struct radix_node *rn, void *arg) /* FALLTHROUGH */ case PFRW_ENQUEUE: SLIST_INSERT_HEAD(w->pfrw_workq, ke, pfrke_workq); - w->pfrw_cnt++; + w->pfrw_free++; break; case PFRW_GET_ADDRS: if (w->pfrw_free-- > 0) { @@ -1089,7 +1083,7 @@ pfr_walktree(struct radix_node *rn, void *arg) case PFRW_POOL_GET: if (ke->pfrke_not) break; /* negative entries are ignored */ - if (!w->pfrw_cnt--) { + if (!w->pfrw_free--) { w->pfrw_kentry = ke; return (1); /* finish search */ } @@ -2347,7 +2341,7 @@ pfr_kentry_byidx(struct pfr_ktable *kt, int idx, int af) bzero(&w, sizeof(w)); w.pfrw_op = PFRW_POOL_GET; - w.pfrw_cnt = idx; + w.pfrw_free = idx; switch (af) { #ifdef INET