Commit 1ef0ec55 authored by Jordan Yates's avatar Jordan Yates Committed by Carles Cufi
Browse files

net: ip: dhcpv4: remove address on interface down

Any received address is no longer valid once the interface goes down.
Leaving the address assigned results in the L4 interface transitioning
through the following on reconnection:
 UP: Interface is connected
 DOWN: Old address is removed by DHCP
 UP: New address is re-added by DHCP

Signed-off-by: default avatarJordan Yates <jordan.yates@data61.csiro.au>
parent 434c93dd
Loading
Loading
Loading
Loading
+4 −0
Changes for subsys/net/ip/dhcpv4.c: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1163,6 +1163,10 @@ static void dhcpv4_iface_event_handler(struct net_mgmt_event_callback *cb,
			iface->config.dhcpv4.state = NET_DHCPV4_RENEWING;
			NET_DBG("enter state=%s", net_dhcpv4_state_name(
					iface->config.dhcpv4.state));
			/* Remove any bound address as interface is gone */
			if (!net_if_ipv4_addr_rm(iface, &iface->config.dhcpv4.requested_ip)) {
				NET_DBG("Failed to remove addr from iface");
			}
		}
	} else if (mgmt_event == NET_EVENT_IF_UP) {
		NET_DBG("Interface %p coming up", iface);