about summary refs log tree commit diff
path: root/src/n-dhcp4
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-03-23 11:52:46 +0100
committerMichael Biebl <biebl@debian.org>2022-03-23 11:52:46 +0100
commit024ee2bf31c1c57823c8bf6588714a4ede5baed1 (patch)
tree5fd63275acf48411b17c71c92771267359ba95d6 /src/n-dhcp4
parent0514770b02f34ccb56b6bc52010452663c6717ed (diff)
parent8c623dddbdebe354cb94bfc559a5371a14865317 (diff)
Update upstream source from tag 'upstream/1.36.4'
Update to upstream version '1.36.4'
with Debian dir 64567d8bf986e0827368a9989323ba0356fe2888
Diffstat (limited to 'src/n-dhcp4')
-rw-r--r--src/n-dhcp4/src/n-dhcp4-c-connection.c19
-rw-r--r--src/n-dhcp4/src/n-dhcp4-private.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/n-dhcp4/src/n-dhcp4-c-connection.c b/src/n-dhcp4/src/n-dhcp4-c-connection.c
index 4aba9739..2f660e3b 100644
--- a/src/n-dhcp4/src/n-dhcp4-c-connection.c
+++ b/src/n-dhcp4/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);
 
@@ -1224,6 +1225,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/src/n-dhcp4-private.h b/src/n-dhcp4/src/n-dhcp4-private.h
index db7b24ff..191e946e 100644
--- a/src/n-dhcp4/src/n-dhcp4-private.h
+++ b/src/n-dhcp4/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;