From ebc42ccecf6892ef0009261dbc8e9a2012c2a2fc Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 23 Nov 2020 14:25:00 -0600 Subject: [PATCH] netconfig: Don't re-create address on RENEWAL ==5279== 104 bytes in 2 blocks are definitely lost in loss record 1 of 1 ==5279== at 0x4C2F0CF: malloc (vg_replace_malloc.c:299) ==5279== by 0x4655CD: l_malloc (util.c:61) ==5279== by 0x47116B: l_rtnl_address_new (rtnl.c:136) ==5279== by 0x438F4B: netconfig_get_dhcp4_address (netconfig.c:429) ==5279== by 0x438F4B: netconfig_ipv4_dhcp_event_handler (netconfig.c:735) ==5279== by 0x491C77: dhcp_client_event_notify (dhcp.c:332) ==5279== by 0x491C77: dhcp_client_rx_message (dhcp.c:810) ==5279== by 0x492A88: _dhcp_default_transport_read_handler (dhcp-transport.c:151) ==5279== by 0x46BECB: io_callback (io.c:118) ==5279== by 0x46B10C: l_main_iterate (main.c:477) ==5279== by 0x46B1DB: l_main_run (main.c:524) ==5279== by 0x46B3EA: l_main_run_with_signal (main.c:646) ==5279== by 0x403ECE: main (main.c:490) --- src/netconfig.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/netconfig.c b/src/netconfig.c index f22e186c..dcb88749 100644 --- a/src/netconfig.c +++ b/src/netconfig.c @@ -729,9 +729,14 @@ static void netconfig_ipv4_dhcp_event_handler(struct l_dhcp_client *client, l_debug("DHCPv4 event %d", event); switch (event) { - case L_DHCP_CLIENT_EVENT_LEASE_RENEWED: - case L_DHCP_CLIENT_EVENT_LEASE_OBTAINED: case L_DHCP_CLIENT_EVENT_IP_CHANGED: + L_WARN_ON(!l_rtnl_ifaddr_delete(rtnl, netconfig->ifindex, + netconfig->v4_address, + netconfig_ifaddr_del_cmd_cb, + netconfig, NULL)); + l_rtnl_address_free(netconfig->v4_address); + /* Fall through. */ + case L_DHCP_CLIENT_EVENT_LEASE_OBTAINED: netconfig->v4_address = netconfig_get_dhcp4_address(netconfig); if (!netconfig->v4_address) { l_error("netconfig: Failed to obtain IP addresses from " @@ -744,6 +749,8 @@ static void netconfig_ipv4_dhcp_event_handler(struct l_dhcp_client *client, netconfig_ipv4_ifaddr_add_cmd_cb, netconfig, NULL)); break; + case L_DHCP_CLIENT_EVENT_LEASE_RENEWED: + break; case L_DHCP_CLIENT_EVENT_LEASE_EXPIRED: L_WARN_ON(!l_rtnl_ifaddr_delete(rtnl, netconfig->ifindex, netconfig->v4_address,