mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 01:10:33 +01:00
core: clean up and simplify device capabilities handling
This is really, really old 2007-era code. Any NMDevice that gets created is already supported, so there's no reason to have every device set NM_DEVICE_CAP_NM_SUPPORTED. For those subclasses that only set that capability, we can remove the subclass method entirely. Next, it turns out that the "type capabilities" code wasn't used anywhere, so remove that too. Lastly, "cipsec" interfaces haven't been used on linux in about 5 years (they were created by the Cisco binary-only IPSec kernel module for Cisco VPNs long before vpnc and openswan came around) so we can remove that code too.
This commit is contained in:
parent
38459f5a00
commit
be807819b0
15 changed files with 11 additions and 126 deletions
|
|
@ -88,9 +88,7 @@ typedef struct {
|
|||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return ( NM_DEVICE_CAP_NM_SUPPORTED
|
||||
| NM_DEVICE_CAP_CARRIER_DETECT
|
||||
| NM_DEVICE_CAP_NONSTANDARD_CARRIER);
|
||||
return (NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NONSTANDARD_CARRIER);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ get_hw_address_length (NMDevice *device)
|
|||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ nm_bridge_error_quark (void)
|
|||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -369,12 +369,6 @@ complete_connection (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static const GByteArray *
|
||||
get_connection_hw_address (NMDevice *device,
|
||||
NMConnection *connection)
|
||||
|
|
@ -1269,7 +1263,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
|
|||
object_class->finalize = finalize;
|
||||
|
||||
device_class->can_auto_connect = can_auto_connect;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->deactivate = deactivate;
|
||||
device_class->act_stage2_config = act_stage2_config;
|
||||
device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
|
||||
|
|
|
|||
|
|
@ -454,18 +454,11 @@ static guint32
|
|||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
|
||||
guint32 caps = NM_DEVICE_CAP_NONE;
|
||||
|
||||
/* cipsec devices are also explicitly unsupported at this time */
|
||||
if (strstr (nm_device_get_iface (dev), "cipsec"))
|
||||
return NM_DEVICE_CAP_NONE;
|
||||
|
||||
if (supports_ethtool_carrier_detect (self) || supports_mii_carrier_detect (self))
|
||||
caps |= NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
|
||||
caps |= NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
|
||||
return caps;
|
||||
return NM_DEVICE_CAP_NONE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -58,12 +58,6 @@ nm_device_generic_error_quark (void)
|
|||
|
||||
/**************************************************************/
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_available (NMDevice *device)
|
||||
{
|
||||
|
|
@ -196,7 +190,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
|||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->is_available = is_available;
|
||||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ get_hw_address_length (NMDevice *device)
|
|||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
|
|
|
|||
|
|
@ -214,12 +214,6 @@ device_state_changed (NMDevice *device,
|
|||
reason);
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *device)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static guint
|
||||
get_hw_address_length (NMDevice *device)
|
||||
{
|
||||
|
|
@ -484,7 +478,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
|
|||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->get_hw_address_length = get_hw_address_length;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->complete_connection = complete_connection;
|
||||
|
|
|
|||
|
|
@ -113,12 +113,6 @@ nm_olpc_mesh_error_quark (void)
|
|||
return quark;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_olpc_mesh_init (NMDeviceOlpcMesh * self)
|
||||
{
|
||||
|
|
@ -477,8 +471,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
|
||||
parent_class->get_type_capabilities = NULL;
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->is_up = is_up;
|
||||
parent_class->bring_up = bring_up;
|
||||
parent_class->take_down = take_down;
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ gboolean nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6);
|
|||
|
||||
void nm_device_set_firmware_missing (NMDevice *self, gboolean missing);
|
||||
|
||||
guint32 nm_device_get_capabilities (NMDevice *dev);
|
||||
guint32 nm_device_get_type_capabilities (NMDevice *dev);
|
||||
|
||||
void nm_device_activate_schedule_stage1_device_prepare (NMDevice *device);
|
||||
void nm_device_activate_schedule_stage2_device_config (NMDevice *device);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static guint32
|
|||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
/* We assume VLAN interfaces always support carrier detect */
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -274,12 +274,6 @@ ipw_rfkill_state_work (gpointer user_data)
|
|||
|
||||
/*****************************************************************/
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static GObject*
|
||||
constructor (GType type,
|
||||
guint n_construct_params,
|
||||
|
|
@ -3352,14 +3346,6 @@ can_interrupt_activation (NMDevice *dev)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static guint32
|
||||
get_type_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_WIFI_GET_PRIVATE (dev)->capabilities;
|
||||
}
|
||||
|
||||
|
||||
static const GByteArray *
|
||||
get_connection_hw_address (NMDevice *device,
|
||||
NMConnection *connection)
|
||||
|
|
@ -3652,8 +3638,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
|
||||
parent_class->get_type_capabilities = get_type_capabilities;
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->hw_bring_up = hw_bring_up;
|
||||
parent_class->is_up = is_up;
|
||||
parent_class->bring_up = bring_up;
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ nm_device_init (NMDevice *self)
|
|||
int i;
|
||||
|
||||
priv->type = NM_DEVICE_TYPE_UNKNOWN;
|
||||
priv->capabilities = NM_DEVICE_CAP_NONE;
|
||||
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
priv->state = NM_DEVICE_STATE_UNMANAGED;
|
||||
priv->state_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
priv->dhcp_timeout = 0;
|
||||
|
|
@ -507,11 +507,8 @@ constructor (GType type,
|
|||
goto error;
|
||||
}
|
||||
|
||||
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
|
||||
if (!device_has_capability (dev, NM_DEVICE_CAP_NM_SUPPORTED)) {
|
||||
nm_log_warn (LOGD_DEVICE, "(%s): Device unsupported, ignoring.", priv->iface);
|
||||
goto error;
|
||||
}
|
||||
if (NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities)
|
||||
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
|
||||
|
||||
priv->dhcp_manager = nm_dhcp_manager_get ();
|
||||
|
||||
|
|
@ -603,12 +600,6 @@ hw_is_up (NMDevice *device)
|
|||
return ifindex > 0 ? nm_system_iface_is_up (ifindex) : TRUE;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nm_device_set_path (NMDevice *self, const char *path)
|
||||
{
|
||||
|
|
@ -822,36 +813,6 @@ nm_device_get_priority (NMDevice *dev)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Accessor for capabilities
|
||||
*/
|
||||
guint32
|
||||
nm_device_get_capabilities (NMDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
|
||||
|
||||
return NM_DEVICE_GET_PRIVATE (self)->capabilities;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessor for type-specific capabilities
|
||||
*/
|
||||
guint32
|
||||
nm_device_get_type_capabilities (NMDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
|
||||
|
||||
return NM_DEVICE_GET_CLASS (self)->get_type_capabilities (self);
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_type_capabilities (NMDevice *self)
|
||||
{
|
||||
return NM_DEVICE_CAP_NONE;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
nm_device_get_type_desc (NMDevice *self)
|
||||
{
|
||||
|
|
@ -1555,18 +1516,12 @@ nm_device_get_best_auto_connection (NMDevice *dev,
|
|||
GSList *connections,
|
||||
char **specific_object)
|
||||
{
|
||||
guint32 caps;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (dev), NULL);
|
||||
g_return_val_if_fail (specific_object != NULL, NULL);
|
||||
g_return_val_if_fail (*specific_object == NULL, NULL);
|
||||
|
||||
caps = nm_device_get_capabilities (dev);
|
||||
/* Don't use devices that SUCK */
|
||||
if (!(caps & NM_DEVICE_CAP_NM_SUPPORTED))
|
||||
return NULL;
|
||||
|
||||
for (iter = connections; iter; iter = iter->next) {
|
||||
NMConnection *connection = NM_CONNECTION (iter->data);
|
||||
|
||||
|
|
@ -4819,9 +4774,6 @@ set_property (GObject *object, guint prop_id,
|
|||
g_free (priv->firmware_version);
|
||||
priv->firmware_version = g_strdup (g_value_get_string (value));
|
||||
break;
|
||||
case PROP_CAPABILITIES:
|
||||
priv->capabilities = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IP4_ADDRESS:
|
||||
priv->ip4_address = g_value_get_uint (value);
|
||||
break;
|
||||
|
|
@ -5021,8 +4973,6 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
object_class->constructor = constructor;
|
||||
object_class->constructed = constructed;
|
||||
|
||||
klass->get_type_capabilities = get_type_capabilities;
|
||||
klass->get_generic_capabilities = get_generic_capabilities;
|
||||
klass->is_available = is_available;
|
||||
klass->act_stage1_prepare = act_stage1_prepare;
|
||||
klass->act_stage2_config = act_stage2_config;
|
||||
|
|
@ -5097,7 +5047,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
"Capabilities",
|
||||
"Capabilities",
|
||||
0, G_MAXUINT32, NM_DEVICE_CAP_NONE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CARRIER,
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ typedef struct {
|
|||
void (* update_initial_hw_address) (NMDevice *self);
|
||||
guint (* get_hw_address_length) (NMDevice *self);
|
||||
|
||||
guint32 (* get_type_capabilities) (NMDevice *self);
|
||||
guint32 (* get_generic_capabilities) (NMDevice *self);
|
||||
|
||||
gboolean (* is_available) (NMDevice *self);
|
||||
|
|
|
|||
|
|
@ -557,12 +557,6 @@ can_auto_connect (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_available (NMDevice *device)
|
||||
{
|
||||
|
|
@ -1421,7 +1415,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass)
|
|||
device_class->check_connection_available = check_connection_available;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->can_auto_connect = can_auto_connect;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->is_available = is_available;
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->act_stage2_config = act_stage2_config;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue