mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 14:40:33 +01:00
core/device: merge branch 'th/device-realize-bgo760450'
https://bugzilla.gnome.org/show_bug.cgi?id=760450
This commit is contained in:
commit
61f400ac03
22 changed files with 224 additions and 282 deletions
|
|
@ -411,7 +411,7 @@ nm_bluez_manager_init (NMBluezManager *self)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -513,18 +513,18 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_DRIVER, "bonding",
|
||||
NM_DEVICE_TYPE_DESC, "Bond",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BOND,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_DRIVER, "bonding",
|
||||
NM_DEVICE_TYPE_DESC, "Bond",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BOND,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL (BOND, Bond, bond,
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -305,9 +305,9 @@ nm_device_ethernet_init (NMDeviceEthernet *self)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
g_object_notify (G_OBJECT (device), NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
|
||||
}
|
||||
|
|
@ -1731,7 +1731,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->setup_start = setup_start;
|
||||
parent_class->realize_start_notify = realize_start_notify;
|
||||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
parent_class->complete_connection = complete_connection;
|
||||
parent_class->new_default_connection = new_default_connection;
|
||||
|
|
@ -1784,7 +1784,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ nm_device_factory_start (NMDeviceFactory *factory)
|
|||
NMDevice *
|
||||
nm_device_factory_create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore,
|
||||
GError **error)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ typedef struct {
|
|||
*/
|
||||
NMDevice * (*create_device) (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore);
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ void nm_device_factory_start (NMDeviceFactory *factory);
|
|||
|
||||
NMDevice * nm_device_factory_create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -61,13 +61,13 @@ get_type_description (NMDevice *device)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDeviceGeneric *self = NM_DEVICE_GENERIC (device);
|
||||
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self);
|
||||
int ifindex;
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_generic_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_generic_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
g_clear_pointer (&priv->type_description, g_free);
|
||||
ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self));
|
||||
|
|
@ -111,7 +111,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
/**************************************************************/
|
||||
|
||||
NMDevice *
|
||||
nm_device_generic_new (NMPlatformLink *plink)
|
||||
nm_device_generic_new (const NMPlatformLink *plink)
|
||||
{
|
||||
g_return_val_if_fail (plink != NULL, NULL);
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
|||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
parent_class->setup_start = setup_start;
|
||||
parent_class->realize_start_notify = realize_start_notify;
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->get_type_description = get_type_description;
|
||||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ typedef struct {
|
|||
|
||||
GType nm_device_generic_get_type (void);
|
||||
|
||||
NMDevice *nm_device_generic_new (NMPlatformLink *plink);
|
||||
NMDevice *nm_device_generic_new (const NMPlatformLink *plink);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -448,13 +448,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
realize (NMDevice *self, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
update_properties (self);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
match_parent (NMDevice *dev_parent, const char *setting_parent)
|
||||
{
|
||||
|
|
@ -771,9 +764,9 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
update_properties (device);
|
||||
}
|
||||
|
|
@ -797,9 +790,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
}
|
||||
|
||||
static void
|
||||
unrealize (NMDevice *device, gboolean remove_resources)
|
||||
unrealize_notify (NMDevice *device)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize (device, remove_resources);
|
||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize_notify (device);
|
||||
|
||||
update_properties_from_ifindex (device, 0);
|
||||
}
|
||||
|
|
@ -885,9 +878,8 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
|
|||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||
device_class->realize = realize;
|
||||
device_class->setup_start = setup_start;
|
||||
device_class->unrealize = unrealize;
|
||||
device_class->realize_start_notify = realize_start_notify;
|
||||
device_class->unrealize_notify = unrealize_notify;
|
||||
|
||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass,
|
||||
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
||||
|
|
@ -988,7 +980,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -209,13 +209,6 @@ link_changed (NMDevice *device, NMPlatformLink *info)
|
|||
update_properties (device);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
realize (NMDevice *device, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
update_properties (device);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
|
|
@ -558,9 +551,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
update_properties (device);
|
||||
}
|
||||
|
|
@ -652,8 +645,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
device_class->is_available = is_available;
|
||||
device_class->link_changed = link_changed;
|
||||
device_class->notify_new_device_added = notify_new_device_added;
|
||||
device_class->realize = realize;
|
||||
device_class->setup_start = setup_start;
|
||||
device_class->realize_start_notify = realize_start_notify;
|
||||
device_class->update_connection = update_connection;
|
||||
|
||||
/* properties */
|
||||
|
|
@ -699,7 +691,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -234,17 +234,10 @@ create_and_realize (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
realize (NMDevice *device, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
reload_tun_properties (NM_DEVICE_TUN (device));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->realize_start_notify (device, plink);
|
||||
reload_tun_properties (device);
|
||||
}
|
||||
|
||||
|
|
@ -344,14 +337,14 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||
}
|
||||
|
||||
static void
|
||||
unrealize (NMDevice *device, gboolean remove_resources)
|
||||
unrealize_notify (NMDevice *device)
|
||||
{
|
||||
NMDeviceTun *self = NM_DEVICE_TUN (device);
|
||||
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
|
||||
GParamSpec **properties;
|
||||
guint n_properties, i;
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize (device, remove_resources);
|
||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device);
|
||||
|
||||
memset (&priv->props, 0, sizeof (NMPlatformTunProperties));
|
||||
|
||||
|
|
@ -446,9 +439,8 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
|
|||
device_class->complete_connection = complete_connection;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->realize = realize;
|
||||
device_class->setup_start = setup_start;
|
||||
device_class->unrealize = unrealize;
|
||||
device_class->realize_start_notify = realize_start_notify;
|
||||
device_class->unrealize_notify = unrealize_notify;
|
||||
device_class->update_connection = update_connection;
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||
|
|
@ -504,7 +496,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ typedef struct {
|
|||
NMDevice *parent;
|
||||
gulong parent_state_id;
|
||||
gulong parent_hwaddr_id;
|
||||
int vlan_id;
|
||||
guint vlan_id;
|
||||
} NMDeviceVlanPrivate;
|
||||
|
||||
enum {
|
||||
|
|
@ -152,59 +152,47 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
update_properties (NMDevice *device)
|
||||
{
|
||||
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||
NMDeviceVlanPrivate *priv;
|
||||
const NMPlatformLink *plink = NULL;
|
||||
const NMPlatformLnkVlan *plnk = NULL;
|
||||
NMDevice *parent = NULL;
|
||||
int ifindex;
|
||||
guint vlan_id;
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->setup_start (device, plink);
|
||||
g_return_if_fail (NM_IS_DEVICE_VLAN (device));
|
||||
|
||||
_LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s",
|
||||
priv->vlan_id, nm_device_get_iface (priv->parent));
|
||||
priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
|
||||
if (ifindex > 0)
|
||||
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, ifindex, &plink);
|
||||
if ( plnk
|
||||
&& plink->parent
|
||||
&& plink->parent != NM_PLATFORM_LINK_OTHER_NETNS)
|
||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent);
|
||||
|
||||
g_object_freeze_notify ((GObject *) device);
|
||||
|
||||
nm_device_vlan_set_parent ((NMDeviceVlan *) device, parent);
|
||||
|
||||
vlan_id = plnk ? plnk->id : 0;
|
||||
if (vlan_id != priv->vlan_id) {
|
||||
priv->vlan_id = vlan_id;
|
||||
g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID);
|
||||
}
|
||||
|
||||
g_object_thaw_notify ((GObject *) device);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
realize (NMDevice *device,
|
||||
NMPlatformLink *plink,
|
||||
GError **error)
|
||||
static void
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
NMDevice *parent;
|
||||
const NMPlatformLnkVlan *plnk;
|
||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
g_return_val_if_fail (plink, FALSE);
|
||||
|
||||
g_assert (plink->type == NM_LINK_TYPE_VLAN);
|
||||
|
||||
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, plink->ifindex, NULL);
|
||||
if (!plnk) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
"(%s): failed to get VLAN properties", plink->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (plnk->id < 0) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
"(%s): VLAN ID invalid", plink->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) {
|
||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent);
|
||||
if (!parent) {
|
||||
nm_log_dbg (LOGD_HW, "(%s): VLAN parent interface unknown", plink->name);
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
"(%s): VLAN parent interface unknown", plink->name);
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
parent = NULL;
|
||||
|
||||
g_warn_if_fail (priv->parent == NULL);
|
||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent);
|
||||
priv->vlan_id = plnk->id;
|
||||
|
||||
return TRUE;
|
||||
update_properties (device);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -217,7 +205,8 @@ create_and_realize (NMDevice *device,
|
|||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
NMSettingVlan *s_vlan;
|
||||
int parent_ifindex, vlan_id;
|
||||
int parent_ifindex;
|
||||
guint vlan_id;
|
||||
NMPlatformError plerr;
|
||||
|
||||
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||
|
|
@ -253,15 +242,18 @@ create_and_realize (NMDevice *device,
|
|||
|
||||
g_warn_if_fail (priv->parent == NULL);
|
||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent);
|
||||
priv->vlan_id = vlan_id;
|
||||
if (vlan_id != priv->vlan_id) {
|
||||
priv->vlan_id = vlan_id;
|
||||
g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
unrealize (NMDevice *device, gboolean remove_resources)
|
||||
unrealize_notify (NMDevice *device)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize (device, remove_resources);
|
||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device);
|
||||
|
||||
NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id = 0;
|
||||
g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID);
|
||||
|
|
@ -317,10 +309,8 @@ notify_new_device_added (NMDevice *device, NMDevice *new_device)
|
|||
return;
|
||||
|
||||
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink);
|
||||
if (!plnk) {
|
||||
_LOGW (LOGD_VLAN, "failed to get VLAN interface info while checking added component.");
|
||||
if (!plnk)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( plink->parent <= 0
|
||||
|| nm_device_get_ifindex (new_device) != plink->parent)
|
||||
|
|
@ -484,15 +474,14 @@ complete_connection (NMDevice *device,
|
|||
static void
|
||||
update_connection (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection);
|
||||
int ifindex = nm_device_get_ifindex (device);
|
||||
NMDevice *parent;
|
||||
const char *setting_parent, *new_parent;
|
||||
const NMPlatformLink *plink;
|
||||
const NMPObject *polnk;
|
||||
nm_auto_nmpobj NMPObject *polnk_ref = NULL;
|
||||
guint vlan_id;
|
||||
guint vlan_flags;
|
||||
|
||||
if (!s_vlan) {
|
||||
s_vlan = (NMSettingVlan *) nm_setting_vlan_new ();
|
||||
|
|
@ -500,36 +489,27 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
|
||||
polnk = nm_platform_link_get_lnk (NM_PLATFORM_GET, ifindex, NM_LINK_TYPE_VLAN, &plink);
|
||||
if (!polnk) {
|
||||
_LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection.");
|
||||
return;
|
||||
}
|
||||
polnk_ref = nmp_object_ref ((NMPObject *) polnk);
|
||||
|
||||
if (priv->vlan_id != polnk->lnk_vlan.id) {
|
||||
priv->vlan_id = polnk->lnk_vlan.id;
|
||||
g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID);
|
||||
}
|
||||
|
||||
if (polnk->lnk_vlan.id != nm_setting_vlan_get_id (s_vlan))
|
||||
g_object_set (s_vlan, NM_SETTING_VLAN_ID, priv->vlan_id, NULL);
|
||||
|
||||
if (plink->parent != NM_PLATFORM_LINK_OTHER_NETNS)
|
||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent);
|
||||
if (polnk)
|
||||
vlan_id = polnk->lnk_vlan.id;
|
||||
else
|
||||
parent = NULL;
|
||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent);
|
||||
vlan_id = priv->vlan_id;
|
||||
if (vlan_id != nm_setting_vlan_get_id (s_vlan))
|
||||
g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL);
|
||||
|
||||
/* Update parent in the connection; default to parent's interface name */
|
||||
if (parent) {
|
||||
new_parent = nm_device_get_iface (parent);
|
||||
if ( priv->parent
|
||||
&& polnk
|
||||
&& plink->parent > 0
|
||||
&& nm_device_get_ifindex (priv->parent) == plink->parent) {
|
||||
new_parent = nm_device_get_iface (priv->parent);
|
||||
setting_parent = nm_setting_vlan_get_parent (s_vlan);
|
||||
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
||||
NMConnection *parent_connection;
|
||||
|
||||
/* Don't change a parent specified by UUID if it's still valid */
|
||||
parent_connection = nm_connection_provider_get_connection_by_uuid (nm_connection_provider_get (), setting_parent);
|
||||
if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection))
|
||||
if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection))
|
||||
new_parent = NULL;
|
||||
}
|
||||
if (new_parent)
|
||||
|
|
@ -537,15 +517,24 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
} else
|
||||
g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, NULL, NULL);
|
||||
|
||||
if (polnk->lnk_vlan.flags != nm_setting_vlan_get_flags (s_vlan))
|
||||
g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, (NMVlanFlags) polnk->lnk_vlan.flags, NULL);
|
||||
if (polnk)
|
||||
vlan_flags = polnk->lnk_vlan.flags;
|
||||
else
|
||||
vlan_flags = NM_VLAN_FLAG_REORDER_HEADERS;
|
||||
if (vlan_flags != nm_setting_vlan_get_flags (s_vlan))
|
||||
g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, (NMVlanFlags) vlan_flags, NULL);
|
||||
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP,
|
||||
polnk->_lnk_vlan.ingress_qos_map,
|
||||
polnk->_lnk_vlan.n_ingress_qos_map);
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP,
|
||||
polnk->_lnk_vlan.egress_qos_map,
|
||||
polnk->_lnk_vlan.n_egress_qos_map);
|
||||
if (polnk) {
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP,
|
||||
polnk->_lnk_vlan.ingress_qos_map,
|
||||
polnk->_lnk_vlan.n_ingress_qos_map);
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP,
|
||||
polnk->_lnk_vlan.egress_qos_map,
|
||||
polnk->_lnk_vlan.n_egress_qos_map);
|
||||
} else {
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP, NULL, 0);
|
||||
_nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
|
|
@ -691,9 +680,8 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
object_class->dispose = dispose;
|
||||
|
||||
parent_class->create_and_realize = create_and_realize;
|
||||
parent_class->realize = realize;
|
||||
parent_class->setup_start = setup_start;
|
||||
parent_class->unrealize = unrealize;
|
||||
parent_class->realize_start_notify = realize_start_notify;
|
||||
parent_class->unrealize_notify = unrealize_notify;
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
parent_class->bring_up = bring_up;
|
||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||
|
|
@ -733,7 +721,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,24 +145,24 @@ link_changed (NMDevice *device, NMPlatformLink *info)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
g_assert (plink->type == NM_LINK_TYPE_VXLAN);
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
update_properties (device);
|
||||
}
|
||||
|
||||
static void
|
||||
unrealize (NMDevice *device, gboolean remove_resources)
|
||||
unrealize_notify (NMDevice *device)
|
||||
{
|
||||
NMDeviceVxlan *self = NM_DEVICE_VXLAN (device);
|
||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self);
|
||||
GParamSpec **properties;
|
||||
guint n_properties, i;
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize (device, remove_resources);
|
||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize_notify (device);
|
||||
|
||||
memset (&priv->props, 0, sizeof (NMPlatformLnkVxlan));
|
||||
|
||||
|
|
@ -236,16 +236,6 @@ create_and_realize (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
realize (NMDevice *device, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
g_assert (plink->type == NM_LINK_TYPE_VXLAN);
|
||||
|
||||
update_properties (device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
match_parent (NMDeviceVxlan *self, const char *parent)
|
||||
{
|
||||
|
|
@ -666,11 +656,10 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||
object_class->dispose = dispose;
|
||||
|
||||
device_class->link_changed = link_changed;
|
||||
device_class->setup_start = setup_start;
|
||||
device_class->unrealize = unrealize;
|
||||
device_class->realize_start_notify = realize_start_notify;
|
||||
device_class->unrealize_notify = unrealize_notify;
|
||||
device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->realize = realize;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->update_connection = update_connection;
|
||||
|
|
@ -803,7 +792,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ static gboolean ip_config_valid (NMDeviceState state);
|
|||
static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, NMDeviceStateReason *reason);
|
||||
static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason);
|
||||
static void nm_device_start_ip_check (NMDevice *self);
|
||||
static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
|
|
@ -1699,23 +1700,23 @@ link_type_compatible (NMDevice *self,
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_device_realize():
|
||||
* nm_device_realize_start():
|
||||
* @self: the #NMDevice
|
||||
* @plink: an existing platform link or %NULL
|
||||
* @out_compatible: %TRUE on return if @self is compatible with @plink
|
||||
* @error: location to store error, or %NULL
|
||||
*
|
||||
* Initializes and sets up the device using existing backing resources. Before
|
||||
* the device is ready for use nm_device_setup_finish() must be called.
|
||||
* the device is ready for use nm_device_realize_finish() must be called.
|
||||
* @out_compatible will only be set if @plink is not %NULL, and
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error
|
||||
*/
|
||||
gboolean
|
||||
nm_device_realize (NMDevice *self,
|
||||
NMPlatformLink *plink,
|
||||
gboolean *out_compatible,
|
||||
GError **error)
|
||||
nm_device_realize_start (NMDevice *self,
|
||||
const NMPlatformLink *plink,
|
||||
gboolean *out_compatible,
|
||||
GError **error)
|
||||
{
|
||||
NM_SET_OUT (out_compatible, TRUE);
|
||||
|
||||
|
|
@ -1731,13 +1732,7 @@ nm_device_realize (NMDevice *self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Try to realize the device from existing resources */
|
||||
if (NM_DEVICE_GET_CLASS (self)->realize) {
|
||||
if (!NM_DEVICE_GET_CLASS (self)->realize (self, plink, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->setup_start (self, plink);
|
||||
realize_start_setup (self, plink);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1775,8 +1770,8 @@ nm_device_create_and_realize (NMDevice *self,
|
|||
plink = &plink_copy;
|
||||
}
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->setup_start (self, plink);
|
||||
nm_device_setup_finish (self, plink);
|
||||
realize_start_setup (self, plink);
|
||||
nm_device_realize_finish (self, plink);
|
||||
|
||||
g_return_val_if_fail (nm_device_check_connection_compatible (self, connection), TRUE);
|
||||
return TRUE;
|
||||
|
|
@ -1839,16 +1834,42 @@ check_carrier (NMDevice *self)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *self, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
/* Stub implementation for realize_start_notify(). It does nothing,
|
||||
* but allows derived classes to uniformly invoke the parent
|
||||
* implementation. */
|
||||
}
|
||||
|
||||
/**
|
||||
* realize_start_setup():
|
||||
* @self: the #NMDevice
|
||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
||||
*
|
||||
* Update the device from backing resource properties (like hardware
|
||||
* addresses, carrier states, driver/firmware info, etc). This function
|
||||
* should only change properties for this device, and should not perform
|
||||
* any tasks that affect other interfaces (like master/slave or parent/child
|
||||
* stuff).
|
||||
*/
|
||||
static void
|
||||
realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
NMDeviceClass *klass;
|
||||
static guint32 id = 0;
|
||||
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
/* The device should not be realized */
|
||||
g_return_if_fail (priv->ip_ifindex <= 0);
|
||||
g_return_if_fail (priv->ip_iface == NULL);
|
||||
|
||||
/* Balanced by a thaw in nm_device_setup_finish() */
|
||||
klass = NM_DEVICE_GET_CLASS (self);
|
||||
|
||||
/* Balanced by a thaw in nm_device_realize_finish() */
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
if (plink) {
|
||||
|
|
@ -1857,7 +1878,7 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
|
|||
}
|
||||
|
||||
if (priv->ifindex > 0) {
|
||||
_LOGD (LOGD_DEVICE, "setup_start(): %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex);
|
||||
_LOGD (LOGD_DEVICE, "start setup of %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex);
|
||||
|
||||
priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_PHYSICAL_PORT_ID);
|
||||
|
|
@ -1884,8 +1905,8 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
|
|||
priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ifindex);
|
||||
}
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
|
||||
priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
|
||||
if (klass->get_generic_capabilities)
|
||||
priv->capabilities |= klass->get_generic_capabilities (self);
|
||||
|
||||
if (!priv->udi) {
|
||||
/* Use a placeholder UDI until we get a real one */
|
||||
|
|
@ -1923,44 +1944,44 @@ setup_start (NMDevice *self, const NMPlatformLink *plink)
|
|||
g_object_notify (G_OBJECT (self), NM_DEVICE_CAPABILITIES);
|
||||
|
||||
priv->real = TRUE;
|
||||
|
||||
klass->realize_start_notify (self, plink);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_finish (NMDevice *self, const NMPlatformLink *plink)
|
||||
/**
|
||||
* nm_device_realize_finish():
|
||||
* @self: the #NMDevice
|
||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
||||
*
|
||||
* Update the device's master/slave or parent/child relationships from
|
||||
* backing resource properties. After this function finishes, the device
|
||||
* is ready for network connectivity.
|
||||
*/
|
||||
void
|
||||
nm_device_realize_finish (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
g_return_if_fail (!plink || link_type_compatible (self, plink->type, NULL, NULL));
|
||||
|
||||
if (plink) {
|
||||
update_device_from_platform_link (self, plink);
|
||||
device_recheck_slave_status (self, plink);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink)
|
||||
{
|
||||
g_return_if_fail (!plink || link_type_compatible (self, plink->type, NULL, NULL));
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->setup_finish (self, plink);
|
||||
|
||||
NM_DEVICE_GET_PRIVATE (self)->real = TRUE;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_REAL);
|
||||
|
||||
nm_device_recheck_available_connections (self);
|
||||
|
||||
/* Balanced by a freeze in setup_start() */
|
||||
/* Balanced by a freeze in realize_start_setup() */
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void
|
||||
unrealize (NMDevice *self, gboolean remove_resources)
|
||||
unrealize_notify (NMDevice *self)
|
||||
{
|
||||
int ifindex;
|
||||
|
||||
if (remove_resources) {
|
||||
ifindex = nm_device_get_ifindex (self);
|
||||
if ( ifindex > 0
|
||||
&& nm_device_is_software (self))
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, ifindex);
|
||||
}
|
||||
/* Stub implementation for unrealize_notify(). It does nothing,
|
||||
* but allows derived classes to uniformly invoke the parent
|
||||
* implementation. */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1978,6 +1999,7 @@ gboolean
|
|||
nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
int ifindex;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||
|
||||
|
|
@ -1995,8 +2017,13 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
|
|||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (self)->unrealize)
|
||||
NM_DEVICE_GET_CLASS (self)->unrealize (self, remove_resources);
|
||||
if (remove_resources) {
|
||||
ifindex = nm_device_get_ifindex (self);
|
||||
if (ifindex > 0)
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, ifindex);
|
||||
}
|
||||
|
||||
NM_DEVICE_GET_CLASS (self)->unrealize_notify (self);
|
||||
|
||||
if (priv->ifindex > 0) {
|
||||
priv->ifindex = 0;
|
||||
|
|
@ -10856,9 +10883,8 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
klass->check_connection_compatible = check_connection_compatible;
|
||||
klass->check_connection_available = check_connection_available;
|
||||
klass->can_unmanaged_external_down = can_unmanaged_external_down;
|
||||
klass->setup_start = setup_start;
|
||||
klass->setup_finish = setup_finish;
|
||||
klass->unrealize = unrealize;
|
||||
klass->realize_start_notify = realize_start_notify;
|
||||
klass->unrealize_notify = unrealize_notify;
|
||||
klass->is_up = is_up;
|
||||
klass->bring_up = bring_up;
|
||||
klass->take_down = take_down;
|
||||
|
|
|
|||
|
|
@ -144,27 +144,6 @@ typedef struct {
|
|||
|
||||
void (* link_changed) (NMDevice *self, NMPlatformLink *info);
|
||||
|
||||
/**
|
||||
* realize():
|
||||
* @self: the #NMDevice
|
||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
||||
* @error: location to store error, or %NULL
|
||||
*
|
||||
* Realize the device from existing backing resources. No resources
|
||||
* should be created as a side-effect of this function. This function
|
||||
* should only fail if critical device properties/resources (eg, VLAN ID)
|
||||
* fail to be read or initialized, that would cause the device to be
|
||||
* unusable. For example, for any properties required to realize the device
|
||||
* during create_and_realize(), if reading those properties in realize()
|
||||
* should fail, this function should probably return %FALSE and an error.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE if some error ocurred when realizing
|
||||
* the device from backing resources
|
||||
*/
|
||||
gboolean (*realize) (NMDevice *self,
|
||||
NMPlatformLink *plink,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* create_and_realize():
|
||||
* @self: the #NMDevice
|
||||
|
|
@ -189,39 +168,23 @@ typedef struct {
|
|||
GError **error);
|
||||
|
||||
/**
|
||||
* setup_start():
|
||||
* realize_start_notify():
|
||||
* @self: the #NMDevice
|
||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
||||
*
|
||||
* Update the device from backing resource properties (like hardware
|
||||
* addresses, carrier states, driver/firmware info, etc). This function
|
||||
* should only change properties for this device, and should not perform
|
||||
* any tasks that affect other interfaces (like master/slave or parent/child
|
||||
* stuff).
|
||||
* Hook for derived classes to be notfied during realize_start_setup()
|
||||
* and perform additional setup.
|
||||
*/
|
||||
void (*setup_start) (NMDevice *self, const NMPlatformLink *plink);
|
||||
void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink);
|
||||
|
||||
/**
|
||||
* setup_finish():
|
||||
* unrealize_notify():
|
||||
* @self: the #NMDevice
|
||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
||||
*
|
||||
* Update the device's master/slave or parent/child relationships from
|
||||
* backing resource properties. After this function finishes, the device
|
||||
* is ready for network connectivity.
|
||||
* Hook for derived classes to clear any properties that depend on backing resources
|
||||
* (kernel devices, etc). This is called by nm_device_unrealize() during unrealization.
|
||||
*/
|
||||
void (*setup_finish) (NMDevice *self, const NMPlatformLink *plink);
|
||||
|
||||
/**
|
||||
* unrealize():
|
||||
* @self: the #NMDevice
|
||||
* @remove_resources: if %TRUE remove backing resources
|
||||
* @error: location to store error, or %NULL
|
||||
*
|
||||
* Clears any properties that depend on backing resources (kernel devices,
|
||||
* etc) and removes those resources if @remove_resources is %TRUE.
|
||||
*/
|
||||
void (*unrealize) (NMDevice *self, gboolean remove_resources);
|
||||
void (*unrealize_notify) (NMDevice *self);
|
||||
|
||||
/* Hardware state (IFF_UP) */
|
||||
gboolean (*can_unmanaged_external_down) (NMDevice *self);
|
||||
|
|
@ -502,16 +465,16 @@ gboolean nm_device_get_is_nm_owned (NMDevice *device);
|
|||
|
||||
gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps);
|
||||
|
||||
gboolean nm_device_realize (NMDevice *device,
|
||||
NMPlatformLink *plink,
|
||||
gboolean nm_device_realize_start (NMDevice *device,
|
||||
const NMPlatformLink *plink,
|
||||
gboolean *out_compatible,
|
||||
GError **error);
|
||||
void nm_device_realize_finish (NMDevice *self,
|
||||
const NMPlatformLink *plink);
|
||||
gboolean nm_device_create_and_realize (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
GError **error);
|
||||
void nm_device_setup_finish (NMDevice *self,
|
||||
const NMPlatformLink *plink);
|
||||
gboolean nm_device_unrealize (NMDevice *device,
|
||||
gboolean remove_resources,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ nm_device_factory_create (GError **error)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -404,9 +404,9 @@ periodic_update_cb (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
setup_start (NMDevice *device, const NMPlatformLink *plink)
|
||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
||||
{
|
||||
NM_DEVICE_CLASS (nm_device_wifi_parent_class)->setup_start (device, plink);
|
||||
NM_DEVICE_CLASS (nm_device_wifi_parent_class)->realize_start_notify (device, plink);
|
||||
|
||||
g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS);
|
||||
}
|
||||
|
|
@ -3016,7 +3016,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
parent_class->setup_start = setup_start;
|
||||
parent_class->realize_start_notify = realize_start_notify;
|
||||
parent_class->bring_up = bring_up;
|
||||
parent_class->can_auto_connect = can_auto_connect;
|
||||
parent_class->is_available = is_available;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ nm_device_factory_create (GError **error)
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES (
|
|||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
NMPlatformLink *plink,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||
/* Create any backing resources the device needs */
|
||||
if (!nm_device_create_and_realize (device, connection, parent, &error)) {
|
||||
nm_log_warn (LOGD_DEVICE, "(%s) couldn't create the device: %s",
|
||||
nm_connection_get_id (connection), error->message);
|
||||
nm_connection_get_id (connection), error->message);
|
||||
g_error_free (error);
|
||||
remove_device (self, device, FALSE, TRUE);
|
||||
return NULL;
|
||||
|
|
@ -1895,9 +1895,9 @@ factory_device_added_cb (NMDeviceFactory *factory,
|
|||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (nm_device_realize (device, NULL, NULL, &error)) {
|
||||
if (nm_device_realize_start (device, NULL, NULL, &error)) {
|
||||
add_device (NM_MANAGER (user_data), device, NULL);
|
||||
nm_device_setup_finish (device, NULL);
|
||||
nm_device_realize_finish (device, NULL);
|
||||
} else {
|
||||
nm_log_warn (LOGD_DEVICE, "(%s): failed to realize device: %s",
|
||||
nm_device_get_iface (device), error->message);
|
||||
|
|
@ -1941,7 +1941,7 @@ _register_device_factory (NMDeviceFactory *factory, gpointer user_data)
|
|||
static void
|
||||
platform_link_added (NMManager *self,
|
||||
int ifindex,
|
||||
NMPlatformLink *plink)
|
||||
const NMPlatformLink *plink)
|
||||
{
|
||||
NMDeviceFactory *factory;
|
||||
NMDevice *device = NULL;
|
||||
|
|
@ -1967,9 +1967,9 @@ platform_link_added (NMManager *self,
|
|||
* device with the link's name.
|
||||
*/
|
||||
return;
|
||||
} else if (nm_device_realize (candidate, plink, &compatible, &error)) {
|
||||
} else if (nm_device_realize_start (candidate, plink, &compatible, &error)) {
|
||||
/* Success */
|
||||
nm_device_setup_finish (candidate, plink);
|
||||
nm_device_realize_finish (candidate, plink);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2016,9 +2016,9 @@ platform_link_added (NMManager *self,
|
|||
if (device) {
|
||||
if (nm_plugin_missing)
|
||||
nm_device_set_nm_plugin_missing (device, TRUE);
|
||||
if (nm_device_realize (device, plink, NULL, &error)) {
|
||||
if (nm_device_realize_start (device, plink, NULL, &error)) {
|
||||
add_device (self, device, NULL);
|
||||
nm_device_setup_finish (device, plink);
|
||||
nm_device_realize_finish (device, plink);
|
||||
} else {
|
||||
nm_log_warn (LOGD_DEVICE, "%s: failed to realize device: %s",
|
||||
plink->name, error->message);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue