3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 23:09:34 +01:00

netconfig: Set address at configure time

netconfig_load_settings is called when establishing a new initial
association to a network.  This function tries to update dhcp/dhcpv6
clients with the MAC address of the netdev being used.  However, it is
too early to update the MAC here since netdev might need to powercycle
the underlying network device in order to update the MAC (i.e. when
AddressRandomization="network" is used).

If the MAC is set incorrectly, DHCP clients are unable to obtain the
lease properly and station is stuck in "connecting" mode indefinitely.
Fix this by delaying MAC address update until netconfig_configure() is
invoked.

Fixes: ad228461ab ("netconfig: Move loading settings to new method, refactor")
This commit is contained in:
Denis Kenzior 2021-09-27 11:21:40 -05:00
parent 4747df491b
commit 6c0eb76cb7
4 changed files with 12 additions and 14 deletions

View File

@ -1046,6 +1046,7 @@ static void netconfig_ipv4_acd_event(enum l_acd_event event, void *user_data)
static bool netconfig_ipv4_select_and_install(struct netconfig *netconfig) static bool netconfig_ipv4_select_and_install(struct netconfig *netconfig)
{ {
struct netdev *netdev = netdev_find(netconfig->ifindex);
bool set_address = (netconfig->rtm_protocol == RTPROT_STATIC); bool set_address = (netconfig->rtm_protocol == RTPROT_STATIC);
if (netconfig->rtm_protocol == RTPROT_DHCP && if (netconfig->rtm_protocol == RTPROT_DHCP &&
@ -1106,6 +1107,9 @@ static bool netconfig_ipv4_select_and_install(struct netconfig *netconfig)
return true; return true;
} }
l_dhcp_client_set_address(netconfig->dhcp_client, ARPHRD_ETHER,
netdev_get_address(netdev), ETH_ALEN);
if (l_dhcp_client_start(netconfig->dhcp_client)) if (l_dhcp_client_start(netconfig->dhcp_client))
return true; return true;
@ -1162,7 +1166,10 @@ static bool netconfig_ipv6_select_and_install(struct netconfig *netconfig)
return true; return true;
} }
/* DHCP */ /* DHCPv6 or RA, update MAC */
l_dhcp6_client_set_address(netconfig->dhcp6_client, ARPHRD_ETHER,
netdev_get_address(netdev), ETH_ALEN);
return true; return true;
} }
@ -1196,8 +1203,7 @@ static int validate_dns_list(int family, char **dns_list)
} }
bool netconfig_load_settings(struct netconfig *netconfig, bool netconfig_load_settings(struct netconfig *netconfig,
const struct l_settings *active_settings, const struct l_settings *active_settings)
const uint8_t *mac_address)
{ {
char *mdns; char *mdns;
bool send_hostname; bool send_hostname;
@ -1302,11 +1308,6 @@ bool netconfig_load_settings(struct netconfig *netconfig,
resolve_set_mdns(netconfig->resolve, mdns); resolve_set_mdns(netconfig->resolve, mdns);
l_free(mdns); l_free(mdns);
l_dhcp_client_set_address(netconfig->dhcp_client, ARPHRD_ETHER,
mac_address, ETH_ALEN);
l_dhcp6_client_set_address(netconfig->dhcp6_client, ARPHRD_ETHER,
mac_address, ETH_ALEN);
netconfig->active_settings = active_settings; netconfig->active_settings = active_settings;
netconfig->dns4_overrides = dns4_overrides; netconfig->dns4_overrides = dns4_overrides;
netconfig->dns6_overrides = dns6_overrides; netconfig->dns6_overrides = dns6_overrides;

View File

@ -32,8 +32,7 @@ typedef void (*netconfig_notify_func_t)(enum netconfig_event event,
void *user_data); void *user_data);
bool netconfig_load_settings(struct netconfig *netconfig, bool netconfig_load_settings(struct netconfig *netconfig,
const struct l_settings *active_settings, const struct l_settings *active_settings);
const uint8_t *mac_address);
bool netconfig_configure(struct netconfig *netconfig, bool netconfig_configure(struct netconfig *netconfig,
netconfig_notify_func_t notify, netconfig_notify_func_t notify,
void *user_data); void *user_data);

View File

@ -1328,8 +1328,7 @@ static void p2p_start_client_netconfig(struct p2p_device *dev)
settings = dev->conn_netconfig_settings ?: p2p_dhcp_settings; settings = dev->conn_netconfig_settings ?: p2p_dhcp_settings;
if (!netconfig_load_settings(dev->conn_netconfig, settings, if (!netconfig_load_settings(dev->conn_netconfig, settings) ||
dev->conn_addr) ||
!netconfig_configure(dev->conn_netconfig, !netconfig_configure(dev->conn_netconfig,
p2p_netconfig_event_handler, p2p_netconfig_event_handler,
dev)) { dev)) {

View File

@ -2868,8 +2868,7 @@ int __station_connect_network(struct station *station, struct network *network,
if (station->netconfig && !netconfig_load_settings( if (station->netconfig && !netconfig_load_settings(
station->netconfig, station->netconfig,
network_get_settings(network), network_get_settings(network)))
netdev_get_address(station->netdev)))
return -EINVAL; return -EINVAL;
hs = station_handshake_setup(station, network, bss); hs = station_handshake_setup(station, network, bss);