diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 96459e2567..569ff9d112 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -69,25 +69,6 @@ nm_bond_error_quark (void) /******************************************************************/ -static guint -get_hw_address_length (NMDevice *device) -{ - GSList *slaves; - guint length; - - /* A bond's hwaddr length depends on what kind of slaves it has; - * if it has no slaves, then it doesn't have a valid hwaddr. - */ - slaves = nm_device_master_get_slaves (device); - if (slaves) { - nm_device_get_hw_address (slaves->data, &length); - g_slist_free (slaves); - } else - length = 0; - - return length; -} - static guint32 get_generic_capabilities (NMDevice *dev) { @@ -356,7 +337,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) object_class->set_property = set_property; parent_class->get_generic_capabilities = get_generic_capabilities; - parent_class->get_hw_address_length = get_hw_address_length; parent_class->is_available = is_available; parent_class->check_connection_compatible = check_connection_compatible; parent_class->complete_connection = complete_connection; diff --git a/src/devices/nm-device-bt.c b/src/devices/nm-device-bt.c index 9b7744c40e..e513eb95dc 100644 --- a/src/devices/nm-device-bt.c +++ b/src/devices/nm-device-bt.c @@ -112,6 +112,17 @@ guint32 nm_device_bt_get_capabilities (NMDeviceBt *self) return NM_DEVICE_BT_GET_PRIVATE (self)->capabilities; } +static guint +get_hw_address_length (NMDevice *device) +{ + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); + + if (priv->have_iface) + return ETH_ALEN; + else + return 0; +} + static guint32 get_connection_bt_type (NMConnection *connection) { @@ -1260,6 +1271,7 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; + device_class->get_hw_address_length = get_hw_address_length; device_class->can_auto_connect = can_auto_connect; device_class->deactivate = deactivate; device_class->act_stage2_config = act_stage2_config; diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index ab182081e8..da97edd58e 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -104,12 +104,6 @@ nm_device_infiniband_new (NMPlatformLink *platform_device) NULL); } -static guint -get_hw_address_length (NMDevice *device) -{ - return INFINIBAND_ALEN; -} - static guint32 get_generic_capabilities (NMDevice *dev) { @@ -324,7 +318,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) object_class->set_property = set_property; parent_class->get_generic_capabilities = get_generic_capabilities; - parent_class->get_hw_address_length = get_hw_address_length; parent_class->check_connection_compatible = check_connection_compatible; parent_class->complete_connection = complete_connection; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4fa864aa0e..f337a9775e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -686,13 +686,21 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface) g_free (old_ip_iface); } +static guint +get_hw_address_length (NMDevice *dev) +{ + size_t len; + + if (nm_platform_link_get_address (nm_device_get_ip_ifindex (dev), &len)) + return len; + else + return 0; +} + static guint nm_device_get_hw_address_length (NMDevice *dev) { - if (NM_DEVICE_GET_CLASS (dev)->get_hw_address_length) - return NM_DEVICE_GET_CLASS (dev)->get_hw_address_length (dev); - else - return ETH_ALEN; + return NM_DEVICE_GET_CLASS (dev)->get_hw_address_length (dev); } const guint8 * @@ -4972,6 +4980,7 @@ nm_device_class_init (NMDeviceClass *klass) klass->hw_take_down = hw_take_down; klass->carrier_changed = carrier_changed; klass->can_interrupt_activation = can_interrupt_activation; + klass->get_hw_address_length = get_hw_address_length; /* Properties */ g_object_class_install_property