summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-01-09 09:43:37 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2020-01-09 09:43:37 +0100
commit7129e669c0e30aa62a681833506c5e312018128e (patch)
tree359c4eb93ab21ed81a7c3d8f7435ef846bb006c9
parent900af25263b8ea502a070549eb863c945de41940 (diff)
parent2523000b36b113fd7b94ae6b7178f6fd33908ef9 (diff)
downloadNetworkManager-7129e669c0e30aa62a681833506c5e312018128e.tar.gz
dhcp: merge branch 'bg/nettools-fixes-pt2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/387
-rw-r--r--shared/n-dhcp4/src/n-dhcp4-c-connection.c3
-rw-r--r--shared/n-dhcp4/src/n-dhcp4-c-probe.c10
-rw-r--r--shared/n-dhcp4/src/n-dhcp4-private.h1
-rw-r--r--src/dhcp/nm-dhcp-nettools.c2
4 files changed, 11 insertions, 5 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
index e51a3e3249..f3ae44e2d9 100644
--- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c
+++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
@@ -139,6 +139,9 @@ int n_dhcp4_c_connection_listen(NDhcp4CConnection *connection) {
_c_cleanup_(c_closep) int fd_packet = -1;
int r;
+ if (connection->state == N_DHCP4_C_CONNECTION_STATE_PACKET)
+ return 0;
+
c_assert(connection->state == N_DHCP4_C_CONNECTION_STATE_INIT ||
connection->state == N_DHCP4_C_CONNECTION_STATE_DRAINING ||
connection->state == N_DHCP4_C_CONNECTION_STATE_UDP);
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-probe.c b/shared/n-dhcp4/src/n-dhcp4-c-probe.c
index 4fb7d3892a..82a089ee5f 100644
--- a/shared/n-dhcp4/src/n-dhcp4-c-probe.c
+++ b/shared/n-dhcp4/src/n-dhcp4-c-probe.c
@@ -946,7 +946,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;
-
+ probe->ns_nak_restart_delay = 0;
break;
case N_DHCP4_CLIENT_PROBE_STATE_REQUESTING:
@@ -969,7 +969,7 @@ static int n_dhcp4_client_probe_transition_ack(NDhcp4ClientProbe *probe, NDhcp4I
node->event.granted.lease = n_dhcp4_client_lease_ref(lease);
probe->current_lease = n_dhcp4_client_lease_ref(lease);
probe->state = N_DHCP4_CLIENT_PROBE_STATE_GRANTED;
-
+ probe->ns_nak_restart_delay = 0;
break;
case N_DHCP4_CLIENT_PROBE_STATE_INIT:
@@ -1004,9 +1004,11 @@ static int n_dhcp4_client_probe_transition_nak(NDhcp4ClientProbe *probe) {
return r;
probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT;
-
+ probe->ns_deferred = n_dhcp4_gettime(CLOCK_BOOTTIME) + probe->ns_nak_restart_delay;
+ probe->ns_nak_restart_delay = c_clamp(probe->ns_nak_restart_delay * 2,
+ UINT64_C(1000000000 * 2),
+ UINT64_C(1000000000 * 300));
break;
-
case N_DHCP4_CLIENT_PROBE_STATE_SELECTING:
case N_DHCP4_CLIENT_PROBE_STATE_INIT_REBOOT:
case N_DHCP4_CLIENT_PROBE_STATE_INIT:
diff --git a/shared/n-dhcp4/src/n-dhcp4-private.h b/shared/n-dhcp4/src/n-dhcp4-private.h
index fcfb0f35b8..c092ae8fc3 100644
--- a/shared/n-dhcp4/src/n-dhcp4-private.h
+++ b/shared/n-dhcp4/src/n-dhcp4-private.h
@@ -352,6 +352,7 @@ struct NDhcp4ClientProbe {
unsigned int state; /* current probe state */
uint64_t ns_deferred; /* timeout for deferred action */
uint64_t ns_reinit;
+ uint64_t ns_nak_restart_delay; /* restart delay after a nak */
NDhcp4ClientLease *current_lease; /* current lease */
NDhcp4CConnection connection; /* client connection wrapper */
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 30820c615a..76a2c2e0aa 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -1028,10 +1028,10 @@ dhcp4_event_handle (NMDhcpNettools *self,
_LOGW ("selecting lease failed: %d", r);
}
break;
+ case N_DHCP4_CLIENT_EVENT_RETRACTED:
case N_DHCP4_CLIENT_EVENT_EXPIRED:
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_EXPIRE, NULL, NULL);
break;
- case N_DHCP4_CLIENT_EVENT_RETRACTED:
case N_DHCP4_CLIENT_EVENT_CANCELLED:
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
break;