summaryrefslogtreecommitdiff
path: root/src/devices/nm-device-vlan.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-09-24 16:58:07 -0500
committerThomas Haller <thaller@redhat.com>2015-12-04 12:16:40 +0100
commit4dbaac4ba24ebc8b257fffe5197cc8e362804a58 (patch)
treeda91c97f54716e167e7a094f7fa872cb12b0f4e4 /src/devices/nm-device-vlan.c
parentb7eb622c247656595a04aa6a32ef17ba4cf15a2a (diff)
downloadNetworkManager-4dbaac4ba24ebc8b257fffe5197cc8e362804a58.tar.gz
core: create devices first and realize them later
Unrealized devices aren't backed by kernel resources and so won't know all of their attributes. That means three things: 1) they must update their attributes when they become realized 2) they must clear those attributes when unrealized 3) they must be looser in checking compatible connections until they are realized This requires that the setup() function be split into two parts, start & finish, because finish must be run after add_device() Also, we can simplify whether to pay attention to 'recheck-assume', which is now dependent on priv->is_nm_owned, because the only case where NM should *not* listen for the 'recheck-assume' signal is when the device is a software device created by NM itself. That logic was previously spread across the callers of add_device() but is now consolidated into nm-manager.c::device_realized() and nm-device.c::nm_device_create_and_realize().
Diffstat (limited to 'src/devices/nm-device-vlan.c')
-rw-r--r--src/devices/nm-device-vlan.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 0f7b0d9f80..58263c5d0c 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -148,12 +148,12 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent)
}
static void
-setup (NMDevice *device, NMPlatformLink *plink)
+setup_start (NMDevice *device, NMPlatformLink *plink)
{
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
- NM_DEVICE_CLASS (nm_device_vlan_parent_class)->setup (device, plink);
+ NM_DEVICE_CLASS (nm_device_vlan_parent_class)->setup_start (device, plink);
_LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s",
priv->vlan_id, nm_device_get_iface (priv->parent));
@@ -311,6 +311,9 @@ notify_new_device_added (NMDevice *device, NMDevice *new_device)
if (priv->parent)
return;
+ if (!nm_device_is_real (device))
+ return;
+
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink);
if (!plnk) {
_LOGW (LOGD_VLAN, "failed to get VLAN interface info while checking added component.");
@@ -397,18 +400,21 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
if (!s_vlan)
return FALSE;
- if (nm_setting_vlan_get_id (s_vlan) != priv->vlan_id)
- return FALSE;
-
- /* Check parent interface; could be an interface name or a UUID */
- parent = nm_setting_vlan_get_parent (s_vlan);
- if (parent) {
- if (!match_parent (NM_DEVICE_VLAN (device), parent))
- return FALSE;
- } else {
- /* Parent could be a MAC address in an NMSettingWired */
- if (!match_hwaddr (device, connection, TRUE))
+ /* Before the device is realized some properties will not be set */
+ if (nm_device_is_real (device)) {
+ if (nm_setting_vlan_get_id (s_vlan) != priv->vlan_id)
return FALSE;
+
+ /* Check parent interface; could be an interface name or a UUID */
+ parent = nm_setting_vlan_get_parent (s_vlan);
+ if (parent) {
+ if (!match_parent (NM_DEVICE_VLAN (device), parent))
+ return FALSE;
+ } else {
+ /* Parent could be a MAC address in an NMSettingWired */
+ if (!match_hwaddr (device, connection, TRUE))
+ return FALSE;
+ }
}
/* Ensure the interface name matches. If not specified we assume a match
@@ -672,7 +678,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
parent_class->create_and_realize = create_and_realize;
parent_class->realize = realize;
- parent_class->setup = setup;
+ parent_class->setup_start = setup_start;
parent_class->unrealize = unrealize;
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->bring_up = bring_up;