diff mbox series

netconfig: Always set DHCP MAC address on start

Message ID 20231124161740.1243946-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series netconfig: Always set DHCP MAC address on start | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

Denis Kenzior Nov. 24, 2023, 4:17 p.m. UTC
l_netconfig_stop() calls l_dhcp_client_stop which does not reset the
client MAC address being used.  Since the underlying MAC might have
changed (for example, due to per-network MAC address generation in iwd),
make sure that any subsequent l_netconfig_start() invocations will
update the DHCP client MAC.  This already happens for DHCPv6, but
somehow did not happen for DHCPv4.
---
 ell/netconfig.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Denis Kenzior Nov. 24, 2023, 6:40 p.m. UTC | #1
On 11/24/23 10:17, Denis Kenzior wrote:
> l_netconfig_stop() calls l_dhcp_client_stop which does not reset the
> client MAC address being used.  Since the underlying MAC might have
> changed (for example, due to per-network MAC address generation in iwd),
> make sure that any subsequent l_netconfig_start() invocations will
> update the DHCP client MAC.  This already happens for DHCPv6, but
> somehow did not happen for DHCPv4.
> ---
>   ell/netconfig.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 

Applied.
diff mbox series

Patch

diff --git a/ell/netconfig.c b/ell/netconfig.c
index 9b01581fff45..dc6cb0f6a8d9 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -1970,6 +1970,9 @@  LIB_EXPORT bool l_netconfig_start(struct l_netconfig *netconfig)
 	if (!netconfig_check_config(netconfig))
 		return false;
 
+	if (!l_net_get_mac_address(netconfig->ifindex, netconfig->mac))
+		return false;
+
 	if (!netconfig->v4_enabled)
 		goto configure_ipv6;
 
@@ -1984,6 +1987,9 @@  LIB_EXPORT bool l_netconfig_start(struct l_netconfig *netconfig)
 		goto configure_ipv6;
 	}
 
+	l_dhcp_client_set_address(netconfig->dhcp_client, ARPHRD_ETHER,
+					netconfig->mac, ETH_ALEN);
+
 	if (!l_dhcp_client_start(netconfig->dhcp_client))
 		return false;
 
@@ -2064,9 +2070,6 @@  configure_ipv6:
 	l_queue_push_tail(addr_wait_list, netconfig);
 	netconfig->have_lla = false;
 
-	if (!l_net_get_mac_address(netconfig->ifindex, netconfig->mac))
-		goto unregister;
-
 	l_dhcp6_client_set_address(netconfig->dhcp6_client, ARPHRD_ETHER,
 					netconfig->mac, ETH_ALEN);
 	l_icmp6_client_set_address(netconfig->icmp6_client, netconfig->mac);