mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
dhcp: fix comparison with previous lease
Follow-up for f8862395e8
.
Fixes #12816.
This commit is contained in:
parent
0ef67b7376
commit
3d9f670783
@ -1385,6 +1385,23 @@ static int client_handle_forcerenew(sd_dhcp_client *client, DHCPMessage *force,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool lease_equal(const sd_dhcp_lease *a, const sd_dhcp_lease *b) {
|
||||||
|
if (a->address != b->address)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (a->subnet_mask != b->subnet_mask)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (a->router_size != b->router_size)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < a->router_size; i++)
|
||||||
|
if (a->router[i].s_addr != b->router[i].s_addr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t len) {
|
static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t len) {
|
||||||
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
|
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
|
||||||
_cleanup_free_ char *error_message = NULL;
|
_cleanup_free_ char *error_message = NULL;
|
||||||
@ -1437,12 +1454,10 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t le
|
|||||||
|
|
||||||
r = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE;
|
r = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE;
|
||||||
if (client->lease) {
|
if (client->lease) {
|
||||||
if (client->lease->address != lease->address ||
|
if (lease_equal(client->lease, lease))
|
||||||
client->lease->subnet_mask != lease->subnet_mask ||
|
|
||||||
client->lease->router != lease->router) {
|
|
||||||
r = SD_DHCP_CLIENT_EVENT_IP_CHANGE;
|
|
||||||
} else
|
|
||||||
r = SD_DHCP_CLIENT_EVENT_RENEW;
|
r = SD_DHCP_CLIENT_EVENT_RENEW;
|
||||||
|
else
|
||||||
|
r = SD_DHCP_CLIENT_EVENT_IP_CHANGE;
|
||||||
|
|
||||||
client->lease = sd_dhcp_lease_unref(client->lease);
|
client->lease = sd_dhcp_lease_unref(client->lease);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user