summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-06-29 10:51:38 +0200
committerThomas Haller <thaller@redhat.com>2017-07-05 18:37:39 +0200
commit485551286c3a7e457972cc4445f4fdf0446d64a8 (patch)
tree9d46b6e8c8daaaf83c932b89b6c264e08e3b4567
parent55e66cc7e617345a39c9a9f929ce12f3f377e6b7 (diff)
downloadNetworkManager-485551286c3a7e457972cc4445f4fdf0446d64a8.tar.gz
platform: add use-udev property for NMPlatform
We want to move the multi_idx from NMLinuxPlatform to NMPlatform, so that it can be used by NMFakePlatform as well. For that, we need to know whether NMPlatform will use udev or not. Add a constrctor property.
-rw-r--r--src/platform/nm-linux-platform.c18
-rw-r--r--src/platform/nm-platform.c20
-rw-r--r--src/platform/nm-platform.h2
3 files changed, 34 insertions, 6 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 6edf38baa9..fe08b985e9 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2619,8 +2619,15 @@ G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
NMPlatform *
nm_linux_platform_new (gboolean log_with_ptr, gboolean netns_support)
{
+ gboolean use_udev = FALSE;
+
+ if ( nmp_netns_is_initial ()
+ && access ("/sys", W_OK) == 0)
+ use_udev = TRUE;
+
return g_object_new (NM_TYPE_LINUX_PLATFORM,
NM_PLATFORM_LOG_WITH_PTR, log_with_ptr,
+ NM_PLATFORM_USE_UDEV, use_udev,
NM_PLATFORM_NETNS_SUPPORT, netns_support,
NULL);
}
@@ -6723,12 +6730,6 @@ nm_linux_platform_init (NMLinuxPlatform *self)
priv->delayed_action.list_refresh_link = g_ptr_array_new ();
priv->delayed_action.list_wait_for_nl_response = g_array_new (FALSE, TRUE, sizeof (DelayedActionWaitForNlResponseData));
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
-
- if ( nmp_netns_is_initial ()
- && access ("/sys", W_OK) == 0) {
- priv->udev_client = nm_udev_client_new ((const char *[]) { "net", NULL },
- handle_udev_event, self);
- }
}
static void
@@ -6742,6 +6743,11 @@ constructed (GObject *_object)
nm_assert (!platform->_netns || platform->_netns == nmp_netns_get_current ());
+ if (nm_platform_get_use_udev (platform)) {
+ priv->udev_client = nm_udev_client_new ((const char *[]) { "net", NULL },
+ handle_udev_event, platform);
+ }
+
priv->cache = nmp_cache_new (nm_platform_get_multi_idx (platform),
priv->udev_client != NULL);
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index e1fa923bb4..661cb40fa2 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -80,11 +80,13 @@ static guint signals[_NM_PLATFORM_SIGNAL_ID_LAST] = { 0 };
enum {
PROP_0,
PROP_NETNS_SUPPORT,
+ PROP_USE_UDEV,
PROP_LOG_WITH_PTR,
LAST_PROP,
};
typedef struct _NMPlatformPrivate {
+ bool use_udev:1;
bool log_with_ptr:1;
NMDedupMultiIndex *multi_idx;
} NMPlatformPrivate;
@@ -96,6 +98,12 @@ G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT)
/*****************************************************************************/
gboolean
+nm_platform_get_use_udev (NMPlatform *self)
+{
+ return NM_PLATFORM_GET_PRIVATE (self)->use_udev;
+}
+
+gboolean
nm_platform_get_log_with_ptr (NMPlatform *self)
{
return NM_PLATFORM_GET_PRIVATE (self)->log_with_ptr;
@@ -4929,6 +4937,10 @@ set_property (GObject *object, guint prop_id,
self->_netns = g_object_ref (netns);
}
break;
+ case PROP_USE_UDEV:
+ /* construct-only */
+ priv->use_udev = g_value_get_boolean (value);
+ break;
case PROP_LOG_WITH_PTR:
/* construct-only */
priv->log_with_ptr = g_value_get_boolean (value);
@@ -4977,6 +4989,14 @@ nm_platform_class_init (NMPlatformClass *platform_class)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property
+ (object_class, PROP_USE_UDEV,
+ g_param_spec_boolean (NM_PLATFORM_USE_UDEV, "", "",
+ FALSE,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property
(object_class, PROP_LOG_WITH_PTR,
g_param_spec_boolean (NM_PLATFORM_LOG_WITH_PTR, "", "",
TRUE,
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 9a38298030..b9ddc239b6 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -45,6 +45,7 @@
/*****************************************************************************/
#define NM_PLATFORM_NETNS_SUPPORT "netns-support"
+#define NM_PLATFORM_USE_UDEV "use-udev"
#define NM_PLATFORM_LOG_WITH_PTR "log-with-ptr"
/*****************************************************************************/
@@ -726,6 +727,7 @@ _nm_platform_uint8_inv (guint8 scope)
return (guint8) ~scope;
}
+gboolean nm_platform_get_use_udev (NMPlatform *self);
gboolean nm_platform_get_log_with_ptr (NMPlatform *self);
NMPNetns *nm_platform_netns_get (NMPlatform *self);