Don't bring up uninitialized devices (fd #56929)

This commit is contained in:
Daniel Drake 2012-11-27 06:27:15 -06:00
parent d1e13ca88f
commit 2f2cea1765
2 changed files with 72 additions and 1 deletions

View File

@ -19,7 +19,7 @@ Name: NetworkManager
Summary: Network connection manager and user applications
Epoch: 1
Version: 0.9.7.0
Release: 6%{snapshot}%{?dist}
Release: 7%{snapshot}%{?dist}
Group: System Environment/Base
License: GPLv2+
URL: http://www.gnome.org/projects/NetworkManager/
@ -30,6 +30,7 @@ Patch1: explain-dns1-dns2.patch
Patch2: nss-error.patch
Patch3: finish-connecting.patch
Patch4: gvaluearray-crash.patch
Patch5: udev-uninitialized-devices.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires(post): chkconfig
@ -155,6 +156,7 @@ NetworkManager functionality from applications that use glib.
%patch2 -p1 -b .nss-error
%patch3 -p1 -b .finish-connecting
%patch4 -p1 -b .gvaluearray
%patch5 -p1 -b .udev-uninitialized
%build
@ -352,6 +354,9 @@ exit 0
%{_datadir}/gtk-doc/html/libnm-util/*
%changelog
* Tue Nov 27 2012 Daniel Drake <dsd@laptop.org> - 0.9.7.0-7.git20121004
- Don't bring up uninitialized devices (fd #56929)
* Mon Oct 15 2012 Dan Winship <danw@redhat.com> - 0.9.7.0-6.git20121004
- Actually apply the patch from the previous commit...

View File

@ -0,0 +1,66 @@
From 2e767e2399f5049b8bb5e7d9a02c78bdb962bb26 Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Mon, 26 Nov 2012 13:09:35 -0600
Subject: [PATCH] core: don't activate uninitialized devices from udev
libgudev's device matching here by default can return devices which
udev has not yet finished initializing.
This was frequently causing boot-time races on the OLPC XO, where
NetworkManager would bring a device up before udev had renamed it,
causing the later rename to fail.
To solve this, filter the enumeration matches to only include
initialized devices. The devices that are present but uninitialized
at this time will arrive a short time later, via a uevent.
https://bugs.freedesktop.org/show_bug.cgi?id=56929
---
src/nm-udev-manager.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/nm-udev-manager.c b/src/nm-udev-manager.c
index 792e53b..60f41aa 100644
--- a/src/nm-udev-manager.c
+++ b/src/nm-udev-manager.c
@@ -515,25 +515,35 @@ void
nm_udev_manager_query_devices (NMUdevManager *self)
{
NMUdevManagerPrivate *priv = NM_UDEV_MANAGER_GET_PRIVATE (self);
+ GUdevEnumerator *enumerator;
GList *devices, *iter;
g_return_if_fail (self != NULL);
g_return_if_fail (NM_IS_UDEV_MANAGER (self));
- devices = g_udev_client_query_by_subsystem (priv->client, "net");
+ enumerator = g_udev_enumerator_new (priv->client);
+ g_udev_enumerator_add_match_subsystem (enumerator, "net");
+ g_udev_enumerator_add_match_is_initialized (enumerator);
+
+ devices = g_udev_enumerator_execute (enumerator);
for (iter = devices; iter; iter = g_list_next (iter)) {
net_add (self, G_UDEV_DEVICE (iter->data));
g_object_unref (G_UDEV_DEVICE (iter->data));
}
g_list_free (devices);
+ g_object_unref (enumerator);
- devices = g_udev_client_query_by_subsystem (priv->client, "atm");
+ enumerator = g_udev_enumerator_new (priv->client);
+ g_udev_enumerator_add_match_subsystem (enumerator, "atm");
+ g_udev_enumerator_add_match_is_initialized (enumerator);
+ devices = g_udev_enumerator_execute (enumerator);
for (iter = devices; iter; iter = g_list_next (iter)) {
adsl_add (self, G_UDEV_DEVICE (iter->data));
g_object_unref (G_UDEV_DEVICE (iter->data));
}
g_list_free (devices);
+ g_object_unref (enumerator);
}
static void
--
1.7.11.7