]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: reset 'configured' flags even if we keep DHCP lease and friends on reconfigure
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 7 Nov 2024 00:52:03 +0000 (09:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Nov 2024 02:53:24 +0000 (11:53 +0900)
Follow-up for 451c2baf30f50b95d73e648058c7c2348dbf0c31.

With the commits, reloading .network files does not release previously
acquired DHCP lease and friends if possible. If previously a DHCP client
was configured as not requesting DNS servers or so, then the previously
acquired lease might not contain any DNS servers. In that case, if the
new .network file enables UseDNS=, then the interface should enter the
configured state after a new lease is acquired. To achieve that, we need
to reset the flags.

With this change, the workaround applied to the test by the commit
451c2baf30f50b95d73e648058c7c2348dbf0c31 can be dropped.

src/network/networkd-link.c
test/test-network/systemd-networkd-tests.py

index ab74260adbe9fb49a1df0e41350780e81fbaac12..f9047103c017a191e267feee5336dded8cf3e4e0 100644 (file)
@@ -1136,6 +1136,15 @@ static int link_drop_dynamic_config(Link *link, Network *network) {
         link->lldp_rx = sd_lldp_rx_unref(link->lldp_rx); /* TODO: keep the received neighbors. */
         link->lldp_tx = sd_lldp_tx_unref(link->lldp_tx);
 
+        /* Even if we do not release DHCP lease or so, reset 'configured' flags. Otherwise, e.g. if
+         * previously UseDNS= was disabled but is now enabled, link will enter configured state before
+         * expected DNS servers being acquired. */
+        link->ipv4ll_address_configured = false;
+        link->dhcp4_configured = false;
+        link->dhcp6_configured = false;
+        link->dhcp_pd_configured = false;
+        link->ndisc_configured = false;
+
         return r;
 }
 
index 8ee94a02946c9d282f0701d7d0ba2fd9d33be1a6..59503d31a198bb99fc30f46523a67e083155425c 100755 (executable)
@@ -6705,7 +6705,6 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
                       '--dhcp-option=option6:ntp-server,[2600::ff]')
 
         networkctl_reload()
-        networkctl_reconfigure('veth99') # Release previously acquired lease and start new DHCPv6 handshake.
         self.wait_online('veth99:routable', 'veth-peer:routable')
 
         # checking address