]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: restart dhcp4 client when renewing lease is requested but the client is...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Oct 2023 09:13:55 +0000 (18:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Oct 2023 09:14:11 +0000 (18:14 +0900)
Follow-up for fc35a9f8d1632c4e7a279228f869bfc77d8f5b9c.

Fixes the issue https://github.com/systemd/systemd/pull/29472#issuecomment-1759092138.

src/network/networkd-link-bus.c

index 06749307832635f4fd55f32b271eada4fbb00756..a42eb8dd63df0124aef1ba892e3519f6abcd9f50 100644 (file)
@@ -626,11 +626,15 @@ int bus_link_method_renew(sd_bus_message *message, void *userdata, sd_bus_error
         if (r == 0)
                 return 1; /* Polkit will call us back */
 
-        if (l->dhcp_client) {
+        if (sd_dhcp_client_is_running(l->dhcp_client))
                 r = sd_dhcp_client_send_renew(l->dhcp_client);
-                if (r < 0)
-                        return r;
-        }
+        else
+                /* The DHCPv4 client may have been stopped by the IPv6 only mode. Let's unconditionally
+                 * restart the client here. Note, if the DHCPv4 client is disabled, then dhcp4_start() does
+                 * nothing and returns 0. */
+                r = dhcp4_start(l);
+        if (r < 0)
+                return r;
 
         return sd_bus_reply_method_return(message, NULL);
 }