summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-05-06 13:48:25 +0200
committerThomas Haller <thaller@redhat.com>2022-05-06 13:48:25 +0200
commit3a49d158e035f7eb3258453f678e575da236e569 (patch)
tree5b724d21f451ee36464a736fb17bd12bb9e68e9e
parentaba56902d181f383bfb3d55cb3538e40866f4fdf (diff)
Squashed 'src/n-dhcp4/' changes from 64513e31c01a..e4af93228e37
e4af93228e37 probe: forget lease after a NAK c39e1fe74463 connection: discard NAKs from other servers in SELECTING git-subtree-dir: src/n-dhcp4 git-subtree-split: e4af93228e3772bbb443ec1237252e6a2f3e3dd7
-rw-r--r--src/n-dhcp4-c-connection.c19
-rw-r--r--src/n-dhcp4-c-probe.c3
-rw-r--r--src/n-dhcp4-private.h1
3 files changed, 21 insertions, 2 deletions
diff --git a/src/n-dhcp4-c-connection.c b/src/n-dhcp4-c-connection.c
index 45a28de212..65328286e8 100644
--- a/src/n-dhcp4-c-connection.c
+++ b/src/n-dhcp4-c-connection.c
@@ -705,6 +705,7 @@ int n_dhcp4_c_connection_select_new(NDhcp4CConnection *connection,
message->userdata.start_time = offer->userdata.start_time;
message->userdata.base_time = offer->userdata.base_time;
message->userdata.client_addr = client.s_addr;
+ message->userdata.server_id = server.s_addr;
n_dhcp4_incoming_get_xid(offer, &xid);
n_dhcp4_outgoing_set_xid(message, xid);
@@ -1229,6 +1230,24 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection,
serv_addr, sizeof(serv_addr)));
}
+ if (type == N_DHCP4_MESSAGE_NAK &&
+ connection->request->userdata.server_id != INADDR_ANY) {
+ struct in_addr server;
+
+ r = n_dhcp4_incoming_query_server_identifier(message, &server);
+ if (r)
+ return N_DHCP4_E_AGAIN;
+
+ if (connection->request->userdata.server_id != server.s_addr) {
+ n_dhcp4_log(connection->log_queue,
+ LOG_DEBUG,
+ "discarded NAK with wrong server-id %s",
+ inet_ntop(AF_INET, &server,
+ serv_addr, sizeof(serv_addr)));
+ return N_DHCP4_E_AGAIN;
+ }
+ }
+
switch (type) {
case N_DHCP4_MESSAGE_OFFER:
case N_DHCP4_MESSAGE_ACK:
diff --git a/src/n-dhcp4-c-probe.c b/src/n-dhcp4-c-probe.c
index 7f20ac0527..283c1693cf 100644
--- a/src/n-dhcp4-c-probe.c
+++ b/src/n-dhcp4-c-probe.c
@@ -995,14 +995,13 @@ static int n_dhcp4_client_probe_transition_nak(NDhcp4ClientProbe *probe) {
case N_DHCP4_CLIENT_PROBE_STATE_RENEWING:
case N_DHCP4_CLIENT_PROBE_STATE_REBINDING:
- /* XXX */
-
r = n_dhcp4_client_probe_raise(probe,
NULL,
N_DHCP4_CLIENT_EVENT_RETRACTED);
if (r)
return r;
+ probe->current_lease = n_dhcp4_client_lease_unref(probe->current_lease);
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 * 2u,
diff --git a/src/n-dhcp4-private.h b/src/n-dhcp4-private.h
index 8d3f14f5d7..858c3d3ab0 100644
--- a/src/n-dhcp4-private.h
+++ b/src/n-dhcp4-private.h
@@ -202,6 +202,7 @@ struct NDhcp4Outgoing {
uint8_t type;
uint8_t message_type;
uint32_t client_addr;
+ uint32_t server_id;
uint64_t start_time;
uint64_t base_time;
uint64_t send_time;