firewall4
firewall4 copied to clipboard
ruleset: avoid no-op port translation in dnat
Correct rport null propagation moving compensatory conditional to reflection snat rule only. Emit shorthand rules if user did not specify redirect target port This saves 2 bytecodes in rule and kernel does not do no-op port rewrite. Also tweak tests to cover changed rules. V2 add test case from WIKI https://openwrt.org/docs/guide-user/firewall/fw3_configurations/intercept_dns#dns_redirection V3 omit unchanged dport in config example
# old
meta nfproto ipv4 tcp dport 53 counter dnat 192.0.2.0:53
# new
meta nfproto ipv4 tcp dport 53 counter dnat 192.0.2.0
It could be even shorter with no place for counter abusing nft-nat-s builtin nfproto filter.
tcp dport 53 dnat ip 192.0.2.0
Also can zap remote port if equal and optimize user's rule.