From 4f7862a656e01cf56849639db1f4ed32bfaf11d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=A4rdian?= Date: Tue, 5 Dec 2023 12:20:07 +0100 Subject: [PATCH] networkd: move KeepConfiguration= into [Network] section Fixup for https://github.com/canonical/netplan/pull/424 --- src/networkd.c | 8 ++++---- tests/generator/test_common.py | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/networkd.c b/src/networkd.c index 7ddd30568..5554c99d6 100644 --- a/src/networkd.c +++ b/src/networkd.c @@ -844,6 +844,9 @@ netplan_netdef_write_network_file( if (def->type >= NETPLAN_DEF_TYPE_VIRTUAL || def->ignore_carrier) g_string_append(network, "ConfigureWithoutCarrier=yes\n"); + if (def->critical) + g_string_append_printf(network, "KeepConfiguration=true\n"); + if (def->bridge && def->backend != NETPLAN_BACKEND_OVS) { g_string_append_printf(network, "Bridge=%s\n", def->bridge); @@ -916,14 +919,11 @@ netplan_netdef_write_network_file( } } - if (def->dhcp4 || def->dhcp6 || def->critical) { + if (def->dhcp4 || def->dhcp6) { /* NetworkManager compatible route metrics */ g_string_append(network, "\n[DHCP]\n"); } - if (def->critical) - g_string_append_printf(network, "KeepConfiguration=true\n"); - if (def->dhcp4 || def->dhcp6) { if (def->dhcp_identifier) g_string_append_printf(network, "ClientIdentifier=%s\n", def->dhcp_identifier); diff --git a/tests/generator/test_common.py b/tests/generator/test_common.py index c013010c4..785f6f426 100644 --- a/tests/generator/test_common.py +++ b/tests/generator/test_common.py @@ -480,8 +480,6 @@ def test_dhcp_critical_true(self): [Network] LinkLocalAddressing=ipv6 - -[DHCP] KeepConfiguration=true '''})