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

[RFC] Set keep-configuration=no by default for Network Manager #519

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions netplan_cli/cli/commands/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,7 @@ def command_apply(self, run_generate=True, sync=False, exit_on_error=True, state
# 2nd: start all other services
utils.systemctl('start', netplan_wpa + netplan_ovs, sync=True)
if restart_nm:
# Flush all IP addresses of NM managed interfaces, to avoid NM creating
# new, non netplan-* connection profiles, using the existing IPs.
nm_interfaces = utils.nm_interfaces(restart_nm_glob, devices)
for iface in nm_interfaces:
utils.ip_addr_flush(iface)
Comment on lines -296 to -297
Copy link
Collaborator

Choose a reason for hiding this comment

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

note: We need to confirm that this doesn't regress https://bugs.launchpad.net/netplan/+bug/1870561

# clear NM state, especially the [device].managed=true config, as that might have been
# re-set via an udev rule setting "NM_UNMANAGED=1"
shutil.rmtree('/run/NetworkManager/devices', ignore_errors=True)
Expand Down
13 changes: 12 additions & 1 deletion src/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,20 @@ int main(int argc, char** argv)

/* Disable /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf
* (which restricts NM to wifi and wwan) if "renderer: NetworkManager" is used anywhere */
if (netplan_state_get_backend(np_state) == NETPLAN_BACKEND_NM || any_nm)
if (netplan_state_get_backend(np_state) == NETPLAN_BACKEND_NM || any_nm) {
_netplan_g_string_free_to_file(g_string_new(NULL), rootdir, "/run/NetworkManager/conf.d/10-globally-managed-devices.conf", NULL);

/*
* Always try to match existing interfaces with connections.
* Because "netplan apply" is too aggressive with Network Manager connections it might
* create in-memory profiles for existing virtual interfaces.
* keep-configuration forces NM to use existing connection profiles for these interfaces avoiding
* this problem.
*/
_netplan_g_string_free_to_file(g_string_new("[device]\nkeep-configuration=no\n"), rootdir,
"/run/NetworkManager/conf.d/10-keep-configuration.conf", NULL);
Comment on lines +317 to +318
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: should this be included in /run/NetworkManager/conf.d/netplan.con instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe rather ship is as a configuration file from the Netplan package, instead of generating it?

}

gboolean enable_wait_online = FALSE;
if (any_networkd)
enable_wait_online = _netplan_networkd_write_wait_online(np_state, rootdir);
Expand Down
3 changes: 3 additions & 0 deletions src/nm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,11 @@ _netplan_nm_cleanup(const char* rootdir)
"/run/NetworkManager/conf.d/netplan.conf", NULL);
g_autofree char* global_manage_path = g_strjoin(NULL, rootdir != NULL ? rootdir : "",
"/run/NetworkManager/conf.d/10-globally-managed-devices.conf", NULL);
g_autofree char* keep_configuration_path = g_strjoin(NULL, rootdir != NULL ? rootdir : "",
"/run/NetworkManager/conf.d/10-keep-configuration.conf", NULL);
unlink(confpath);
unlink(global_manage_path);
unlink(keep_configuration_path);
_netplan_unlink_glob(rootdir, "/run/NetworkManager/system-connections/netplan-*");
return TRUE;
}
Loading