diff options
author | Dan Streetman <ddstreet@canonical.com> | 2020-12-14 15:50:11 -0500 |
---|---|---|
committer | Dan Streetman <ddstreet@canonical.com> | 2020-12-14 17:39:26 -0500 |
commit | f3bd46c657d9ffd4c34624fbbff23d21d5848ca4 (patch) | |
tree | ab07a4f62243ccd8ee64e5534c9e08fb68f67732 | |
parent | e3284031ae6764614ce5d745ffbe3ad6da97970e (diff) | |
download | systemd-f3bd46c657d9ffd4c34624fbbff23d21d5848ca4.tar.gz |
sd-dhcp-client: don't log timeouts if already expired
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index f47a542483..face7d7dd6 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -1712,13 +1712,13 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { if (r < 0) return r; - log_dhcp_client(client, "lease expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, lifetime_timeout - time_now, USEC_PER_SEC)); - /* don't arm earlier timeouts if this has already expired */ if (lifetime_timeout <= time_now) return 0; + log_dhcp_client(client, "lease expires in %s", + format_timespan(time_string, FORMAT_TIMESPAN_MAX, lifetime_timeout - time_now, USEC_PER_SEC)); + /* arm T2 timeout */ r = event_reset_time(client->event, &client->timeout_t2, clock_boottime_or_monotonic(), @@ -1728,13 +1728,13 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { if (r < 0) return r; - log_dhcp_client(client, "T2 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, t2_timeout - time_now, USEC_PER_SEC)); - /* don't arm earlier timeout if this has already expired */ if (t2_timeout <= time_now) return 0; + log_dhcp_client(client, "T2 expires in %s", + format_timespan(time_string, FORMAT_TIMESPAN_MAX, t2_timeout - time_now, USEC_PER_SEC)); + /* arm T1 timeout */ r = event_reset_time(client->event, &client->timeout_t1, clock_boottime_or_monotonic(), @@ -1744,8 +1744,9 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { if (r < 0) return r; - log_dhcp_client(client, "T1 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, t1_timeout - time_now, USEC_PER_SEC)); + if (t1_timeout > time_now) + log_dhcp_client(client, "T1 expires in %s", + format_timespan(time_string, FORMAT_TIMESPAN_MAX, t1_timeout - time_now, USEC_PER_SEC)); return 0; } |