platform: expose GUdevDevice instance for platform links
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
#include "nm-connection-provider.h"
|
#include "nm-connection-provider.h"
|
||||||
#include "nm-device-factory.h"
|
#include "nm-device-factory.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
#include "NetworkManagerUtils.h"
|
||||||
|
|
||||||
#include "nm-device-ethernet-glue.h"
|
#include "nm-device-ethernet-glue.h"
|
||||||
|
|
||||||
@@ -151,28 +152,21 @@ static void
|
|||||||
_update_s390_subchannels (NMDeviceEthernet *self)
|
_update_s390_subchannels (NMDeviceEthernet *self)
|
||||||
{
|
{
|
||||||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||||
GUdevClient *client;
|
|
||||||
GUdevDevice *dev;
|
GUdevDevice *dev;
|
||||||
GUdevDevice *parent = NULL;
|
GUdevDevice *parent = NULL;
|
||||||
const char *parent_path, *item, *driver;
|
const char *parent_path, *item, *driver;
|
||||||
const char *subsystems[] = { "net", NULL };
|
int ifindex;
|
||||||
const char *iface;
|
|
||||||
GDir *dir;
|
GDir *dir;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
client = g_udev_client_new (subsystems);
|
ifindex = nm_device_get_ifindex (NM_DEVICE (self));
|
||||||
if (!client) {
|
dev = (GUdevDevice *) nm_platform_link_get_udev_device (NM_PLATFORM_GET, ifindex);
|
||||||
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to initialize GUdev client");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
dev = iface ? g_udev_client_query_by_subsystem_and_name (client, "net", iface) : NULL;
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to find device '%s' with udev",
|
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to find device %d '%s' with udev",
|
||||||
iface ? iface : "(null)");
|
ifindex, str_if_set (nm_device_get_iface (NM_DEVICE (self)), "(null)"));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
g_object_ref (dev);
|
||||||
|
|
||||||
/* Try for the "ccwgroup" parent */
|
/* Try for the "ccwgroup" parent */
|
||||||
parent = g_udev_device_get_parent_with_subsystem (dev, "ccwgroup", NULL);
|
parent = g_udev_device_get_parent_with_subsystem (dev, "ccwgroup", NULL);
|
||||||
@@ -244,7 +238,6 @@ out:
|
|||||||
g_object_unref (parent);
|
g_object_unref (parent);
|
||||||
if (dev)
|
if (dev)
|
||||||
g_object_unref (dev);
|
g_object_unref (dev);
|
||||||
g_object_unref (client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GObject*
|
static GObject*
|
||||||
|
@@ -2969,6 +2969,20 @@ link_get_udi (NMPlatform *platform, int ifindex)
|
|||||||
return g_udev_device_get_sysfs_path (obj->_link.udev.device);
|
return g_udev_device_get_sysfs_path (obj->_link.udev.device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
link_get_udev_device (NMPlatform *platform, int ifindex)
|
||||||
|
{
|
||||||
|
const NMPObject *obj_cache;
|
||||||
|
|
||||||
|
/* we don't use cache_lookup_link() because this would return NULL
|
||||||
|
* if the link is not visible in libnl. For link_get_udev_device()
|
||||||
|
* we want to return whatever we have, even if the link itself
|
||||||
|
* appears invisible via other platform functions. */
|
||||||
|
|
||||||
|
obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex);
|
||||||
|
return obj_cache ? (GObject *) obj_cache->_link.udev.device : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_get_user_ipv6ll_enabled (NMPlatform *platform, int ifindex)
|
link_get_user_ipv6ll_enabled (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
@@ -4999,6 +5013,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||||||
platform_class->link_uses_arp = link_uses_arp;
|
platform_class->link_uses_arp = link_uses_arp;
|
||||||
|
|
||||||
platform_class->link_get_udi = link_get_udi;
|
platform_class->link_get_udi = link_get_udi;
|
||||||
|
platform_class->link_get_udev_device = link_get_udev_device;
|
||||||
platform_class->link_get_ipv6_token = link_get_ipv6_token;
|
platform_class->link_get_ipv6_token = link_get_ipv6_token;
|
||||||
|
|
||||||
platform_class->link_get_user_ipv6ll_enabled = link_get_user_ipv6ll_enabled;
|
platform_class->link_get_user_ipv6ll_enabled = link_get_user_ipv6ll_enabled;
|
||||||
|
@@ -928,6 +928,19 @@ nm_platform_link_get_udi (NMPlatform *self, int ifindex)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GObject *
|
||||||
|
nm_platform_link_get_udev_device (NMPlatform *self, int ifindex)
|
||||||
|
{
|
||||||
|
_CHECK_SELF (self, klass, FALSE);
|
||||||
|
reset_error (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (ifindex >= 0, NULL);
|
||||||
|
|
||||||
|
if (klass->link_get_udev_device)
|
||||||
|
return klass->link_get_udev_device (self, ifindex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_platform_link_get_user_ip6vll_enabled:
|
* nm_platform_link_get_user_ip6vll_enabled:
|
||||||
* @self: platform instance
|
* @self: platform instance
|
||||||
|
@@ -433,6 +433,7 @@ typedef struct {
|
|||||||
gboolean (*link_uses_arp) (NMPlatform *, int ifindex);
|
gboolean (*link_uses_arp) (NMPlatform *, int ifindex);
|
||||||
|
|
||||||
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
||||||
|
GObject *(*link_get_udev_device) (NMPlatform *self, int ifindex);
|
||||||
gboolean (*link_get_ipv6_token) (NMPlatform *, int ifindex, NMUtilsIPv6IfaceId *iid);
|
gboolean (*link_get_ipv6_token) (NMPlatform *, int ifindex, NMUtilsIPv6IfaceId *iid);
|
||||||
|
|
||||||
gboolean (*link_get_user_ipv6ll_enabled) (NMPlatform *, int ifindex);
|
gboolean (*link_get_user_ipv6ll_enabled) (NMPlatform *, int ifindex);
|
||||||
@@ -624,6 +625,8 @@ gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex);
|
|||||||
gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid);
|
gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid);
|
||||||
const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
|
const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
|
GObject *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
|
gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
|
||||||
gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user