($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH] netconfig: Always set DHCP MAC address on start
Date: Fri, 24 Nov 2023 10:17:26 -0600	[thread overview]
Message-ID: <20231124161740.1243946-1-denkenz@gmail.com> (raw)

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


             reply	other threads:[~2023-11-24 16:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 16:17 Denis Kenzior [this message]
2023-11-24 18:40 ` [PATCH] netconfig: Always set DHCP MAC address on start Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231124161740.1243946-1-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).