mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 14:10:12 +01:00
device: don't call virtual function carrier_changed() directly
Don't give the subclass the ability to override the parents behavior. The parent implementation is not intended to allow for that. Instead, restrict the flexibility of how the virtual function integrates with the larger picture. That means, the virtual function is only called at one place, and there is only one implementation in NMDeviceEthernet (and it doesn't really matter whether the implementation chains up the parent implementation or not).
This commit is contained in:
parent
23bc781063
commit
5a7374d8be
3 changed files with 16 additions and 10 deletions
|
|
@ -1597,12 +1597,11 @@ get_link_speed (NMDevice *device)
|
|||
}
|
||||
|
||||
static void
|
||||
carrier_changed (NMDevice *device, gboolean carrier)
|
||||
carrier_changed_notify (NMDevice *device, gboolean carrier)
|
||||
{
|
||||
if (carrier)
|
||||
get_link_speed (device);
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->carrier_changed (device, carrier);
|
||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->carrier_changed_notify (device, carrier);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1764,7 +1763,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||
parent_class->deactivate = deactivate;
|
||||
parent_class->get_s390_subchannels = get_s390_subchannels;
|
||||
parent_class->update_connection = update_connection;
|
||||
parent_class->carrier_changed = carrier_changed;
|
||||
parent_class->carrier_changed_notify = carrier_changed_notify;
|
||||
parent_class->link_changed = link_changed;
|
||||
parent_class->is_available = is_available;
|
||||
parent_class->can_reapply_change = can_reapply_change;
|
||||
|
|
|
|||
|
|
@ -2170,11 +2170,19 @@ nm_device_update_dynamic_ip_setup (NMDevice *self)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
carrier_changed_notify (NMDevice *self, gboolean carrier)
|
||||
{
|
||||
/* stub */
|
||||
}
|
||||
|
||||
static void
|
||||
carrier_changed (NMDevice *self, gboolean carrier)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->carrier_changed_notify (self, carrier);
|
||||
|
||||
if (priv->state <= NM_DEVICE_STATE_UNMANAGED)
|
||||
return;
|
||||
|
||||
|
|
@ -2248,7 +2256,7 @@ link_disconnect_action_cb (gpointer user_data)
|
|||
|
||||
priv->carrier_defer_id = 0;
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->carrier_changed (self, FALSE);
|
||||
carrier_changed (self, FALSE);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -2269,7 +2277,6 @@ void
|
|||
nm_device_set_carrier (NMDevice *self, gboolean carrier)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (self);
|
||||
NMDeviceState state = nm_device_get_state (self);
|
||||
|
||||
if (priv->carrier == carrier)
|
||||
|
|
@ -2281,7 +2288,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier)
|
|||
if (priv->carrier) {
|
||||
_LOGI (LOGD_DEVICE, "link connected");
|
||||
link_disconnect_action_cancel (self);
|
||||
klass->carrier_changed (self, TRUE);
|
||||
carrier_changed (self, TRUE);
|
||||
|
||||
if (nm_clear_g_source (&priv->carrier_wait_id)) {
|
||||
nm_device_remove_pending_action (self, NM_PENDING_ACTION_CARRIER_WAIT, TRUE);
|
||||
|
|
@ -2290,7 +2297,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier)
|
|||
} else if ( state <= NM_DEVICE_STATE_DISCONNECTED
|
||||
&& !priv->queued_act_request) {
|
||||
_LOGD (LOGD_DEVICE, "link disconnected");
|
||||
klass->carrier_changed (self, FALSE);
|
||||
carrier_changed (self, FALSE);
|
||||
} else {
|
||||
priv->carrier_defer_id = g_timeout_add_seconds (LINK_DISCONNECT_DELAY,
|
||||
link_disconnect_action_cb, self);
|
||||
|
|
@ -14109,7 +14116,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
klass->can_unmanaged_external_down = can_unmanaged_external_down;
|
||||
klass->realize_start_notify = realize_start_notify;
|
||||
klass->unrealize_notify = unrealize_notify;
|
||||
klass->carrier_changed = carrier_changed;
|
||||
klass->carrier_changed_notify = carrier_changed_notify;
|
||||
klass->get_ip_iface_identifier = get_ip_iface_identifier;
|
||||
klass->unmanaged_on_quit = unmanaged_on_quit;
|
||||
klass->deactivate_reset_hw_addr = deactivate_reset_hw_addr;
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ typedef struct {
|
|||
gboolean (*can_unmanaged_external_down) (NMDevice *self);
|
||||
|
||||
/* Carrier state (IFF_LOWER_UP) */
|
||||
void (*carrier_changed) (NMDevice *, gboolean carrier);
|
||||
void (*carrier_changed_notify) (NMDevice *, gboolean carrier);
|
||||
|
||||
gboolean (* get_ip_iface_identifier) (NMDevice *self, NMUtilsIPv6IfaceId *out_iid);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue