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

nixos/networkmanager: default firewallBackend to nftables, remove firewallBackend #240918

Merged

Conversation

SuperSandro2000
Copy link
Member

Description of changes

see #161428

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

nixos/modules/services/networking/networkmanager.nix Outdated Show resolved Hide resolved
@SuperSandro2000 SuperSandro2000 force-pushed the networkmanager-firewall-backend branch from 888888b to c0f12da Compare July 14, 2023 19:36
@mkg20001
Copy link
Member

mkg20001 commented Sep 5, 2023

@flokli What's left (besides CI green) for this to be ready?

@mkg20001 mkg20001 force-pushed the networkmanager-firewall-backend branch 2 times, most recently from 7489b2d to 4f3a238 Compare September 5, 2023 17:58
@flokli
Copy link
Contributor

flokli commented Sep 6, 2023

Didn't we switch the iptables binary to iptables-nftables-compat in #81172, so even with config.networking.nftables.enable set to false (the default still?) all iptables rules are in fact also nft rules?

NetworkManager also seems to have an autodetection mode, which will use nft as soon as an nft binary is available, and only fall back in case only iptables binary is present. I assume most distros these days have an nft in $PATH.

I'd probably change this config option to default to being /unset/, and make sure nftables is in the NetworkManager $PATH, so it normally uses nft. This matches closer the behaviour on other distros, and follows the principle of least surprise.

People who then explicitly want to still use the iptables binary (to see the NetworkManager-configured rules in an iptables-nftables-compat/iptables-legacy invocation) could set the option, but leaving the option unset in NixOS, and having NetworkManager use its default logic seems like the right path forward to me.

@mkg20001
Copy link
Member

automatic detection simply checks if the nft executable exists and then uses nft right away, which i assume will always be the case in nixos since we patch the path in

meaning the effective default is nftables.

will it be more or less confusing if we set this explicitly?
can legacy iptables even still be enabled? otherwise we might want to get rid of the firewallBackend

static NMFirewallBackend
_firewall_backend_detect(void)
{
    if (g_file_test(NFT_PATH, G_FILE_TEST_IS_EXECUTABLE))
        return NM_FIREWALL_BACKEND_NFTABLES;
    if (g_file_test(IPTABLES_PATH, G_FILE_TEST_IS_EXECUTABLE))
        return NM_FIREWALL_BACKEND_IPTABLES;

    return NM_FIREWALL_BACKEND_NFTABLES;
}
```

@flokli
Copy link
Contributor

flokli commented Sep 18, 2023

I think people can still opt out of nftables by overwriting the iptables binary to the legacy one. At least the example in networking.firewall.package mentions it as an example. This is probably not tested at all, and not sure if it's worthwhile putting in that work still.

I'd probably just remove the networking.networkmanager.firewallBackendoption entirely, and keep the autodetection code in NetworkManager itself.

@mkg20001
Copy link
Member

I'd probably just remove the networking.networkmanager.firewallBackendoption entirely, and keep the autodetection code in NetworkManager itself.

So it should only use nftables then (see other comment)? I'll edit that then

@flokli
Copy link
Contributor

flokli commented Sep 20, 2023

SGTM!

@mkg20001 mkg20001 force-pushed the networkmanager-firewall-backend branch from 4f3a238 to 473807a Compare September 20, 2023 11:38
@mkg20001 mkg20001 changed the title nixos/networkmanager: default firewallBackend to nftables if networking.nftables is used nixos/networkmanager: default firewallBackend to nftables, remove firewallBackend Sep 20, 2023
@mkg20001 mkg20001 force-pushed the networkmanager-firewall-backend branch 2 times, most recently from 0ff8c34 to 2a92117 Compare September 20, 2023 12:10
@mkg20001 mkg20001 force-pushed the networkmanager-firewall-backend branch from 1e8f7b1 to d4d6bd4 Compare September 21, 2023 13:17
Copy link
Contributor

@jian-lin jian-lin left a comment

Choose a reason for hiding this comment

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

some nitpicking

nixos/modules/services/networking/networkmanager.nix Outdated Show resolved Hide resolved
nixos/doc/manual/release-notes/rl-2311.section.md Outdated Show resolved Hide resolved
SuperSandro2000 and others added 2 commits September 21, 2023 16:18
…ewallBackend

Co-authored-by: Florian Klink <flokli@flokli.de>

Co-authored-by: Lin Jian <me@linj.tech>
Co-authored-by: Florian Klink <flokli@flokli.de>

Co-authored-by: Lin Jian <me@linj.tech>
@mkg20001 mkg20001 force-pushed the networkmanager-firewall-backend branch from a686414 to 7fd7b57 Compare September 21, 2023 14:19
@mkg20001 mkg20001 merged commit b6f8848 into NixOS:master Sep 21, 2023
19 checks passed
@SuperSandro2000 SuperSandro2000 deleted the networkmanager-firewall-backend branch September 21, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants