devices: use NMPlatform to find the hardware address length
For device types that don't override it, make nm_device_get_hw_addr_len() use NMPlatform to find out the actual hardware address length, rather than just defaulting to ETH_ALEN. Fixes warnings in the logs when using tun or gre devices.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user