🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.hackers
Article #46

Re: improvements to PF macros

#46
From: Vadim Goncharov
Date: Mon, 19 Oct 2026 23:47
70 lines
8656 bytes
On Thu, 8 Oct 2026 21:00:33 +0000
Robert Austen <robert.austen@willowglensystems.com> wrote:

> I've been working with PF under freebsd for a few months, and have noticed a
> recurring theme in the forums, that the macros in PF could be improved.
> 
> I notice that it is often difficult to define one macro in terms of
> another, and just addressing that item alone would help write cleaner
> simpler rules.

I'm not using pf, just soming from Lex/Yacc side, because changing syntax
can establish a precedent for "downstream" projects: at $job I am doing custom
firewall-like thing, with some syntax parts borrowed from FreeBSD firewalls,
and I think I am not the only where "@" is already got used for other things.
What about, say, "$$" ?

[...]
> this change allows a macro to be defined in terms of an existing macro,
> using the '@' to refer to that existing macro by name, rather than expanding
> the macro out and causing the eventual 'syntax error' response that often
> results.
> 
> this allows using one macro within another
> set_ext_tag = "tag \"from_outside\""
> is_int_tag = "tagged \"from_inside\""
> 
> combined_tags = @set_ext_tag @is_int_tag
> 
> this results in $combined_tags expanding to:
>                                   tag "from_outside" tagged "from_inside"

I do not understand this example - man page close to beginning shows:

           ext_if = "kue0"
           all_ifs = "{" $ext_if lo0 "}"
           pass out on $ext_if from any to any

what your example achieves what's not covered already?

> [...]
> the existing grammar for varstring inserts a space, which is not always
> helpful, so the second change. this change adds the '+' operator to
> explicitly concat two strings together (either or both could be a macro),
> which allows the following
> 
> subnet = "192.168.0."
> client = @subnet + "206"
> 
> 
> this results in $client expanding to:
>                        192.168.0.206

This looks like an overkill for simple task - e.g. in Shell, you do not need
separate strings concatenation operator - you just concatenate them, e.g.
inside quotes. So your real problem seems to be the statement

  Macros are not expanded inside quotes.

from manpage. This can't be changed literally without breaking backwards
compatibility, but `man sh` can serve as inspiration, and may be `man make`,
too. For example, what about syntax like $'' inside which macros are expanded?
Or $() in make-style? Can this actuallt solve BOTH of your problems?..

-- 
WBR, @nuclight


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <20261020024752.103664e5@nuclight.lan>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
References: <YT6PR01MB1099647AE1BFFA49DE8D72D06EF932@YT6PR01MB10996.CANPRD01.PROD.OUTLOOK.COM>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: Vadim Goncharov <vadimnuclight@gmail.com>
Newsgroups: muc.lists.freebsd.hackers
Subject: Re: improvements to PF macros
Date: Tue, 20 Oct 2026 02:47:52 +0300
Organization: Newsgate at muc.de e.V.
Sender: owner-freebsd-hackers@FreeBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <20261020024752.103664e5@nuclight.lan>
References: <YT6PR01MB1099647AE1BFFA49DE8D72D06EF932@YT6PR01MB10996.CANPRD01.PROD.OUTLOOK.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="10316"; mail-complaints-to="news-admin@muc.de"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1792453686; h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references:list-id:list-help:
	 list-owner:list-unsubscribe:list-subscribe:list-post;
	bh=ofuzg3J8pxqcs7hRTtODz20J4wtSL9JQI+IuvhnSNh0=;
	b=GiN88ef6t5Eq5ee95anaqcVUitqFG1/r+IGlLe3LIrDj3RTLwQ6sfPj7Zxsy9482IJEB2N
	OxqE2sQvCyQAszAjno04eb5yJzIZ/w/0hjljYR0viNlW1tuez9fq69duwVx9UZ2atgNyVX
	BLgR6S0UsY+Wi479HjS7AJSAWcAgI7g5p8zlA7uukjF4UZi3HuD0ypUfBLi5t+fX7xXk1v
	i2f9UtEXjVmngcbArYv8FSwCeRPjCQ+rmfTDHfphef9HsNjTxCLzYsQCXoHbQm35UQtptZ
	sfVxSe//vaLuAwx/KcI4CNB0GH3RIPzox7bgI0R7JfoAy2yJz0rL6zEISAfvzA==
X-Original-To: hackers@mlmmj.nyi.freebsd.org
Authentication-Results: mx1.freebsd.org;
	dkim=pass header.d=gmail.com header.s=20251104 header.b=dAR3Rp95;
	spf=pass (mx1.freebsd.org: domain of vadimnuclight@gmail.com designates 2a00:1450:4864:20::334 as permitted sender) smtp.mailfrom=vadimnuclight@gmail.com;
	dmarc=pass (policy=none) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792453676; x=1793058476; darn=freebsd.org;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=ofuzg3J8pxqcs7hRTtODz20J4wtSL9JQI+IuvhnSNh0=;
        b=dAR3Rp95RlrHgOzID93pma0h3QTKN/Hgf5coafW12ProQ0CeZU3POVzPa4tJmGTIjE
         gWro+2DZ4RPzrd/DZ7IxGaOToVNKtBNVhP+i0I4iSQtHXxxHikrG5NNiwM4NgcabQsKv
         WpehXqR+PBOv4hWgCKaPBOmLMLjR2CAr7Lbz7ZPcMrSHF3d89dmFMWDoDQSPvtecV75T
         uL1X5fzAKB3rUAdvuOBFdAXVsM055W2Cj7mVrsUFNDLm1Cq8fwrYa/XUpjV6cwGdorQJ
         rR+eIYGh0dj+zPHK3oTDeRB1WtT0Mk5OomxWTC2UqnJPWvyNzq435nzOKKstjFwYaVG+
         DsXQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792453676; x=1793058476;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=ofuzg3J8pxqcs7hRTtODz20J4wtSL9JQI+IuvhnSNh0=;
        b=w1q2Bh/OVfuJX4+f9Gi63pcqhLwtiWJ3rw7WAZlETNsIIo2LMNZUJx15LEu+vw73YF
         qZkh1bfel41pHj1xgtLOm2NgC+eSmeJbzmqRIpfbd1ARLgUl1gc8Fn11nUong2AR8H0t
         ezu7U5/ZcxXGgo/dignKGV4ln14XfgJD1cU0nJ3Pb1pVhMRaNlQND6kmJkMr5VJHtIar
         jAR0QgR0o7+mJv4+dNjUvT0Ypahg1uHiyRzttZSICeNGrlefO99fteAvNUCS609yVjnk
         LqAmRDyIF4IbCoTtKdUE8YBjcVwZx8ixGJwx45vj89LnK00PX+Ia89lk1GZg4I2TrdCy
         Lp4Q==
X-Forwarded-Encrypted: i=1; AKwUvBzdn2Pcm/P7ghk8cQY6waf5wf1h7zR81dsussHcbcz5jmWcfU8gpH6meMF1sQUH5xF3uCI13lO1@freebsd.org
X-Gm-Message-State: AFq9FYII3CvsKZbKaIgLyoicGuRzuMFO27gDb920WW3m7S8PaghA0orv
	oqqXR14Vpsv2v1ScvyLrkz6G/8UhF7pqRQ3XDaHow6kV3RuQrPi4Fiac
X-Gm-Gg: AYBFou3oRcyIHkTbHEI2XVojJC+8Ofmwghndnzt9Q9ax/cRvSzGPblTrIu7EITlMR3v
	NA7SVgwEpu4jvexe0cgm3EMyiONyry3A/IPZG/IQMXJvuOL9WmoARpUpqVah1N2fIJO5X40TrXz
	LzPHG9n3sgOn07W26YoL6cORc3WFP7yoXRv889Z8KNHh6lHDkLkzXOBmpW7pzUsTBQgti1eksIn
	J+Tf73wJGUQNBpl3I7fl1Thnm3bAw4TNdWZeC8bPuWGe/SzRBCSYU7hkL7fyCypBXoX3CR1U7Ad
	+HXlGdFMZ9O/Vxsl9zFuUZjfmxtXW99G4yWmvLMV7HxEWionhlZR+IfnE3zMyG6yXeWTxCAMPhq
	7sXW2igCBpIgKVECUT/YVdoS91JixUWPfNjIdIMMzRKZFP5D8KpHNVAFFz/22tCYoj9qHw+Juxq
	oopCfpFh+Fi7fQdt815i0tRFg5JG1usQ17XnBg+CCGvTW9G/9NkQO2kkx9TL/0o6KAp9NR64HtW
	S7IDWz+HWpNrZwQWDjMIM2jE5+Uvoe8Ql6rS1erOwcutDE=
In-Reply-To: <YT6PR01MB1099647AE1BFFA49DE8D72D06EF932@YT6PR01MB10996.CANPRD01.PROD.OUTLOOK.COM>
Precedence: list
X-Spamd-Bar: -
X-Spamd-Result: default: False [-1.00 / 15.00];
	DMARC_POLICY_ALLOW(-0.50)[gmail.com,none];
	R_DKIM_ALLOW(-0.20)[gmail.com:s=20251104];
	R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4864::/56:c];
	MIME_GOOD(-0.10)[text/plain];
	FREEMAIL_ENVFROM(0.00)[gmail.com];
	FREEMAIL_FROM(0.00)[gmail.com];
	DWL_DNSWL_NONE(0.00)[gmail.com:dkim];
	ARC_NA(0.00)[];
	RCVD_VIA_SMTP_AUTH(0.00)[];
	ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US];
	TO_DN_SOME(0.00)[];
	MIME_TRACE(0.00)[0:+];
	RCVD_TLS_LAST(0.00)[];
	MLMMJ_DEST(0.00)[hackers@freebsd.org];
	RCVD_COUNT_TWO(0.00)[2];
	FROM_EQ_ENVFROM(0.00)[];
	FROM_HAS_DN(0.00)[];
	RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::334:from];
	TO_DN_EQ_ADDR_SOME(0.00)[];
	PREVIOUSLY_DELIVERED(0.00)[hackers@freebsd.org];
	TO_MATCH_ENVRCPT_SOME(0.00)[];
	RCPT_COUNT_THREE(0.00)[3];
	DKIM_TRACE(0.00)[gmail.com:+]
X-Rspamd-Queue-Id: 4j7sg35Xr1z4Y9v
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes
X-Received-Bytes: 8444