platform: don't wait for udev device initializaton if there's no udev
There's no udev running in containers, it only starts if /sys is writable. If a hardware device is added to the container's namespace NM would not announce it. This also removes the software link special case -- the software links will now wait for udev initialization (in case udev is there) as well. There's no reason to treat them differently anymore. This makes it possible to use udev properties of the software links. https://bugzilla.gnome.org/show_bug.cgi?id=740526
This commit is contained in:
@@ -780,41 +780,6 @@ link_type_from_udev (NMPlatform *platform, int ifindex, const char *ifname, int
|
||||
return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_is_software (struct rtnl_link *rtnllink)
|
||||
{
|
||||
const char *type;
|
||||
|
||||
/* FIXME: replace somehow with NMLinkType or nm_platform_is_software(), but
|
||||
* solve the infinite callstack problems that getting the type of a TUN/TAP
|
||||
* device causes.
|
||||
*/
|
||||
|
||||
if ( rtnl_link_get_arptype (rtnllink) == ARPHRD_INFINIBAND
|
||||
&& strchr (rtnl_link_get_name (rtnllink), '.'))
|
||||
return TRUE;
|
||||
|
||||
type = rtnl_link_get_type (rtnllink);
|
||||
if (type == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!strcmp (type, "dummy") ||
|
||||
!strcmp (type, "gre") ||
|
||||
!strcmp (type, "gretap") ||
|
||||
!strcmp (type, "macvlan") ||
|
||||
!strcmp (type, "macvtap") ||
|
||||
!strcmp (type, "tun") ||
|
||||
!strcmp (type, "veth") ||
|
||||
!strcmp (type, "vlan") ||
|
||||
!strcmp (type, "vxlan") ||
|
||||
!strcmp (type, "bridge") ||
|
||||
!strcmp (type, "bond") ||
|
||||
!strcmp (type, "team"))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
ethtool_get_driver (const char *ifname)
|
||||
{
|
||||
@@ -837,10 +802,6 @@ link_is_announceable (NMPlatform *platform, struct rtnl_link *rtnllink)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
|
||||
/* Software devices are always visible outside the platform */
|
||||
if (link_is_software (rtnllink))
|
||||
return TRUE;
|
||||
|
||||
/* Hardware devices must be found by udev so rules get run and tags set */
|
||||
if (g_hash_table_lookup (priv->udev_devices,
|
||||
GINT_TO_POINTER (rtnl_link_get_ifindex (rtnllink))))
|
||||
@@ -1587,7 +1548,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
|
||||
if (!init_link (platform, &device, rtnl_link))
|
||||
return;
|
||||
|
||||
/* Skip hardware devices not yet discovered by udev. They will be
|
||||
/* Skip devices not yet discovered by udev. They will be
|
||||
* announced by udev_device_added(). This doesn't apply to removed
|
||||
* devices, as those come either from udev_device_removed(),
|
||||
* event_notification() or link_delete() which block the announcment
|
||||
@@ -1596,7 +1557,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
|
||||
switch (change_type) {
|
||||
case NM_PLATFORM_SIGNAL_ADDED:
|
||||
case NM_PLATFORM_SIGNAL_CHANGED:
|
||||
if (!link_is_software (rtnl_link) && !device.driver)
|
||||
if (!device.driver)
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
@@ -4537,7 +4498,12 @@ setup (NMPlatform *platform)
|
||||
/* And read initial device list */
|
||||
enumerator = g_udev_enumerator_new (priv->udev_client);
|
||||
g_udev_enumerator_add_match_subsystem (enumerator, "net");
|
||||
g_udev_enumerator_add_match_is_initialized (enumerator);
|
||||
|
||||
/* Demand that the device is initialized (udev rules ran,
|
||||
* device has a stable name now) in case udev is running
|
||||
* (not in a container). */
|
||||
if (access ("/sys", W_OK) == 0)
|
||||
g_udev_enumerator_add_match_is_initialized (enumerator);
|
||||
|
||||
devices = g_udev_enumerator_execute (enumerator);
|
||||
for (iter = devices; iter; iter = g_list_next (iter)) {
|
||||
|
Reference in New Issue
Block a user