]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: report transient DHCP failure to the caller
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 8 Oct 2020 14:51:25 +0000 (16:51 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Nov 2020 03:37:36 +0000 (12:37 +0900)
So far we only reported major state transitions like failure to acquire
the message. Let's report the initial failure after a few timeouts in
a new event type.

The number of timeouts is hardcoded as 3, since Windows seems to be using
that. I don't think we need to make this configurable out of the box. A
reasonable default may be enough.

src/libsystemd-network/sd-dhcp-client.c
src/systemd/sd-dhcp-client.h

index 76f762cf9698be3e0818d1c3f84a8fd3576e9ee5..f47a542483444f6be3f653a6d949858dddb46561 100644 (file)
@@ -38,6 +38,9 @@
 #define RESTART_AFTER_NAK_MIN_USEC (1 * USEC_PER_SEC)
 #define RESTART_AFTER_NAK_MAX_USEC (30 * USEC_PER_MINUTE)
 
+#define TRANSIENT_FAILURE_ATTEMPTS 3 /* Arbitrary limit: how many attempts are considered enough to report
+                                      * transient failure. */
+
 typedef struct sd_dhcp_client_id {
         uint8_t type;
         union {
@@ -1299,6 +1302,9 @@ static int client_timeout_resend(
                 goto error;
         }
 
+        if (client->attempt >= TRANSIENT_FAILURE_ATTEMPTS)
+                client_notify(client, SD_DHCP_CLIENT_EVENT_TRANSIENT_FAILURE);
+
         return 0;
 
 error:
index 44bafe6df5de06a95d12e1ac0e6e3510b451a60d..c35328a9a6fc6d87e615c5bb894c3fb560da9a98 100644 (file)
@@ -40,6 +40,8 @@ enum {
         SD_DHCP_CLIENT_EVENT_EXPIRED            = 3,
         SD_DHCP_CLIENT_EVENT_RENEW              = 4,
         SD_DHCP_CLIENT_EVENT_SELECTING          = 5,
+        SD_DHCP_CLIENT_EVENT_TRANSIENT_FAILURE  = 6, /* Sent when we have not received a reply after the first few attempts.
+                                                      * The client may want to start acquiring link-local addresses. */
 };
 
 enum {