From 4e3e6679e8f73b83d38e4b20d8b025e12991d1cb Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Fri, 10 Jul 2015 11:25:21 +0300 Subject: [PATCH] sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client reset When the DHCPv6 client is started by the library user or stopped for any reason, unref the DHCPv6 lease when resetting the DHCPv6 client data structure. This makes the DHCPv6 client always start from a clean state and not keep unnecessary an lease structure around when stopped. If this is not done, a previously existing lease information can be interpreted to be from another server when restarting DHCPv6. --- src/libsystemd-network/sd-dhcp6-client.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index e2f58628514..85bb1f3a8f5 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -272,6 +272,11 @@ static void client_notify(sd_dhcp6_client *client, int event) { static int client_reset(sd_dhcp6_client *client) { assert_return(client, -EINVAL); + if (client->lease) { + dhcp6_lease_clear_timers(&client->lease->ia); + client->lease = sd_dhcp6_lease_unref(client->lease); + } + client->receive_message = sd_event_source_unref(client->receive_message); -- 2.39.2