NetworkManager minor version check is probably unnecessary

Author: stephen-huanCreated Nov 25, 2023Updated Sep 24, 2026
LabelsenhancementLinux

Issue report

Operating system: NixOS 23.11.20231102.fa804ed (Tapir)

App version: mullvad-cli 2023.5

Issue description

Currently the NetworkManager DNS manager is only used if NetworkManager's version is between 16 and 26.

rust
const MINIMUM_SUPPORTED_MAJOR_VERSION: u32 = 1;
const MINIMUM_SUPPORTED_MINOR_VERSION: u32 = 16;


const MAXIMUM_SUPPORTED_MAJOR_VERSION: u32 = 1;
const MAXIMUM_SUPPORTED_MINOR_VERSION: u32 = 26;

Considering NetworkManager 1.26 is over 3 years old at this point, many popular Linux distros don't carry it.

I'm using NetworkManager 1.44.0. Changing

rust
const MAXIMUM_SUPPORTED_MINOR_VERSION: u32 = 44;

and recompiling seems to work fine, i.e. the connection works, mullvad-daemon -v shows

[2023-11-25 07:48:23.728][talpid_core::dns][INFO] Setting DNS servers to 10.64.0.1
[2023-11-25 07:48:23.732][talpid_core::dns::imp][DEBUG] Managing DNS via network manager
[2023-11-25 07:48:23.761][mullvad_daemon][DEBUG] New tunnel state: Connected { ...

and the contents of /etc/resolv.conf and /run/NetworkManager/resolv.conf are both

# Generated by NetworkManager
nameserver 10.64.0.1

as expected.

It seems this version check was introduced in c2fe8beebd7641657974f76ab6dc33ed379e2e26, and 5d8fe0f8e75fd0b942285d3782c358a37d3dc34c says the reasoning was that

One other solution that was considered was to just prefer NM over systemd-resolved, and we already kind of could do that, but the coming NM versions (1.28 and up) seem to not be able to manage DNS via it's own /etc/resolv.conf.

I'm not sure what the reasoning behind that is. The only major DNS change I could find in the project changelog since 1.26 is that the default setting for rc-manager was changed to auto in 1.28.

  • Introduce a new "rc-manager=auto" setting and make it the default, unless a different default is chosen at compile time. This mode tries to detect "systemd-resolved", "resolvconf", and "netconfig" and chooses the mode that seems most suitable depending on build setting and runtime detection. "resolvconf" and "netconfig" are only considered iff NetworkManager was built with the respective options enabled.

So although NetworkManager now defaults to systemd-resolved if it's used, as described in the man page rc-manager can be set to either symlink or file for NetworkManager to directly edit /etc/resolv.conf, and these options are probably not going away anytime soon. In light of this I would suggest removing the minor version check entirely, i.e.

diff
diff --git a/talpid-dbus/src/network_manager.rs b/talpid-dbus/src/network_manager.rs
index ba614f056..507d11a1b 100644
--- a/talpid-dbus/src/network_manager.rs
+++ b/talpid-dbus/src/network_manager.rs
@@ -54,7 +54,6 @@ const MINIMUM_SUPPORTED_MAJOR_VERSION: u32 = 1;
 const MINIMUM_SUPPORTED_MINOR_VERSION: u32 = 16;
 
 const MAXIMUM_SUPPORTED_MAJOR_VERSION: u32 = 1;
-const MAXIMUM_SUPPORTED_MINOR_VERSION: u32 = 26;
 
 const NM_DEVICE_STATE_CHANGED: &str = "StateChanged";
 
@@ -224,8 +223,6 @@ impl NetworkManager {
 
     fn ensure_nm_is_old_enough_for_dns(major_version: u32, minor_version: u32) -> Result<()> {
         if major_version > MAXIMUM_SUPPORTED_MAJOR_VERSION
-            || (minor_version > MAXIMUM_SUPPORTED_MINOR_VERSION
-                && major_version >= MAXIMUM_SUPPORTED_MAJOR_VERSION)
         {
             Err(Error::NMTooNewFroDns(major_version, minor_version))
         } else {
@@ -745,6 +742,5 @@ mod test {
         NetworkManager::ensure_nm_is_new_enough_for_wireguard(1, 16).unwrap();
         NetworkManager::ensure_nm_is_old_enough_for_dns(1, 26).unwrap();
         assert!(NetworkManager::ensure_nm_is_new_enough_for_wireguard(1, 14).is_err());
-        assert!(NetworkManager::ensure_nm_is_old_enough_for_dns(1, 28).is_err());
     }
 }