[PATCH] netconfig: Always set DHCP MAC address on start
Denis Kenzior <[email protected]> Fri, 24 Nov 2023 10:17:26 -0600
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
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(-) 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); -- 2.42.0