mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 03:30:31 +01:00
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().
This commit is contained in:
parent
0311a0eae3
commit
4c6b991bb0
10 changed files with 62 additions and 45 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue