summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-01-08 17:24:24 +0100
committerThomas Haller <thaller@redhat.com>2016-01-11 14:05:49 +0100
commit4c6b991bb04210d98878e2b0fb106deb3dfbb865 (patch)
tree2e42900dbd4597db2ec6f3bb9eff2b291f574843
parent0311a0eae3a5f3449e5ab7806206abb728480503 (diff)
downloadNetworkManager-4c6b991bb04210d98878e2b0fb106deb3dfbb865.tar.gz
device: move implementation of NMDevice:setup_start() to realize_start_setup()
All implementations of NMDevice:setup_start() in derived classes invoke the parent implementation first. Enforce that by moving NMDevice:setup_start() to realize_start_setup() and only notify derived classes afterwards via NMDevice:realize_start_notify().
-rw-r--r--src/devices/nm-device-ethernet.c6
-rw-r--r--src/devices/nm-device-generic.c6
-rw-r--r--src/devices/nm-device-ip-tunnel.c6
-rw-r--r--src/devices/nm-device-macvlan.c6
-rw-r--r--src/devices/nm-device-tun.c6
-rw-r--r--src/devices/nm-device-vlan.c6
-rw-r--r--src/devices/nm-device-vxlan.c6
-rw-r--r--src/devices/nm-device.c48
-rw-r--r--src/devices/nm-device.h11
-rw-r--r--src/devices/wifi/nm-device-wifi.c6
10 files changed, 62 insertions, 45 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index e341cc730a..b99f0671f5 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -305,9 +305,9 @@ nm_device_ethernet_init (NMDeviceEthernet *self)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
- NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->realize_start_notify (device, plink);
g_object_notify (G_OBJECT (device), NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
}
@@ -1731,7 +1731,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
object_class->set_property = set_property;
parent_class->get_generic_capabilities = get_generic_capabilities;
- parent_class->setup_start = setup_start;
+ parent_class->realize_start_notify = realize_start_notify;
parent_class->check_connection_compatible = check_connection_compatible;
parent_class->complete_connection = complete_connection;
parent_class->new_default_connection = new_default_connection;
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c
index b6fe16be65..b05bdb1cc5 100644
--- a/src/devices/nm-device-generic.c
+++ b/src/devices/nm-device-generic.c
@@ -61,13 +61,13 @@ get_type_description (NMDevice *device)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
NMDeviceGeneric *self = NM_DEVICE_GENERIC (device);
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self);
int ifindex;
- NM_DEVICE_CLASS (nm_device_generic_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_generic_parent_class)->realize_start_notify (device, plink);
g_clear_pointer (&priv->type_description, g_free);
ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self));
@@ -203,7 +203,7 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
object_class->get_property = get_property;
object_class->set_property = set_property;
- parent_class->setup_start = setup_start;
+ parent_class->realize_start_notify = realize_start_notify;
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->get_type_description = get_type_description;
parent_class->check_connection_compatible = check_connection_compatible;
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index 2fa6bee19d..8fff4dfb9c 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -771,9 +771,9 @@ create_and_realize (NMDevice *device,
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
- NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink);
update_properties (device);
}
@@ -886,7 +886,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
device_class->create_and_realize = create_and_realize;
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
device_class->realize = realize;
- device_class->setup_start = setup_start;
+ device_class->realize_start_notify = realize_start_notify;
device_class->unrealize = unrealize;
NM_DEVICE_CLASS_DECLARE_TYPES (klass,
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index 907d480b2d..fb6a50b97b 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -558,9 +558,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
- NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->realize_start_notify (device, plink);
update_properties (device);
}
@@ -653,7 +653,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
device_class->link_changed = link_changed;
device_class->notify_new_device_added = notify_new_device_added;
device_class->realize = realize;
- device_class->setup_start = setup_start;
+ device_class->realize_start_notify = realize_start_notify;
device_class->update_connection = update_connection;
/* properties */
diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c
index e1ec520363..5f150522df 100644
--- a/src/devices/nm-device-tun.c
+++ b/src/devices/nm-device-tun.c
@@ -242,9 +242,9 @@ realize (NMDevice *device, NMPlatformLink *plink, GError **error)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
- NM_DEVICE_CLASS (nm_device_tun_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_tun_parent_class)->realize_start_notify (device, plink);
reload_tun_properties (device);
}
@@ -447,7 +447,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
device_class->check_connection_compatible = check_connection_compatible;
device_class->create_and_realize = create_and_realize;
device_class->realize = realize;
- device_class->setup_start = setup_start;
+ device_class->realize_start_notify = realize_start_notify;
device_class->unrealize = unrealize;
device_class->update_connection = update_connection;
device_class->act_stage1_prepare = act_stage1_prepare;
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 5ccddbde38..47047b1999 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -152,12 +152,12 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const 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_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink);
_LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s",
priv->vlan_id, nm_device_get_iface (priv->parent));
@@ -692,7 +692,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
parent_class->create_and_realize = create_and_realize;
parent_class->realize = realize;
- parent_class->setup_start = setup_start;
+ parent_class->realize_start_notify = realize_start_notify;
parent_class->unrealize = unrealize;
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->bring_up = bring_up;
diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c
index a2dfa7d91a..01e93ba975 100644
--- a/src/devices/nm-device-vxlan.c
+++ b/src/devices/nm-device-vxlan.c
@@ -145,11 +145,11 @@ link_changed (NMDevice *device, NMPlatformLink *info)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
g_assert (plink->type == NM_LINK_TYPE_VXLAN);
- NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->realize_start_notify (device, plink);
update_properties (device);
}
@@ -666,7 +666,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
object_class->dispose = dispose;
device_class->link_changed = link_changed;
- device_class->setup_start = setup_start;
+ device_class->realize_start_notify = realize_start_notify;
device_class->unrealize = unrealize;
device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME;
device_class->create_and_realize = create_and_realize;
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index a1f81bd170..a7357c5486 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1840,15 +1840,41 @@ check_carrier (NMDevice *self)
}
static void
-setup_start (NMDevice *self, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *self, const NMPlatformLink *plink)
{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ /* Stub implementation for realize_start_notify(). It does nothing,
+ * but allows derived classes to uniformly invoke the parent
+ * implementation. */
+}
+
+/**
+ * realize_start_setup():
+ * @self: the #NMDevice
+ * @plink: the #NMPlatformLink if backed by a kernel netdevice
+ *
+ * Update the device from backing resource properties (like hardware
+ * addresses, carrier states, driver/firmware info, etc). This function
+ * should only change properties for this device, and should not perform
+ * any tasks that affect other interfaces (like master/slave or parent/child
+ * stuff).
+ */
+static void
+realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
+{
+ NMDevicePrivate *priv;
+ NMDeviceClass *klass;
static guint32 id = 0;
+ g_return_if_fail (NM_IS_DEVICE (self));
+
+ priv = NM_DEVICE_GET_PRIVATE (self);
+
/* The device should not be realized */
g_return_if_fail (priv->ip_ifindex <= 0);
g_return_if_fail (priv->ip_iface == NULL);
+ klass = NM_DEVICE_GET_CLASS (self);
+
/* Balanced by a thaw in nm_device_setup_finish() */
g_object_freeze_notify (G_OBJECT (self));
@@ -1858,7 +1884,7 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
}
if (priv->ifindex > 0) {
- _LOGD (LOGD_DEVICE, "setup_start(): %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex);
+ _LOGD (LOGD_DEVICE, "start setup of %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex);
priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
g_object_notify (G_OBJECT (self), NM_DEVICE_PHYSICAL_PORT_ID);
@@ -1885,8 +1911,8 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ifindex);
}
- if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
- priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
+ if (klass->get_generic_capabilities)
+ priv->capabilities |= klass->get_generic_capabilities (self);
if (!priv->udi) {
/* Use a placeholder UDI until we get a real one */
@@ -1924,14 +1950,8 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
g_object_notify (G_OBJECT (self), NM_DEVICE_CAPABILITIES);
priv->real = TRUE;
-}
-
-static void
-realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
-{
- g_return_if_fail (NM_IS_DEVICE (self));
- NM_DEVICE_GET_CLASS (self)->setup_start (self, plink);
+ klass->realize_start_notify (self, plink);
}
/**
@@ -1958,7 +1978,7 @@ nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink)
nm_device_recheck_available_connections (self);
- /* Balanced by a freeze in setup_start() */
+ /* Balanced by a freeze in realize_start_setup() */
g_object_thaw_notify (G_OBJECT (self));
}
@@ -10868,7 +10888,7 @@ nm_device_class_init (NMDeviceClass *klass)
klass->check_connection_compatible = check_connection_compatible;
klass->check_connection_available = check_connection_available;
klass->can_unmanaged_external_down = can_unmanaged_external_down;
- klass->setup_start = setup_start;
+ klass->realize_start_notify = realize_start_notify;
klass->unrealize = unrealize;
klass->is_up = is_up;
klass->bring_up = bring_up;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index ce49320e64..edcbb443a1 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -189,17 +189,14 @@ typedef struct {
GError **error);
/**
- * setup_start():
+ * realize_start_notify():
* @self: the #NMDevice
* @plink: the #NMPlatformLink if backed by a kernel netdevice
*
- * Update the device from backing resource properties (like hardware
- * addresses, carrier states, driver/firmware info, etc). This function
- * should only change properties for this device, and should not perform
- * any tasks that affect other interfaces (like master/slave or parent/child
- * stuff).
+ * Hook for derived classes to be notfied during realize_start_setup()
+ * and perform additional setup.
*/
- void (*setup_start) (NMDevice *self, const NMPlatformLink *plink);
+ void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink);
/**
* unrealize():
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 247534d17e..64da03e1c8 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -404,9 +404,9 @@ periodic_update_cb (gpointer user_data)
}
static void
-setup_start (NMDevice *device, const NMPlatformLink *plink)
+realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
{
- NM_DEVICE_CLASS (nm_device_wifi_parent_class)->setup_start (device, plink);
+ NM_DEVICE_CLASS (nm_device_wifi_parent_class)->realize_start_notify (device, plink);
g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS);
}
@@ -3016,7 +3016,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
object_class->dispose = dispose;
object_class->finalize = finalize;
- parent_class->setup_start = setup_start;
+ parent_class->realize_start_notify = realize_start_notify;
parent_class->bring_up = bring_up;
parent_class->can_auto_connect = can_auto_connect;
parent_class->is_available = is_available;