* syntax issues when reducing rules through grouping ?
@ 2024-07-18 19:44 pgnd
2024-07-18 21:00 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: pgnd @ 2024-07-18 19:44 UTC (permalink / raw)
To: netfilter
i've migrated some fw code to nftables, and am cleaning up my sources -- at this point, for my own readability.
i've managed to so far miss any clear writeups on such housekeeping, so using some trial-n-error :-/
when involving marks in nat/mangle chains, what's valid, or not, is a bit fuzzy.
in this sample script
cat tmp.nft
#!/usr/sbin/nft -f
define VPN = "A"
define LAN = "B"
define SVR1 = "1.1.1.1"
define SVR2 = "2.2.2.2"
table nat {
chain prerouting {
type nat hook prerouting priority -150; policy accept;
# SET1
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 udp dport 53
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 tcp dport 53
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 udp dport 25
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport 465
# SET2 (This seem a bit tortured, but it's fewer lines ...)
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport { 25, 465 }
# SET3
meta mark set 0x02 {
24 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
25 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport { 25, 465 }
26 }
27
28 }
29 }
rule group "SETs" 1, 2 & 3 are _intended_ to be functionally equivalent, but simply increasingly "grouped" for convenience/readability (yes, arguable!)
testing, SET1 & SET2 seem OK, but SET3 is clearly unhappy,
nft -c -f tmp.nft
tmp.nft:24:4-7: Error: syntax error, unexpected meta
meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
^^^^
tmp.nft:29:1-1: Error: syntax error, unexpected '}'
}
^
what's specifically DISallowed in my SET3 syntax usage?
what'd be the 'most grouped' that SET can validly be?
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: syntax issues when reducing rules through grouping ?
2024-07-18 19:44 syntax issues when reducing rules through grouping ? pgnd
@ 2024-07-18 21:00 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2024-07-18 21:00 UTC (permalink / raw)
To: pgnd; +Cc: netfilter
pgnd <pgnd@dev-mail.net> wrote:
> table nat {
> chain prerouting {
> type nat hook prerouting priority -150; policy accept;
>
> # SET1
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 udp dport 53
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 tcp dport 53
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 udp dport 25
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport 465
>
> # SET2 (This seem a bit tortured, but it's fewer lines ...)
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
> meta mark set 0x02 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport { 25, 465 }
>
> # SET3
> meta mark set 0x02 {
> 24 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
> 25 meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR2 tcp dport { 25, 465 }
> 26 }
> 27
> 28 }
> 29 }
>
>
> rule group "SETs" 1, 2 & 3 are _intended_ to be functionally equivalent, but simply increasingly "grouped" for convenience/readability (yes, arguable!)
>
> testing, SET1 & SET2 seem OK, but SET3 is clearly unhappy,
>
> nft -c -f tmp.nft
> tmp.nft:24:4-7: Error: syntax error, unexpected meta
> meta iifname "$VPN" meta oifname "$LAN" ip daddr $SVR1 meta l4proto {tcp, udp} th dport 53
> ^^^^
> tmp.nft:29:1-1: Error: syntax error, unexpected '}'
> }
> ^
>
> what's specifically DISallowed in my SET3 syntax usage?
Missing 'jump' or 'goto' keyword: meta mark set 2 jump { meta ...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-18 21:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-18 19:44 syntax issues when reducing rules through grouping ? pgnd
2024-07-18 21:00 ` Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).