summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-07-12 20:26:02 +0200
committerThomas Haller <thaller@redhat.com>2022-07-19 12:36:57 +0200
commit36e6ac54509596c3d259dd0619142a92b34bf9dc (patch)
treee9e13f84aabd77ceb6bd128fdadc3578abd79690
parentf40dcd65f75a2763c26966d4218b74ce5d79ba0e (diff)
downloadNetworkManager-36e6ac54509596c3d259dd0619142a92b34bf9dc.tar.gz
platform: use new platform API to get genl family id for nl80211/Wi-Fi
-rw-r--r--src/libnm-platform/nm-linux-platform.c9
-rw-r--r--src/libnm-platform/wifi/nm-wifi-utils-nl80211.c20
-rw-r--r--src/libnm-platform/wifi/nm-wifi-utils-nl80211.h2
-rw-r--r--src/libnm-platform/wifi/nm-wifi-utils.c6
-rw-r--r--src/libnm-platform/wifi/nm-wifi-utils.h3
5 files changed, 20 insertions, 20 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c
index 0e6f3c71e2..7dd831eca0 100644
--- a/src/libnm-platform/nm-linux-platform.c
+++ b/src/libnm-platform/nm-linux-platform.c
@@ -3296,10 +3296,11 @@ _new_from_nl_link(NMPlatform *platform,
switch (obj->link.type) {
case NM_LINK_TYPE_WIFI:
case NM_LINK_TYPE_OLPC_MESH:
- obj->_link.ext_data =
- (GObject *) nm_wifi_utils_new(ifi->ifi_index,
- NM_LINUX_PLATFORM_GET_PRIVATE(platform)->sk_genl_sync,
- TRUE);
+ obj->_link.ext_data = (GObject *) nm_wifi_utils_new(
+ NM_LINUX_PLATFORM_GET_PRIVATE(platform)->sk_genl_sync,
+ nm_platform_genl_get_family_id(platform, NMP_GENL_FAMILY_TYPE_NL80211),
+ ifi->ifi_index,
+ TRUE);
break;
case NM_LINK_TYPE_WPAN:
obj->_link.ext_data =
diff --git a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
index 475b8a390a..bd56885ddd 100644
--- a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
+++ b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.c
@@ -46,9 +46,9 @@ typedef struct {
NMWifiUtils parent;
struct nl_sock *nl_sock;
guint32 *freqs;
- int id;
int num_freqs;
int phy;
+ guint16 genl_family_id;
bool can_wowlan : 1;
} NMWifiUtilsNl80211;
@@ -83,12 +83,12 @@ error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
}
static struct nl_msg *
-_nl80211_alloc_msg(int id, int ifindex, int phy, guint32 cmd, guint32 flags)
+_nl80211_alloc_msg(guint16 genl_family_id, int ifindex, int phy, guint32 cmd, guint32 flags)
{
nm_auto_nlmsg struct nl_msg *msg = NULL;
msg = nlmsg_alloc();
- genlmsg_put(msg, 0, 0, id, 0, flags, cmd, 0);
+ genlmsg_put(msg, 0, 0, genl_family_id, 0, flags, cmd, 0);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
if (phy != -1)
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, phy);
@@ -101,7 +101,7 @@ nla_put_failure:
static struct nl_msg *
nl80211_alloc_msg(NMWifiUtilsNl80211 *self, guint32 cmd, guint32 flags)
{
- return _nl80211_alloc_msg(self->id, self->parent.ifindex, self->phy, cmd, flags);
+ return _nl80211_alloc_msg(self->genl_family_id, self->parent.ifindex, self->phy, cmd, flags);
}
static int
@@ -945,7 +945,7 @@ nm_wifi_utils_nl80211_class_init(NMWifiUtilsNl80211Class *klass)
}
NMWifiUtils *
-nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl)
+nm_wifi_utils_nl80211_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex)
{
gs_unref_object NMWifiUtilsNl80211 *self = NULL;
nm_auto_nlmsg struct nl_msg *msg = NULL;
@@ -954,16 +954,14 @@ nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl)
if (!genl)
return NULL;
+ if (genl_family_id == 0)
+ return NULL;
+
self = g_object_new(NM_TYPE_WIFI_UTILS_NL80211, NULL);
self->parent.ifindex = ifindex;
self->nl_sock = genl;
-
- self->id = genl_ctrl_resolve(self->nl_sock, "nl80211");
- if (self->id < 0) {
- _LOGD("genl_ctrl_resolve: failed to resolve \"nl80211\"");
- return NULL;
- }
+ self->genl_family_id = genl_family_id;
self->phy = -1;
diff --git a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.h b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.h
index 4a63330739..4783c572b4 100644
--- a/src/libnm-platform/wifi/nm-wifi-utils-nl80211.h
+++ b/src/libnm-platform/wifi/nm-wifi-utils-nl80211.h
@@ -24,6 +24,6 @@
GType nm_wifi_utils_nl80211_get_type(void);
-NMWifiUtils *nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl);
+NMWifiUtils *nm_wifi_utils_nl80211_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex);
#endif /* __WIFI_UTILS_NL80211_H__ */
diff --git a/src/libnm-platform/wifi/nm-wifi-utils.c b/src/libnm-platform/wifi/nm-wifi-utils.c
index 08a8ec4ff3..0238b74aa9 100644
--- a/src/libnm-platform/wifi/nm-wifi-utils.c
+++ b/src/libnm-platform/wifi/nm-wifi-utils.c
@@ -32,16 +32,16 @@ nm_wifi_utils_class_init(NMWifiUtilsClass *klass)
{}
NMWifiUtils *
-nm_wifi_utils_new(int ifindex, struct nl_sock *genl, gboolean check_scan)
+nm_wifi_utils_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex, gboolean check_scan)
{
NMWifiUtils *ret;
g_return_val_if_fail(ifindex > 0, NULL);
- ret = nm_wifi_utils_nl80211_new(ifindex, genl);
+ ret = nm_wifi_utils_nl80211_new(genl, genl_family_id, ifindex);
#if HAVE_WEXT
- if (ret == NULL)
+ if (!ret)
ret = nm_wifi_utils_wext_new(ifindex, check_scan);
#endif
diff --git a/src/libnm-platform/wifi/nm-wifi-utils.h b/src/libnm-platform/wifi/nm-wifi-utils.h
index 0d30c1a119..4dbeb21ff3 100644
--- a/src/libnm-platform/wifi/nm-wifi-utils.h
+++ b/src/libnm-platform/wifi/nm-wifi-utils.h
@@ -27,7 +27,8 @@ GType nm_wifi_utils_get_type(void);
gboolean nm_wifi_utils_is_wifi(int dirfd, const char *ifname);
-NMWifiUtils *nm_wifi_utils_new(int ifindex, struct nl_sock *genl, gboolean check_scan);
+NMWifiUtils *
+nm_wifi_utils_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex, gboolean check_scan);
_NMDeviceWifiCapabilities nm_wifi_utils_get_caps(NMWifiUtils *data);