Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iptables compat fixes #147

Merged
merged 3 commits into from Aug 19, 2022
Merged

Iptables compat fixes #147

merged 3 commits into from Aug 19, 2022

Conversation

tohojo
Copy link
Owner

@tohojo tohojo commented Jan 25, 2022

A couple of fixes to be more compatible with iptables-nft, and to allow us to lift the hard package dependency on iptables in the openwrt package...

@@ -33,8 +33,10 @@
[ -z "$IP_BINARY" ] && IP_BINARY=$(command -v ip)
[ -z "$IPTABLES" ] && IPTABLES=iptables_wrapper
[ -z "$IPTABLES_BINARY" ] && IPTABLES_BINARY=$(command -v iptables)
[ -z "$IPTABLES_BINARY" ] && IPTABLES_BINARY=$(command -v iptables-nft)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please switch the order, so that iptables-nft is evaluated first.
Otherwise the first line, with iptables, populates the IPTABLES_BINARY variable, and the added second line is worthless.
Or did I understood the the logic wrong?

(There will likely be iptables present for the near future, due to scrambled dependencies...)

The same comment for the ip6tables below.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure that is the right thing to do in general, though? Having both binaries available is really a weird setup, and I'm not sure we can assume any order in general.

Maybe a better solution for openwrt would be to explicitly set IP{,6}TABLES_BINARY in /etc/sqm/sqm.conf for the platform?

@hnyman
Copy link

hnyman commented Jan 25, 2022

Iptables will likely "in general" be there for the near future. Iptables is so tightly/widely in the package dependencies that it will take time to sort out...
(...once somebody with enough knowledge about the netfilter universe dependencies actually tackles the issue.)

My logic starts from the perspective that in master the presence of iptables-nft likely means that firewall4 and nftables is in use, so iptables-nft should be preferred (and thus evaluated first). As the fallback option, mainly for 21.02 etc., the old iptables can be evaluated.

@tohojo
Copy link
Owner Author

tohojo commented Jan 25, 2022

Hmm, just checked on my own machine, and that has both binaries as well, both provided by the 'iptables' package. So presence of the binaries is definitely not a good indicator for which is in use :/

So that leaves platform-specific configuration. I think we could just stick a IPTABLES_BINARY=$(command -v iptables-nft) into sqm.conf on openwrt; if that fails we'll still fall back to the existing code in defaults.sh to pick up iptables if that exists. And just drop the second autodetection from defaults.sh altogether as that hardly seems to be useful...

For systems switching to nftables, the iptables-nft binary can be used as a
compatibility layer for applications relying on iptables. Not every
distribution (notably OpenWrt) installs a symlink from iptables-nft to
iptables, though, so add a fallback check for iptables-nft if we can't find
iptables itself.

Both binaries can be present on the same system simultaneously, so we can't
really infer anything from their presence. In the interest of not breaking
existing setups, prefer the regular 'iptables' binary over 'iptables-nft'.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Add a new function to explicitly check if we found an iptables binary on
startup; and call this from simple.qos so we can error out when this
happens.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
OpenWrt is moving to using nftables by default, but the 'iptables' binary
is likely to stick around for a while. So add a platform-specific
preference for using iptables-nft (if it exists). We'll still fall back to
'iptables' if 'iptables-nft' is not installed on the system, and we'll
still get the warning if neither exists and simple.qos is used.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
@dtaht
Copy link
Collaborator

dtaht commented Jan 25, 2022

LGTM.

@kokroo
Copy link

kokroo commented Aug 1, 2022

So can we merge this?

@tohojo
Copy link
Owner Author

tohojo commented Aug 19, 2022

Hmm, yeah, not sure why we never got around to merging it...

@tohojo tohojo merged commit 7ce734e into master Aug 19, 2022
@tohojo tohojo deleted the iptables-compat branch August 19, 2022 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants