diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index dbd38401e..c816c94bc 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -59,12 +59,14 @@ enum { /**************************************************************/ static void -link_changed (NMDevice *device) +link_changed (NMDevice *device, NMPlatformLink *info) { NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformGreProperties props; + NM_DEVICE_CLASS (nm_device_gre_parent_class)->link_changed (device, info); + if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) { nm_log_warn (LOGD_HW, "(%s): could not read gre properties", nm_device_get_iface (device)); @@ -128,7 +130,7 @@ nm_device_gre_init (NMDeviceGre *self) static void constructed (GObject *object) { - link_changed (NM_DEVICE (object)); + link_changed (NM_DEVICE (object), NULL); G_OBJECT_CLASS (nm_device_gre_parent_class)->constructed (object); } diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 4d7f5029c..0f782024b 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -54,12 +54,14 @@ enum { /**************************************************************/ static void -link_changed (NMDevice *device) +link_changed (NMDevice *device, NMPlatformLink *info) { NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformMacvlanProperties props; + NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info); + if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) { nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties", nm_device_get_iface (device)); @@ -108,7 +110,7 @@ nm_device_macvlan_init (NMDeviceMacvlan *self) static void constructed (GObject *object) { - link_changed (NM_DEVICE (object)); + link_changed (NM_DEVICE (object), NULL); G_OBJECT_CLASS (nm_device_macvlan_parent_class)->constructed (object); } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 86498cf85..0ed182c4d 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -53,12 +53,14 @@ enum { }; static void -link_changed (NMDevice *device) +link_changed (NMDevice *device, NMPlatformLink *info) { NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformTunProperties props; + NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, info); + if (!nm_platform_tun_get_properties (nm_device_get_ifindex (device), &props)) { nm_log_warn (LOGD_HW, "(%s): could not read tun properties", nm_device_get_iface (device)); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 79e7f28bd..11db09880 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1151,15 +1151,21 @@ nm_device_set_carrier (NMDevice *device, gboolean carrier) static void link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMDevice *device) { + NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device); + if (ifindex != nm_device_get_ifindex (device)) return; + if (klass->link_changed) + klass->link_changed (device, info); +} + +static void +link_changed (NMDevice *device, NMPlatformLink *info) +{ if ( device_has_capability (device, NM_DEVICE_CAP_CARRIER_DETECT) && !device_has_capability (device, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) nm_device_set_carrier (device, info->connected); - - if (NM_DEVICE_GET_CLASS (device)->link_changed) - NM_DEVICE_GET_CLASS (device)->link_changed (device); } static void @@ -5124,6 +5130,8 @@ nm_device_class_init (NMDeviceClass *klass) object_class->constructor = constructor; object_class->constructed = constructed; + klass->link_changed = link_changed; + klass->is_available = is_available; klass->act_stage1_prepare = act_stage1_prepare; klass->act_stage2_config = act_stage2_config; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 4ce5927fa..d731a4120 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -101,6 +101,8 @@ typedef struct { NMDeviceState old_state, NMDeviceStateReason reason); + void (* link_changed) (NMDevice *self, NMPlatformLink *info); + /* Hardware state (IFF_UP) */ gboolean (*is_up) (NMDevice *self); gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware); @@ -186,8 +188,6 @@ typedef struct { gboolean (* have_any_ready_slaves) (NMDevice *self, const GSList *slaves); - - void (* link_changed) (NMDevice *self); } NMDeviceClass;