diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-02-14 22:09:34 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-02-17 18:58:47 +0100 |
commit | 3286918bd96d16e3c798963146c32486a6369b2f (patch) | |
tree | 961a59e744442bd88611c8ab3d35e0bd1dacf594 /shared | |
parent | 037507f790c53ac7e05b26046cb4f4dfa0fa6d24 (diff) | |
download | NetworkManager-3286918bd96d16e3c798963146c32486a6369b2f.tar.gz |
n-dhcp4: request previous address after expiration
If the lease expires and the client start again sending a discover,
request the previous address.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-c-probe.c | 13 | ||||
-rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-private.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-probe.c b/shared/n-dhcp4/src/n-dhcp4-c-probe.c index bfead036bd..e4477a7c74 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-probe.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-probe.c @@ -436,7 +436,10 @@ int n_dhcp4_client_probe_new(NDhcp4ClientProbe **probep, if (r) return r; - if (probe->config->init_reboot && probe->config->requested_ip.s_addr != INADDR_ANY) + if (probe->config->requested_ip.s_addr != INADDR_ANY) + probe->last_address = probe->config->requested_ip; + + if (probe->config->init_reboot && probe->last_address.s_addr != INADDR_ANY) probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT_REBOOT; else probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT; @@ -648,7 +651,7 @@ static int n_dhcp4_client_probe_transition_reboot(NDhcp4ClientProbe *probe, uint if (r) return r; - r = n_dhcp4_c_connection_reboot_new(&probe->connection, &request, &probe->config->requested_ip); + r = n_dhcp4_c_connection_reboot_new(&probe->connection, &request, &probe->last_address); if (r) return r; @@ -700,8 +703,8 @@ static int n_dhcp4_client_probe_transition_deferred(NDhcp4ClientProbe *probe, ui if (r) return r; - if (!probe->config->init_reboot && probe->config->requested_ip.s_addr != INADDR_ANY) { - r = n_dhcp4_outgoing_append_requested_ip(request, probe->config->requested_ip); + if (probe->last_address.s_addr != INADDR_ANY) { + r = n_dhcp4_outgoing_append_requested_ip(request, probe->last_address); if (r) return r; } @@ -841,6 +844,7 @@ static int n_dhcp4_client_probe_transition_lifetime(NDhcp4ClientProbe *probe) { return r; c_assert(probe->client->current_probe == probe); + probe->current_lease = n_dhcp4_client_lease_unref(probe->current_lease); probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT; @@ -945,6 +949,7 @@ static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4I n_dhcp4_client_lease_unref(probe->current_lease); probe->current_lease = n_dhcp4_client_lease_ref(lease); probe->state = N_DHCP4_CLIENT_PROBE_STATE_BOUND; + n_dhcp4_client_lease_get_yiaddr(lease, &probe->last_address); probe->ns_nak_restart_delay = 0; break; diff --git a/shared/n-dhcp4/src/n-dhcp4-private.h b/shared/n-dhcp4/src/n-dhcp4-private.h index b5936ddf84..436ee8065c 100644 --- a/shared/n-dhcp4/src/n-dhcp4-private.h +++ b/shared/n-dhcp4/src/n-dhcp4-private.h @@ -350,6 +350,7 @@ struct NDhcp4ClientProbe { void *userdata; unsigned int state; /* current probe state */ + struct in_addr last_address; /* last address obtained */ uint64_t ns_deferred; /* timeout for deferred action */ uint64_t ns_reinit; uint64_t ns_nak_restart_delay; /* restart delay after a nak */ |