mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 16:40:16 +01:00
wifi: make sure we're connected to netlink before using it
This should fix the warning "failed to allocate link cache" when a new device is added. It doesn't affect WiFi operation, and the code would fall back to non-nl80211 mechanisms of detecting whether a device was wifi or not, so it corrects this check and quiets the error message.
This commit is contained in:
parent
1da9738f1b
commit
ce6b667a68
1 changed files with 6 additions and 5 deletions
|
|
@ -754,13 +754,14 @@ error:
|
|||
static int
|
||||
iface_to_index (struct nl_sock *nl_sock, const char *iface)
|
||||
{
|
||||
struct nl_cache *link_cache;
|
||||
struct nl_cache *link_cache = NULL;
|
||||
int err, ifindex;
|
||||
|
||||
/* name to index */
|
||||
err = rtnl_link_alloc_cache (nl_sock, &link_cache);
|
||||
if (err < 0) {
|
||||
nm_log_warn (LOGD_HW, "failed to allocate link cache");
|
||||
nm_log_warn (LOGD_HW, "failed to allocate link cache: (%d) %s",
|
||||
err, nl_geterror (err));
|
||||
return -1;
|
||||
}
|
||||
nl_cache_mngt_provide (link_cache);
|
||||
|
|
@ -787,11 +788,11 @@ wifi_nl80211_is_wifi (const char *iface)
|
|||
if (nl_sock == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (genl_connect (nl_sock))
|
||||
goto error;
|
||||
|
||||
ifindex = iface_to_index (nl_sock, iface);
|
||||
if (ifindex < 0)
|
||||
return FALSE;
|
||||
|
||||
if (genl_connect (nl_sock))
|
||||
goto error;
|
||||
|
||||
id = genl_ctrl_resolve (nl_sock, "nl80211");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue