platform: merge setup_devices() function into constructed()
We already populate the netlink cache in constructed(). No need to wait with udev devices until nm_platform_query_devices(). Just do it right away. Add a hack to keep 'lo' default-unmanaged. Now that we load udev devices earlier, we end up clearing the default-unmanged flag on 'lo', which has bad consequences.
This commit is contained in:
@@ -1109,7 +1109,14 @@ nm_device_finish_init (NMDevice *self)
|
||||
nm_device_enslave_slave (priv->master, self, NULL);
|
||||
|
||||
if (priv->ifindex > 0) {
|
||||
if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) {
|
||||
if (priv->ifindex == 1) {
|
||||
/* keep 'lo' as default-unmanaged. */
|
||||
|
||||
/* FIXME: either find a better way to unmange 'lo' that cannot be changed
|
||||
* by user configuration (NM_UNMANGED_LOOPBACK?) or fix managing 'lo'.
|
||||
* Currently it can happen that NM deletes 127.0.0.1 address. */
|
||||
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, TRUE);
|
||||
} else if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) {
|
||||
nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged);
|
||||
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, platform_unmanaged);
|
||||
} else {
|
||||
|
@@ -4774,6 +4774,8 @@ constructed (GObject *_object)
|
||||
int channel_flags;
|
||||
gboolean status;
|
||||
int nle;
|
||||
GUdevEnumerator *enumerator;
|
||||
GList *devices, *iter;
|
||||
|
||||
/* Initialize netlink socket for requests */
|
||||
priv->nlh = setup_socket (FALSE, platform);
|
||||
@@ -4838,16 +4840,6 @@ constructed (GObject *_object)
|
||||
|
||||
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
||||
|
||||
G_OBJECT_CLASS (nm_linux_platform_parent_class)->constructed (_object);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_devices (NMPlatform *platform)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
GUdevEnumerator *enumerator;
|
||||
GList *devices, *iter;
|
||||
|
||||
/* And read initial device list */
|
||||
enumerator = g_udev_enumerator_new (priv->udev_client);
|
||||
g_udev_enumerator_add_match_subsystem (enumerator, "net");
|
||||
@@ -4861,6 +4853,8 @@ setup_devices (NMPlatform *platform)
|
||||
}
|
||||
g_list_free (devices);
|
||||
g_object_unref (enumerator);
|
||||
|
||||
G_OBJECT_CLASS (nm_linux_platform_parent_class)->constructed (_object);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4898,8 +4892,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
||||
object_class->constructed = constructed;
|
||||
object_class->finalize = nm_linux_platform_finalize;
|
||||
|
||||
platform_class->setup_devices = setup_devices;
|
||||
|
||||
platform_class->sysctl_set = sysctl_set;
|
||||
platform_class->sysctl_get = sysctl_get;
|
||||
|
||||
|
@@ -405,10 +405,6 @@ nm_platform_query_devices (NMPlatform *self)
|
||||
NM_PLATFORM_REASON_INTERNAL);
|
||||
}
|
||||
g_array_unref (links_array);
|
||||
|
||||
/* Platform specific device setup. */
|
||||
if (klass->setup_devices)
|
||||
klass->setup_devices (self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -368,8 +368,6 @@ struct _NMPlatform {
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
||||
void (*setup_devices) (NMPlatform *);
|
||||
|
||||
gboolean (*sysctl_set) (NMPlatform *, const char *path, const char *value);
|
||||
char * (*sysctl_get) (NMPlatform *, const char *path);
|
||||
|
||||
|
Reference in New Issue
Block a user