device: merge branch 'th/device-parent-bgo776719'
https://bugzilla.gnome.org/show_bug.cgi?id=776719
This commit is contained in:
@@ -259,18 +259,6 @@ _update_s390_subchannels (NMDeviceEthernet *self)
|
|||||||
_notify (self, PROP_S390_SUBCHANNELS);
|
_notify (self, PROP_S390_SUBCHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
constructed (GObject *object)
|
|
||||||
{
|
|
||||||
const NMPlatformLink *pllink;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructed (object);
|
|
||||||
|
|
||||||
pllink = nm_platform_link_get (NM_PLATFORM_GET, nm_device_get_ifindex ((NMDevice *) object));
|
|
||||||
if (pllink && pllink->initialized)
|
|
||||||
_update_s390_subchannels ((NMDeviceEthernet *) object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_secrets_tries (NMDevice *device)
|
clear_secrets_tries (NMDevice *device)
|
||||||
{
|
{
|
||||||
@@ -1679,10 +1667,11 @@ carrier_changed (NMDevice *device, gboolean carrier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *device, NMPlatformLink *info)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->link_changed (device, info);
|
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->link_changed (device, pllink);
|
||||||
if (info->initialized)
|
if (pllink->initialized)
|
||||||
_update_s390_subchannels ((NMDeviceEthernet *) device);
|
_update_s390_subchannels ((NMDeviceEthernet *) device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1772,7 +1761,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||||||
|
|
||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRED_SETTING_NAME, NM_LINK_TYPE_ETHERNET)
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRED_SETTING_NAME, NM_LINK_TYPE_ETHERNET)
|
||||||
|
|
||||||
object_class->constructed = constructed;
|
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
|
@@ -46,7 +46,6 @@ _LOG_DECLARE_SELF(NMDeviceIPTunnel);
|
|||||||
|
|
||||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel,
|
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel,
|
||||||
PROP_MODE,
|
PROP_MODE,
|
||||||
PROP_PARENT,
|
|
||||||
PROP_LOCAL,
|
PROP_LOCAL,
|
||||||
PROP_REMOTE,
|
PROP_REMOTE,
|
||||||
PROP_TTL,
|
PROP_TTL,
|
||||||
@@ -60,8 +59,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel,
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMIPTunnelMode mode;
|
NMIPTunnelMode mode;
|
||||||
NMDevice *parent;
|
|
||||||
int parent_ifindex;
|
|
||||||
char *local;
|
char *local;
|
||||||
char *remote;
|
char *remote;
|
||||||
guint8 ttl;
|
guint8 ttl;
|
||||||
@@ -126,8 +123,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex)
|
|||||||
{
|
{
|
||||||
NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device);
|
NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device);
|
||||||
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
|
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
|
||||||
NMDevice *parent;
|
int parent_ifindex = 0;
|
||||||
int parent_ifindex;
|
|
||||||
in_addr_t local4, remote4;
|
in_addr_t local4, remote4;
|
||||||
struct in6_addr local6, remote6;
|
struct in6_addr local6, remote6;
|
||||||
guint8 ttl = 0, tos = 0, encap_limit = 0;
|
guint8 ttl = 0, tos = 0, encap_limit = 0;
|
||||||
@@ -137,11 +133,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex)
|
|||||||
|
|
||||||
if (ifindex <= 0) {
|
if (ifindex <= 0) {
|
||||||
clear:
|
clear:
|
||||||
if (priv->parent || priv->parent_ifindex) {
|
nm_device_parent_set_ifindex (device, 0);
|
||||||
g_clear_object (&priv->parent);
|
|
||||||
priv->parent_ifindex = 0;
|
|
||||||
_notify (self, PROP_PARENT);
|
|
||||||
}
|
|
||||||
if (priv->local) {
|
if (priv->local) {
|
||||||
g_clear_pointer (&priv->local, g_free);
|
g_clear_pointer (&priv->local, g_free);
|
||||||
_notify (self, PROP_LOCAL);
|
_notify (self, PROP_LOCAL);
|
||||||
@@ -257,14 +249,7 @@ clear:
|
|||||||
} else
|
} else
|
||||||
g_return_if_reached ();
|
g_return_if_reached ();
|
||||||
|
|
||||||
if (priv->parent_ifindex != parent_ifindex) {
|
nm_device_parent_set_ifindex (device, parent_ifindex);
|
||||||
g_clear_object (&priv->parent);
|
|
||||||
priv->parent_ifindex = parent_ifindex;
|
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex);
|
|
||||||
if (parent)
|
|
||||||
priv->parent = g_object_ref (parent);
|
|
||||||
_notify (self, PROP_PARENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->addr_family == AF_INET) {
|
if (priv->addr_family == AF_INET) {
|
||||||
if (!address_equal_pn (AF_INET, priv->local, &local4)) {
|
if (!address_equal_pn (AF_INET, priv->local, &local4)) {
|
||||||
@@ -331,9 +316,10 @@ update_properties (NMDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *device, NMPlatformLink *info)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, info);
|
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->link_changed (device, pllink);
|
||||||
update_properties (device);
|
update_properties (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,8 +368,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) != priv->mode)
|
if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) != priv->mode)
|
||||||
g_object_set (G_OBJECT (s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL);
|
g_object_set (G_OBJECT (s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL);
|
||||||
|
|
||||||
if (priv->parent_ifindex > 0)
|
parent = nm_device_parent_get_device (device);
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex);
|
|
||||||
|
|
||||||
/* Update parent in the connection; default to parent's interface name */
|
/* Update parent in the connection; default to parent's interface name */
|
||||||
if (parent) {
|
if (parent) {
|
||||||
@@ -512,7 +497,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||||||
/* Check parent interface; could be an interface name or a UUID */
|
/* Check parent interface; could be an interface name or a UUID */
|
||||||
parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel);
|
parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (!match_parent (priv->parent, parent))
|
if (!match_parent (nm_device_parent_get_device (device), parent))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,14 +744,6 @@ create_and_realize (NMDevice *device,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
|
||||||
{
|
|
||||||
NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink);
|
|
||||||
|
|
||||||
update_properties (device);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
||||||
{
|
{
|
||||||
@@ -806,16 +783,11 @@ get_property (GObject *object, guint prop_id,
|
|||||||
GValue *value, GParamSpec *pspec)
|
GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object);
|
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object);
|
||||||
NMDevice *parent;
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
g_value_set_uint (value, priv->mode);
|
g_value_set_uint (value, priv->mode);
|
||||||
break;
|
break;
|
||||||
case PROP_PARENT:
|
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex);
|
|
||||||
nm_utils_g_value_set_object_path (value, parent);
|
|
||||||
break;
|
|
||||||
case PROP_LOCAL:
|
case PROP_LOCAL:
|
||||||
g_value_set_string (value, priv->local);
|
g_value_set_string (value, priv->local);
|
||||||
break;
|
break;
|
||||||
@@ -902,7 +874,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
|
|||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||||
device_class->realize_start_notify = realize_start_notify;
|
|
||||||
device_class->unrealize_notify = unrealize_notify;
|
device_class->unrealize_notify = unrealize_notify;
|
||||||
|
|
||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass,
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass,
|
||||||
@@ -919,12 +890,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
|
|||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS);
|
G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
obj_properties[PROP_PARENT] =
|
|
||||||
g_param_spec_string (NM_DEVICE_IP_TUNNEL_PARENT, "", "",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
obj_properties[PROP_LOCAL] =
|
obj_properties[PROP_LOCAL] =
|
||||||
g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "",
|
g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "",
|
||||||
NULL,
|
NULL,
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
#define NM_DEVICE_IP_TUNNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelClass))
|
#define NM_DEVICE_IP_TUNNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelClass))
|
||||||
|
|
||||||
#define NM_DEVICE_IP_TUNNEL_MODE "mode"
|
#define NM_DEVICE_IP_TUNNEL_MODE "mode"
|
||||||
#define NM_DEVICE_IP_TUNNEL_PARENT "parent"
|
|
||||||
#define NM_DEVICE_IP_TUNNEL_LOCAL "local"
|
#define NM_DEVICE_IP_TUNNEL_LOCAL "local"
|
||||||
#define NM_DEVICE_IP_TUNNEL_REMOTE "remote"
|
#define NM_DEVICE_IP_TUNNEL_REMOTE "remote"
|
||||||
#define NM_DEVICE_IP_TUNNEL_TTL "ttl"
|
#define NM_DEVICE_IP_TUNNEL_TTL "ttl"
|
||||||
@@ -43,6 +42,9 @@
|
|||||||
#define NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT "encapsulation-limit"
|
#define NM_DEVICE_IP_TUNNEL_ENCAPSULATION_LIMIT "encapsulation-limit"
|
||||||
#define NM_DEVICE_IP_TUNNEL_FLOW_LABEL "flow-label"
|
#define NM_DEVICE_IP_TUNNEL_FLOW_LABEL "flow-label"
|
||||||
|
|
||||||
|
/* defined in the parent class, but exposed on D-Bus by the subclass. */
|
||||||
|
#define NM_DEVICE_IP_TUNNEL_PARENT NM_DEVICE_PARENT
|
||||||
|
|
||||||
typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel;
|
typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel;
|
||||||
typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass;
|
typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass;
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
|
|
||||||
#define _LOG_DECLARE_SELF(t) \
|
#define _LOG_DECLARE_SELF(t) \
|
||||||
inline static NMDevice * \
|
_nm_unused inline static NMDevice * \
|
||||||
_nm_device_log_self_to_device (t *self) \
|
_nm_device_log_self_to_device (t *self) \
|
||||||
{ \
|
{ \
|
||||||
return (NMDevice *) self; \
|
return (NMDevice *) self; \
|
||||||
|
@@ -44,16 +44,13 @@ _LOG_DECLARE_SELF(NMDeviceMacvlan);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacvlan,
|
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacvlan,
|
||||||
PROP_PARENT,
|
|
||||||
PROP_MODE,
|
PROP_MODE,
|
||||||
PROP_NO_PROMISC,
|
PROP_NO_PROMISC,
|
||||||
PROP_TAP,
|
PROP_TAP,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int parent_ifindex;
|
|
||||||
gulong parent_state_id;
|
gulong parent_state_id;
|
||||||
NMDevice *parent;
|
|
||||||
NMPlatformLnkMacvlan props;
|
NMPlatformLnkMacvlan props;
|
||||||
} NMDeviceMacvlanPrivate;
|
} NMDeviceMacvlanPrivate;
|
||||||
|
|
||||||
@@ -141,21 +138,24 @@ parent_state_changed (NMDevice *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_macvlan_set_parent (NMDeviceMacvlan *self, NMDevice *parent)
|
parent_changed_notify (NMDevice *device,
|
||||||
{
|
int old_ifindex,
|
||||||
|
NMDevice *old_parent,
|
||||||
|
int new_ifindex,
|
||||||
|
NMDevice *new_parent)
|
||||||
|
{
|
||||||
|
NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device);
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self);
|
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self);
|
||||||
NMDevice *device = NM_DEVICE (self);
|
|
||||||
|
|
||||||
if (parent == priv->parent)
|
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->parent_changed_notify (device, old_ifindex, old_parent, new_ifindex, new_parent);
|
||||||
return;
|
|
||||||
|
|
||||||
nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id);
|
/* note that @self doesn't have to clear @parent_state_id on dispose,
|
||||||
|
* because NMDevice's dispose() will unset the parent, which in turn calls
|
||||||
|
* parent_changed_notify(). */
|
||||||
|
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||||
|
|
||||||
g_clear_object (&priv->parent);
|
if (new_parent) {
|
||||||
|
priv->parent_state_id = g_signal_connect (new_parent,
|
||||||
if (parent) {
|
|
||||||
priv->parent = g_object_ref (parent);
|
|
||||||
priv->parent_state_id = g_signal_connect (priv->parent,
|
|
||||||
"state-changed",
|
"state-changed",
|
||||||
G_CALLBACK (parent_state_changed),
|
G_CALLBACK (parent_state_changed),
|
||||||
device);
|
device);
|
||||||
@@ -163,15 +163,16 @@ nm_device_macvlan_set_parent (NMDeviceMacvlan *self, NMDevice *parent)
|
|||||||
/* Set parent-dependent unmanaged flag */
|
/* Set parent-dependent unmanaged flag */
|
||||||
nm_device_set_unmanaged_by_flags (device,
|
nm_device_set_unmanaged_by_flags (device,
|
||||||
NM_UNMANAGED_PARENT,
|
NM_UNMANAGED_PARENT,
|
||||||
!nm_device_get_managed (parent, FALSE),
|
!nm_device_get_managed (new_parent, FALSE),
|
||||||
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED);
|
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recheck availability now that the parent has changed */
|
if (new_ifindex > 0) {
|
||||||
nm_device_queue_recheck_available (device,
|
/* Recheck availability now that the parent has changed */
|
||||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED,
|
nm_device_queue_recheck_available (device,
|
||||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED);
|
NM_DEVICE_STATE_REASON_PARENT_CHANGED,
|
||||||
_notify (self, PROP_PARENT);
|
NM_DEVICE_STATE_REASON_PARENT_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -182,7 +183,6 @@ update_properties (NMDevice *device)
|
|||||||
GObject *object = G_OBJECT (device);
|
GObject *object = G_OBJECT (device);
|
||||||
const NMPlatformLnkMacvlan *props;
|
const NMPlatformLnkMacvlan *props;
|
||||||
const NMPlatformLink *plink;
|
const NMPlatformLink *plink;
|
||||||
NMDevice *parent = NULL;
|
|
||||||
|
|
||||||
if (priv->props.tap)
|
if (priv->props.tap)
|
||||||
props = nm_platform_link_get_lnk_macvtap (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink);
|
props = nm_platform_link_get_lnk_macvtap (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink);
|
||||||
@@ -196,25 +196,22 @@ update_properties (NMDevice *device)
|
|||||||
|
|
||||||
g_object_freeze_notify (object);
|
g_object_freeze_notify (object);
|
||||||
|
|
||||||
if (priv->parent_ifindex != plink->parent) {
|
nm_device_parent_set_ifindex (device, plink->parent);
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent);
|
|
||||||
nm_device_macvlan_set_parent (self, parent);
|
|
||||||
}
|
|
||||||
if (priv->props.mode != props->mode)
|
if (priv->props.mode != props->mode)
|
||||||
_notify (self, PROP_MODE);
|
_notify (self, PROP_MODE);
|
||||||
if (priv->props.no_promisc != props->no_promisc)
|
if (priv->props.no_promisc != props->no_promisc)
|
||||||
_notify (self, PROP_NO_PROMISC);
|
_notify (self, PROP_NO_PROMISC);
|
||||||
|
|
||||||
priv->parent_ifindex = plink->parent;
|
|
||||||
priv->props = *props;
|
priv->props = *props;
|
||||||
|
|
||||||
g_object_thaw_notify (object);
|
g_object_thaw_notify (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *device, NMPlatformLink *info)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info);
|
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, pllink);
|
||||||
update_properties (device);
|
update_properties (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,17 +229,17 @@ create_and_realize (NMDevice *device,
|
|||||||
int parent_ifindex;
|
int parent_ifindex;
|
||||||
|
|
||||||
s_macvlan = nm_connection_get_setting_macvlan (connection);
|
s_macvlan = nm_connection_get_setting_macvlan (connection);
|
||||||
g_assert (s_macvlan);
|
g_return_val_if_fail (s_macvlan, FALSE);
|
||||||
|
|
||||||
if (!parent) {
|
parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0;
|
||||||
|
|
||||||
|
if (parent_ifindex <= 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||||
"MACVLAN devices can not be created without a parent interface");
|
"MACVLAN devices can not be created without a parent interface");
|
||||||
|
g_return_val_if_fail (!parent, FALSE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent_ifindex = nm_device_get_ifindex (parent);
|
|
||||||
g_warn_if_fail (parent_ifindex > 0);
|
|
||||||
|
|
||||||
lnk.mode = setting_mode_to_platform (nm_setting_macvlan_get_mode (s_macvlan));
|
lnk.mode = setting_mode_to_platform (nm_setting_macvlan_get_mode (s_macvlan));
|
||||||
if (!lnk.mode) {
|
if (!lnk.mode) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||||
@@ -282,45 +279,23 @@ get_generic_capabilities (NMDevice *dev)
|
|||||||
static gboolean
|
static gboolean
|
||||||
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
||||||
{
|
{
|
||||||
if (!NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device)->parent)
|
if (!nm_device_parent_get_device (device))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->is_available (device, flags);
|
return NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->is_available (device, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
notify_new_device_added (NMDevice *device, NMDevice *new_device)
|
|
||||||
{
|
|
||||||
NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device);
|
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self);
|
|
||||||
|
|
||||||
if (priv->parent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!nm_device_is_real (device))
|
|
||||||
return;
|
|
||||||
|
|
||||||
update_properties (device);
|
|
||||||
|
|
||||||
if ( priv->parent_ifindex <= 0
|
|
||||||
|| nm_device_get_ifindex (new_device) != priv->parent_ifindex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv->parent_ifindex = nm_device_get_ifindex (new_device);
|
|
||||||
nm_device_macvlan_set_parent (self, new_device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
match_parent (NMDeviceMacvlan *self, const char *parent)
|
match_parent (NMDeviceMacvlan *self, const char *parent)
|
||||||
{
|
{
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (self);
|
NMDevice *parent_device;
|
||||||
|
|
||||||
g_return_val_if_fail (parent != NULL, FALSE);
|
g_return_val_if_fail (parent != NULL, FALSE);
|
||||||
|
|
||||||
if (!priv->parent)
|
parent_device = nm_device_parent_get_device (NM_DEVICE (self));
|
||||||
|
if (!parent_device)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (nm_utils_is_uuid (parent)) {
|
if (nm_utils_is_uuid (parent)) {
|
||||||
@@ -331,7 +306,7 @@ match_parent (NMDeviceMacvlan *self, const char *parent)
|
|||||||
* device has that connection activated.
|
* device has that connection activated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parent_req = nm_device_get_act_request (priv->parent);
|
parent_req = nm_device_get_act_request (parent_device);
|
||||||
if (!parent_req)
|
if (!parent_req)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -343,7 +318,7 @@ match_parent (NMDeviceMacvlan *self, const char *parent)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* interface name */
|
/* interface name */
|
||||||
if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0)
|
if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,8 +328,8 @@ match_parent (NMDeviceMacvlan *self, const char *parent)
|
|||||||
static gboolean
|
static gboolean
|
||||||
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
||||||
{
|
{
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device);
|
|
||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
|
NMDevice *parent_device;
|
||||||
const char *setting_mac;
|
const char *setting_mac;
|
||||||
const char *parent_mac;
|
const char *parent_mac;
|
||||||
|
|
||||||
@@ -366,10 +341,11 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw
|
|||||||
if (!setting_mac)
|
if (!setting_mac)
|
||||||
return !fail_if_no_hwaddr;
|
return !fail_if_no_hwaddr;
|
||||||
|
|
||||||
if (!priv->parent)
|
parent_device = nm_device_parent_get_device (device);
|
||||||
|
if (!parent_device)
|
||||||
return !fail_if_no_hwaddr;
|
return !fail_if_no_hwaddr;
|
||||||
|
|
||||||
parent_mac = nm_device_get_permanent_hw_address (priv->parent);
|
parent_mac = nm_device_get_permanent_hw_address (parent_device);
|
||||||
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +433,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
{
|
{
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device);
|
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device);
|
||||||
NMSettingMacvlan *s_macvlan = nm_connection_get_setting_macvlan (connection);
|
NMSettingMacvlan *s_macvlan = nm_connection_get_setting_macvlan (connection);
|
||||||
|
NMDevice *parent_device;
|
||||||
const char *setting_parent, *new_parent;
|
const char *setting_parent, *new_parent;
|
||||||
int new_mode;
|
int new_mode;
|
||||||
|
|
||||||
@@ -477,15 +454,16 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
g_object_set (s_macvlan, NM_SETTING_MACVLAN_TAP, !!priv->props.tap, NULL);
|
g_object_set (s_macvlan, NM_SETTING_MACVLAN_TAP, !!priv->props.tap, NULL);
|
||||||
|
|
||||||
/* Update parent in the connection; default to parent's interface name */
|
/* Update parent in the connection; default to parent's interface name */
|
||||||
if (priv->parent) {
|
parent_device = nm_device_parent_get_device (device);
|
||||||
new_parent = nm_device_get_iface (priv->parent);
|
if (parent_device) {
|
||||||
|
new_parent = nm_device_get_iface (parent_device);
|
||||||
setting_parent = nm_setting_macvlan_get_parent (s_macvlan);
|
setting_parent = nm_setting_macvlan_get_parent (s_macvlan);
|
||||||
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
||||||
NMConnection *parent_connection;
|
NMConnection *parent_connection;
|
||||||
|
|
||||||
/* Don't change a parent specified by UUID if it's still valid */
|
/* Don't change a parent specified by UUID if it's still valid */
|
||||||
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
|
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
|
||||||
if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection))
|
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection))
|
||||||
new_parent = NULL;
|
new_parent = NULL;
|
||||||
}
|
}
|
||||||
if (new_parent)
|
if (new_parent)
|
||||||
@@ -529,14 +507,6 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
|
||||||
{
|
|
||||||
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->realize_start_notify (device, plink);
|
|
||||||
|
|
||||||
update_properties (device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -544,16 +514,8 @@ get_property (GObject *object, guint prop_id,
|
|||||||
GValue *value, GParamSpec *pspec)
|
GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) object);
|
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) object);
|
||||||
NMDevice *parent;
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PARENT:
|
|
||||||
if (priv->parent_ifindex > 0)
|
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex);
|
|
||||||
else
|
|
||||||
parent = NULL;
|
|
||||||
nm_utils_g_value_set_object_path (value, parent);
|
|
||||||
break;
|
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
g_value_set_string (value, platform_mode_to_string (priv->props.mode));
|
g_value_set_string (value, platform_mode_to_string (priv->props.mode));
|
||||||
break;
|
break;
|
||||||
@@ -591,14 +553,6 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dispose (GObject *object)
|
|
||||||
{
|
|
||||||
nm_device_macvlan_set_parent (NM_DEVICE_MACVLAN (object), NULL);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_macvlan_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
||||||
{
|
{
|
||||||
@@ -607,7 +561,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||||||
|
|
||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP)
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP)
|
||||||
|
|
||||||
object_class->dispose = dispose;
|
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
|
|
||||||
@@ -620,16 +573,9 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||||||
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||||
device_class->is_available = is_available;
|
device_class->is_available = is_available;
|
||||||
device_class->link_changed = link_changed;
|
device_class->link_changed = link_changed;
|
||||||
device_class->notify_new_device_added = notify_new_device_added;
|
device_class->parent_changed_notify = parent_changed_notify;
|
||||||
device_class->realize_start_notify = realize_start_notify;
|
|
||||||
device_class->update_connection = update_connection;
|
device_class->update_connection = update_connection;
|
||||||
|
|
||||||
obj_properties[PROP_PARENT] =
|
|
||||||
g_param_spec_string (NM_DEVICE_MACVLAN_PARENT, "", "",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
obj_properties[PROP_MODE] =
|
obj_properties[PROP_MODE] =
|
||||||
g_param_spec_string (NM_DEVICE_MACVLAN_MODE, "", "",
|
g_param_spec_string (NM_DEVICE_MACVLAN_MODE, "", "",
|
||||||
NULL,
|
NULL,
|
||||||
|
@@ -30,11 +30,13 @@
|
|||||||
#define NM_IS_DEVICE_MACVLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MACVLAN))
|
#define NM_IS_DEVICE_MACVLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_MACVLAN))
|
||||||
#define NM_DEVICE_MACVLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanClass))
|
#define NM_DEVICE_MACVLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanClass))
|
||||||
|
|
||||||
#define NM_DEVICE_MACVLAN_PARENT "parent"
|
|
||||||
#define NM_DEVICE_MACVLAN_MODE "mode"
|
#define NM_DEVICE_MACVLAN_MODE "mode"
|
||||||
#define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc"
|
#define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc"
|
||||||
#define NM_DEVICE_MACVLAN_TAP "tap"
|
#define NM_DEVICE_MACVLAN_TAP "tap"
|
||||||
|
|
||||||
|
/* defined in the parent class, but exposed on D-Bus by the subclass. */
|
||||||
|
#define NM_DEVICE_MACVLAN_PARENT NM_DEVICE_PARENT
|
||||||
|
|
||||||
typedef struct _NMDeviceMacvlan NMDeviceMacvlan;
|
typedef struct _NMDeviceMacvlan NMDeviceMacvlan;
|
||||||
typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass;
|
typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass;
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@ G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reload_tun_properties (NMDeviceTun *self)
|
update_properties (NMDeviceTun *self)
|
||||||
{
|
{
|
||||||
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
|
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
|
||||||
GObject *object = G_OBJECT (self);
|
GObject *object = G_OBJECT (self);
|
||||||
@@ -122,11 +122,11 @@ get_generic_capabilities (NMDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *device, NMPlatformLink *info)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, info);
|
NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, pllink);
|
||||||
|
update_properties (NM_DEVICE_TUN (device));
|
||||||
reload_tun_properties (NM_DEVICE_TUN (device));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -251,13 +251,6 @@ create_and_realize (NMDevice *device,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
|
||||||
{
|
|
||||||
NM_DEVICE_CLASS (nm_device_tun_parent_class)->realize_start_notify (device, plink);
|
|
||||||
reload_tun_properties ((NMDeviceTun *) device);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
||||||
{
|
{
|
||||||
@@ -438,7 +431,6 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
|
|||||||
device_class->check_connection_compatible = check_connection_compatible;
|
device_class->check_connection_compatible = check_connection_compatible;
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->realize_start_notify = realize_start_notify;
|
|
||||||
device_class->unrealize_notify = unrealize_notify;
|
device_class->unrealize_notify = unrealize_notify;
|
||||||
device_class->update_connection = update_connection;
|
device_class->update_connection = update_connection;
|
||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
|
@@ -23,9 +23,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <linux/sockios.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
#include "nm-device-veth.h"
|
#include "nm-device-veth.h"
|
||||||
#include "nm-device-private.h"
|
#include "nm-device-private.h"
|
||||||
@@ -41,8 +38,6 @@ _LOG_DECLARE_SELF(NMDeviceVeth);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMDevice *peer;
|
|
||||||
gboolean ever_had_peer;
|
|
||||||
} NMDeviceVethPrivate;
|
} NMDeviceVethPrivate;
|
||||||
|
|
||||||
struct _NMDeviceVeth {
|
struct _NMDeviceVeth {
|
||||||
@@ -67,42 +62,23 @@ G_DEFINE_TYPE (NMDeviceVeth, nm_device_veth, NM_TYPE_DEVICE_ETHERNET)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_peer (NMDeviceVeth *self, NMDevice *peer)
|
update_properties (NMDevice *device)
|
||||||
{
|
{
|
||||||
NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self);
|
NMDevice *peer;
|
||||||
|
int ifindex, peer_ifindex;
|
||||||
|
|
||||||
if (!priv->peer) {
|
ifindex = nm_device_get_ifindex (device);
|
||||||
priv->ever_had_peer = TRUE;
|
|
||||||
priv->peer = peer;
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (peer), (gpointer *) &priv->peer);
|
|
||||||
|
|
||||||
_notify (self, PROP_PEER);
|
if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex, &peer_ifindex))
|
||||||
}
|
peer_ifindex = 0;
|
||||||
}
|
|
||||||
|
|
||||||
static NMDevice *
|
nm_device_parent_set_ifindex (device, peer_ifindex);
|
||||||
get_peer (NMDeviceVeth *self)
|
|
||||||
{
|
|
||||||
NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self);
|
|
||||||
NMDevice *device = NM_DEVICE (self), *peer = NULL;
|
|
||||||
int peer_ifindex;
|
|
||||||
|
|
||||||
if (priv->ever_had_peer)
|
peer = nm_device_parent_get_device (device);
|
||||||
return priv->peer;
|
if ( peer
|
||||||
|
&& NM_IS_DEVICE_VETH (peer)
|
||||||
if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) {
|
&& nm_device_parent_get_ifindex (peer) <= 0)
|
||||||
_LOGW (LOGD_PLATFORM, "could not read veth properties");
|
update_properties (peer);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (peer_ifindex > 0)
|
|
||||||
peer = nm_manager_get_device_by_ifindex (nm_manager_get (), peer_ifindex);
|
|
||||||
if (peer && NM_IS_DEVICE_VETH (peer)) {
|
|
||||||
set_peer (self, peer);
|
|
||||||
set_peer (NM_DEVICE_VETH (peer), device);
|
|
||||||
}
|
|
||||||
|
|
||||||
return priv->peer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -115,6 +91,14 @@ can_unmanaged_external_down (NMDevice *self)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
|
{
|
||||||
|
NM_DEVICE_CLASS (nm_device_veth_parent_class)->link_changed (device, pllink);
|
||||||
|
update_properties (device);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -123,17 +107,10 @@ nm_device_veth_init (NMDeviceVeth *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dispose (GObject *object)
|
notify (GObject *object, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMDeviceVeth *self = NM_DEVICE_VETH (object);
|
if (nm_streq (pspec->name, NM_DEVICE_PARENT))
|
||||||
NMDeviceVethPrivate *priv = NM_DEVICE_VETH_GET_PRIVATE (self);
|
_notify (NM_DEVICE_VETH (object), PROP_PEER);
|
||||||
|
|
||||||
if (priv->peer) {
|
|
||||||
g_object_remove_weak_pointer (G_OBJECT (priv->peer), (gpointer *) &priv->peer);
|
|
||||||
priv->peer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_veth_parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -145,7 +122,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PEER:
|
case PROP_PEER:
|
||||||
peer = get_peer (self);
|
peer = nm_device_parent_get_device (NM_DEVICE (self));
|
||||||
|
if (peer && !NM_IS_DEVICE_VETH (peer))
|
||||||
|
peer = NULL;
|
||||||
nm_utils_g_value_set_object_path (value, peer);
|
nm_utils_g_value_set_object_path (value, peer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -163,9 +142,10 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
|
|||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VETH)
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VETH)
|
||||||
|
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->dispose = dispose;
|
object_class->notify = notify;
|
||||||
|
|
||||||
device_class->can_unmanaged_external_down = can_unmanaged_external_down;
|
device_class->can_unmanaged_external_down = can_unmanaged_external_down;
|
||||||
|
device_class->link_changed = link_changed;
|
||||||
|
|
||||||
obj_properties[PROP_PEER] =
|
obj_properties[PROP_PEER] =
|
||||||
g_param_spec_string (NM_DEVICE_VETH_PEER, "", "",
|
g_param_spec_string (NM_DEVICE_VETH_PEER, "", "",
|
||||||
|
@@ -45,12 +45,10 @@ _LOG_DECLARE_SELF(NMDeviceVlan);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVlan,
|
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVlan,
|
||||||
PROP_PARENT,
|
|
||||||
PROP_VLAN_ID,
|
PROP_VLAN_ID,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMDevice *parent;
|
|
||||||
gulong parent_state_id;
|
gulong parent_state_id;
|
||||||
gulong parent_hwaddr_id;
|
gulong parent_hwaddr_id;
|
||||||
guint vlan_id;
|
guint vlan_id;
|
||||||
@@ -128,41 +126,46 @@ parent_hwaddr_maybe_changed (NMDevice *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent)
|
parent_changed_notify (NMDevice *device,
|
||||||
|
int old_ifindex,
|
||||||
|
NMDevice *old_parent,
|
||||||
|
int new_ifindex,
|
||||||
|
NMDevice *new_parent)
|
||||||
{
|
{
|
||||||
|
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||||
NMDevice *device = NM_DEVICE (self);
|
|
||||||
|
|
||||||
if (parent == priv->parent)
|
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->parent_changed_notify (device, old_ifindex, old_parent, new_ifindex, new_parent);
|
||||||
return;
|
|
||||||
|
|
||||||
nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id);
|
/* note that @self doesn't have to clear @parent_state_id on dispose,
|
||||||
nm_clear_g_signal_handler (priv->parent, &priv->parent_hwaddr_id);
|
* because NMDevice's dispose() will unset the parent, which in turn calls
|
||||||
g_clear_object (&priv->parent);
|
* parent_changed_notify(). */
|
||||||
|
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||||
|
nm_clear_g_signal_handler (old_parent, &priv->parent_hwaddr_id);
|
||||||
|
|
||||||
if (parent) {
|
if (new_parent) {
|
||||||
priv->parent = g_object_ref (parent);
|
priv->parent_state_id = g_signal_connect (new_parent,
|
||||||
priv->parent_state_id = g_signal_connect (priv->parent,
|
|
||||||
NM_DEVICE_STATE_CHANGED,
|
NM_DEVICE_STATE_CHANGED,
|
||||||
G_CALLBACK (parent_state_changed),
|
G_CALLBACK (parent_state_changed),
|
||||||
device);
|
device);
|
||||||
|
|
||||||
priv->parent_hwaddr_id = g_signal_connect (priv->parent, "notify::" NM_DEVICE_HW_ADDRESS,
|
priv->parent_hwaddr_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_HW_ADDRESS,
|
||||||
G_CALLBACK (parent_hwaddr_maybe_changed), device);
|
G_CALLBACK (parent_hwaddr_maybe_changed), device);
|
||||||
parent_hwaddr_maybe_changed (parent, NULL, self);
|
parent_hwaddr_maybe_changed (new_parent, NULL, self);
|
||||||
|
|
||||||
/* Set parent-dependent unmanaged flag */
|
/* Set parent-dependent unmanaged flag */
|
||||||
nm_device_set_unmanaged_by_flags (device,
|
nm_device_set_unmanaged_by_flags (device,
|
||||||
NM_UNMANAGED_PARENT,
|
NM_UNMANAGED_PARENT,
|
||||||
!nm_device_get_managed (parent, FALSE),
|
!nm_device_get_managed (new_parent, FALSE),
|
||||||
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED);
|
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recheck availability now that the parent has changed */
|
/* Recheck availability now that the parent has changed */
|
||||||
nm_device_queue_recheck_available (device,
|
if (new_ifindex > 0) {
|
||||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED,
|
nm_device_queue_recheck_available (device,
|
||||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED);
|
NM_DEVICE_STATE_REASON_PARENT_CHANGED,
|
||||||
_notify (self, PROP_PARENT);
|
NM_DEVICE_STATE_REASON_PARENT_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -171,8 +174,8 @@ update_properties (NMDevice *device)
|
|||||||
NMDeviceVlanPrivate *priv;
|
NMDeviceVlanPrivate *priv;
|
||||||
const NMPlatformLink *plink = NULL;
|
const NMPlatformLink *plink = NULL;
|
||||||
const NMPlatformLnkVlan *plnk = NULL;
|
const NMPlatformLnkVlan *plnk = NULL;
|
||||||
NMDevice *parent = NULL;
|
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
int parent_ifindex = 0;
|
||||||
guint vlan_id;
|
guint vlan_id;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_DEVICE_VLAN (device));
|
g_return_if_fail (NM_IS_DEVICE_VLAN (device));
|
||||||
@@ -183,14 +186,14 @@ update_properties (NMDevice *device)
|
|||||||
|
|
||||||
if (ifindex > 0)
|
if (ifindex > 0)
|
||||||
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, ifindex, &plink);
|
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, ifindex, &plink);
|
||||||
|
|
||||||
if ( plnk
|
if ( plnk
|
||||||
&& plink->parent
|
&& plink->parent > 0)
|
||||||
&& plink->parent != NM_PLATFORM_LINK_OTHER_NETNS)
|
parent_ifindex = plink->parent;
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent);
|
|
||||||
|
|
||||||
g_object_freeze_notify ((GObject *) device);
|
g_object_freeze_notify ((GObject *) device);
|
||||||
|
|
||||||
nm_device_vlan_set_parent ((NMDeviceVlan *) device, parent);
|
nm_device_parent_set_ifindex (device, parent_ifindex);
|
||||||
|
|
||||||
vlan_id = plnk ? plnk->id : 0;
|
vlan_id = plnk ? plnk->id : 0;
|
||||||
if (vlan_id != priv->vlan_id) {
|
if (vlan_id != priv->vlan_id) {
|
||||||
@@ -202,10 +205,10 @@ update_properties (NMDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink);
|
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->link_changed (device, pllink);
|
||||||
|
|
||||||
update_properties (device);
|
update_properties (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,8 +263,7 @@ create_and_realize (NMDevice *device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_warn_if_fail (priv->parent == NULL);
|
nm_device_parent_set_ifindex (device, parent_ifindex);
|
||||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent);
|
|
||||||
if (vlan_id != priv->vlan_id) {
|
if (vlan_id != priv->vlan_id) {
|
||||||
priv->vlan_id = vlan_id;
|
priv->vlan_id = vlan_id;
|
||||||
_notify ((NMDeviceVlan *) device, PROP_VLAN_ID);
|
_notify ((NMDeviceVlan *) device, PROP_VLAN_ID);
|
||||||
@@ -273,17 +275,21 @@ create_and_realize (NMDevice *device,
|
|||||||
static void
|
static void
|
||||||
unrealize_notify (NMDevice *device)
|
unrealize_notify (NMDevice *device)
|
||||||
{
|
{
|
||||||
|
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
||||||
|
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||||
|
|
||||||
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device);
|
NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device);
|
||||||
|
|
||||||
NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device)->vlan_id = 0;
|
if (priv->vlan_id != 0) {
|
||||||
_notify ((NMDeviceVlan *) device, PROP_VLAN_ID);
|
priv->vlan_id = 0;
|
||||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), NULL);
|
_notify (self, PROP_VLAN_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMDeviceCapabilities
|
static NMDeviceCapabilities
|
||||||
get_generic_capabilities (NMDevice *dev)
|
get_generic_capabilities (NMDevice *device)
|
||||||
{
|
{
|
||||||
/* We assume VLAN interfaces always support carrier detect */
|
/* We assume VLAN interfaces always support carrier detect */
|
||||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
||||||
@@ -294,47 +300,22 @@ get_generic_capabilities (NMDevice *dev)
|
|||||||
static gboolean
|
static gboolean
|
||||||
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
||||||
{
|
{
|
||||||
if (!NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device)->parent)
|
if (!nm_device_parent_get_device (device))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags);
|
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
notify_new_device_added (NMDevice *device, NMDevice *new_device)
|
|
||||||
{
|
|
||||||
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
|
|
||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
|
||||||
const NMPlatformLink *plink;
|
|
||||||
const NMPlatformLnkVlan *plnk;
|
|
||||||
|
|
||||||
if (priv->parent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!nm_device_is_real (device))
|
|
||||||
return;
|
|
||||||
|
|
||||||
plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink);
|
|
||||||
if (!plnk)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( plink->parent <= 0
|
|
||||||
|| nm_device_get_ifindex (new_device) != plink->parent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
nm_device_vlan_set_parent (self, new_device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
match_parent (NMDeviceVlan *self, const char *parent)
|
match_parent (NMDeviceVlan *self, const char *parent)
|
||||||
{
|
{
|
||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
NMDevice *parent_device;
|
||||||
|
|
||||||
g_return_val_if_fail (parent != NULL, FALSE);
|
g_return_val_if_fail (parent != NULL, FALSE);
|
||||||
|
|
||||||
if (!priv->parent)
|
parent_device = nm_device_parent_get_device (NM_DEVICE (self));
|
||||||
|
if (!parent_device)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (nm_utils_is_uuid (parent)) {
|
if (nm_utils_is_uuid (parent)) {
|
||||||
@@ -345,7 +326,7 @@ match_parent (NMDeviceVlan *self, const char *parent)
|
|||||||
* device has that connection activated.
|
* device has that connection activated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parent_req = nm_device_get_act_request (priv->parent);
|
parent_req = nm_device_get_act_request (parent_device);
|
||||||
if (!parent_req)
|
if (!parent_req)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -357,7 +338,7 @@ match_parent (NMDeviceVlan *self, const char *parent)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* interface name */
|
/* interface name */
|
||||||
if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0)
|
if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,8 +348,8 @@ match_parent (NMDeviceVlan *self, const char *parent)
|
|||||||
static gboolean
|
static gboolean
|
||||||
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
||||||
{
|
{
|
||||||
NMDeviceVlanPrivate *priv;
|
|
||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
|
NMDevice *parent_device;
|
||||||
const char *setting_mac;
|
const char *setting_mac;
|
||||||
const char *parent_mac;
|
const char *parent_mac;
|
||||||
|
|
||||||
@@ -380,11 +361,11 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw
|
|||||||
if (!setting_mac)
|
if (!setting_mac)
|
||||||
return !fail_if_no_hwaddr;
|
return !fail_if_no_hwaddr;
|
||||||
|
|
||||||
priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) device);
|
parent_device = nm_device_parent_get_device (device);
|
||||||
if (!priv->parent)
|
if (!parent_device)
|
||||||
return !fail_if_no_hwaddr;
|
return !fail_if_no_hwaddr;
|
||||||
|
|
||||||
parent_mac = nm_device_get_permanent_hw_address (priv->parent);
|
parent_mac = nm_device_get_permanent_hw_address (parent_device);
|
||||||
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,6 +462,7 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
const char *setting_parent, *new_parent;
|
const char *setting_parent, *new_parent;
|
||||||
const NMPlatformLink *plink;
|
const NMPlatformLink *plink;
|
||||||
const NMPObject *polnk;
|
const NMPObject *polnk;
|
||||||
|
NMDevice *parent_device;
|
||||||
guint vlan_id;
|
guint vlan_id;
|
||||||
guint vlan_flags;
|
guint vlan_flags;
|
||||||
|
|
||||||
@@ -499,18 +481,19 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL);
|
g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL);
|
||||||
|
|
||||||
/* Update parent in the connection; default to parent's interface name */
|
/* Update parent in the connection; default to parent's interface name */
|
||||||
if ( priv->parent
|
parent_device = nm_device_parent_get_device (device);
|
||||||
|
if ( parent_device
|
||||||
&& polnk
|
&& polnk
|
||||||
&& plink->parent > 0
|
&& plink->parent > 0
|
||||||
&& nm_device_get_ifindex (priv->parent) == plink->parent) {
|
&& nm_device_get_ifindex (parent_device) == plink->parent) {
|
||||||
new_parent = nm_device_get_iface (priv->parent);
|
new_parent = nm_device_get_iface (parent_device);
|
||||||
setting_parent = nm_setting_vlan_get_parent (s_vlan);
|
setting_parent = nm_setting_vlan_get_parent (s_vlan);
|
||||||
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
||||||
NMConnection *parent_connection;
|
NMConnection *parent_connection;
|
||||||
|
|
||||||
/* Don't change a parent specified by UUID if it's still valid */
|
/* Don't change a parent specified by UUID if it's still valid */
|
||||||
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
|
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
|
||||||
if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection))
|
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection))
|
||||||
new_parent = NULL;
|
new_parent = NULL;
|
||||||
}
|
}
|
||||||
if (new_parent)
|
if (new_parent)
|
||||||
@@ -539,26 +522,27 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMActStageReturn
|
static NMActStageReturn
|
||||||
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
||||||
{
|
{
|
||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) dev);
|
NMDevice *parent_device;
|
||||||
NMSettingVlan *s_vlan;
|
NMSettingVlan *s_vlan;
|
||||||
NMActStageReturn ret;
|
NMActStageReturn ret;
|
||||||
|
|
||||||
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||||
|
|
||||||
ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (dev, reason);
|
ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (device, reason);
|
||||||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE))
|
if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
|
||||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
|
|
||||||
/* Change MAC address to parent's one if needed */
|
/* Change MAC address to parent's one if needed */
|
||||||
if (priv->parent)
|
parent_device = nm_device_parent_get_device (device);
|
||||||
parent_hwaddr_maybe_changed (priv->parent, NULL, dev);
|
if (parent_device)
|
||||||
|
parent_hwaddr_maybe_changed (parent_device, NULL, device);
|
||||||
|
|
||||||
s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_VLAN);
|
s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
|
||||||
if (s_vlan) {
|
if (s_vlan) {
|
||||||
gs_free NMVlanQosMapping *ingress_map = NULL;
|
gs_free NMVlanQosMapping *ingress_map = NULL;
|
||||||
gs_free NMVlanQosMapping *egress_map = NULL;
|
gs_free NMVlanQosMapping *egress_map = NULL;
|
||||||
@@ -574,7 +558,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||||||
&n_egress_map);
|
&n_egress_map);
|
||||||
|
|
||||||
nm_platform_link_vlan_change (NM_PLATFORM_GET,
|
nm_platform_link_vlan_change (NM_PLATFORM_GET,
|
||||||
nm_device_get_ifindex (dev),
|
nm_device_get_ifindex (device),
|
||||||
NM_VLAN_FLAGS_ALL,
|
NM_VLAN_FLAGS_ALL,
|
||||||
nm_setting_vlan_get_flags (s_vlan),
|
nm_setting_vlan_get_flags (s_vlan),
|
||||||
TRUE,
|
TRUE,
|
||||||
@@ -615,9 +599,6 @@ get_property (GObject *object, guint prop_id,
|
|||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) object);
|
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDeviceVlan *) object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PARENT:
|
|
||||||
nm_utils_g_value_set_object_path (value, priv->parent);
|
|
||||||
break;
|
|
||||||
case PROP_VLAN_ID:
|
case PROP_VLAN_ID:
|
||||||
g_value_set_uint (value, priv->vlan_id);
|
g_value_set_uint (value, priv->vlan_id);
|
||||||
break;
|
break;
|
||||||
@@ -634,14 +615,6 @@ nm_device_vlan_init (NMDeviceVlan * self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dispose (GObject *object)
|
|
||||||
{
|
|
||||||
nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), NULL);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
||||||
{
|
{
|
||||||
@@ -651,27 +624,21 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_VLAN_SETTING_NAME, NM_LINK_TYPE_VLAN)
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_VLAN_SETTING_NAME, NM_LINK_TYPE_VLAN)
|
||||||
|
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->dispose = dispose;
|
|
||||||
|
|
||||||
parent_class->create_and_realize = create_and_realize;
|
parent_class->create_and_realize = create_and_realize;
|
||||||
parent_class->realize_start_notify = realize_start_notify;
|
parent_class->link_changed = link_changed;
|
||||||
parent_class->unrealize_notify = unrealize_notify;
|
parent_class->unrealize_notify = unrealize_notify;
|
||||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||||
parent_class->is_available = is_available;
|
parent_class->is_available = is_available;
|
||||||
parent_class->notify_new_device_added = notify_new_device_added;
|
parent_class->parent_changed_notify = parent_changed_notify;
|
||||||
|
|
||||||
parent_class->check_connection_compatible = check_connection_compatible;
|
parent_class->check_connection_compatible = check_connection_compatible;
|
||||||
parent_class->check_connection_available = check_connection_available;
|
parent_class->check_connection_available = check_connection_available;
|
||||||
parent_class->complete_connection = complete_connection;
|
parent_class->complete_connection = complete_connection;
|
||||||
parent_class->update_connection = update_connection;
|
parent_class->update_connection = update_connection;
|
||||||
|
|
||||||
obj_properties[PROP_PARENT] =
|
|
||||||
g_param_spec_string (NM_DEVICE_VLAN_PARENT, "", "",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_STATIC_STRINGS);
|
|
||||||
obj_properties[PROP_VLAN_ID] =
|
obj_properties[PROP_VLAN_ID] =
|
||||||
g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "",
|
g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "",
|
||||||
0, 4095, 0,
|
0, 4095, 0,
|
||||||
|
@@ -37,9 +37,11 @@ typedef enum {
|
|||||||
} NMVlanError;
|
} NMVlanError;
|
||||||
|
|
||||||
/* D-Bus exported properties */
|
/* D-Bus exported properties */
|
||||||
#define NM_DEVICE_VLAN_PARENT "parent"
|
|
||||||
#define NM_DEVICE_VLAN_ID "vlan-id"
|
#define NM_DEVICE_VLAN_ID "vlan-id"
|
||||||
|
|
||||||
|
/* defined in the parent class, but exposed on D-Bus by the subclass. */
|
||||||
|
#define NM_DEVICE_VLAN_PARENT NM_DEVICE_PARENT
|
||||||
|
|
||||||
typedef struct _NMDeviceVlan NMDeviceVlan;
|
typedef struct _NMDeviceVlan NMDeviceVlan;
|
||||||
typedef struct _NMDeviceVlanClass NMDeviceVlanClass;
|
typedef struct _NMDeviceVlanClass NMDeviceVlanClass;
|
||||||
|
|
||||||
|
@@ -43,7 +43,6 @@ _LOG_DECLARE_SELF(NMDeviceVxlan);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVxlan,
|
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVxlan,
|
||||||
PROP_PARENT,
|
|
||||||
PROP_ID,
|
PROP_ID,
|
||||||
PROP_LOCAL,
|
PROP_LOCAL,
|
||||||
PROP_GROUP,
|
PROP_GROUP,
|
||||||
@@ -62,7 +61,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVxlan,
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMDevice *parent;
|
|
||||||
NMPlatformLnkVxlan props;
|
NMPlatformLnkVxlan props;
|
||||||
} NMDeviceVxlanPrivate;
|
} NMDeviceVxlanPrivate;
|
||||||
|
|
||||||
@@ -88,7 +86,6 @@ update_properties (NMDevice *device)
|
|||||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self);
|
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self);
|
||||||
GObject *object = G_OBJECT (device);
|
GObject *object = G_OBJECT (device);
|
||||||
const NMPlatformLnkVxlan *props;
|
const NMPlatformLnkVxlan *props;
|
||||||
NMDevice *parent;
|
|
||||||
|
|
||||||
props = nm_platform_link_get_lnk_vxlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL);
|
props = nm_platform_link_get_lnk_vxlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL);
|
||||||
if (!props) {
|
if (!props) {
|
||||||
@@ -98,13 +95,8 @@ update_properties (NMDevice *device)
|
|||||||
|
|
||||||
g_object_freeze_notify (object);
|
g_object_freeze_notify (object);
|
||||||
|
|
||||||
if (priv->props.parent_ifindex != props->parent_ifindex) {
|
if (priv->props.parent_ifindex != props->parent_ifindex)
|
||||||
g_clear_object (&priv->parent);
|
nm_device_parent_set_ifindex (device, props->parent_ifindex);
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), props->parent_ifindex);
|
|
||||||
if (parent)
|
|
||||||
priv->parent = g_object_ref (parent);
|
|
||||||
_notify (self, PROP_PARENT);
|
|
||||||
}
|
|
||||||
if (priv->props.id != props->id)
|
if (priv->props.id != props->id)
|
||||||
_notify (self, PROP_ID);
|
_notify (self, PROP_ID);
|
||||||
if (priv->props.local != props->local)
|
if (priv->props.local != props->local)
|
||||||
@@ -152,19 +144,10 @@ get_generic_capabilities (NMDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *device, NMPlatformLink *info)
|
link_changed (NMDevice *device,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->link_changed (device, info);
|
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->link_changed (device, pllink);
|
||||||
update_properties (device);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
|
||||||
{
|
|
||||||
g_assert (plink->type == NM_LINK_TYPE_VXLAN);
|
|
||||||
|
|
||||||
NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->realize_start_notify (device, plink);
|
|
||||||
|
|
||||||
update_properties (device);
|
update_properties (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,11 +233,12 @@ create_and_realize (NMDevice *device,
|
|||||||
static gboolean
|
static gboolean
|
||||||
match_parent (NMDeviceVxlan *self, const char *parent)
|
match_parent (NMDeviceVxlan *self, const char *parent)
|
||||||
{
|
{
|
||||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self);
|
NMDevice *parent_device;
|
||||||
|
|
||||||
g_return_val_if_fail (parent != NULL, FALSE);
|
g_return_val_if_fail (parent != NULL, FALSE);
|
||||||
|
|
||||||
if (!priv->parent)
|
parent_device = nm_device_parent_get_device (NM_DEVICE (self));
|
||||||
|
if (!parent_device)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (nm_utils_is_uuid (parent)) {
|
if (nm_utils_is_uuid (parent)) {
|
||||||
@@ -264,7 +248,7 @@ match_parent (NMDeviceVxlan *self, const char *parent)
|
|||||||
/* If the parent is a UUID, the connection matches if our parent
|
/* If the parent is a UUID, the connection matches if our parent
|
||||||
* device has that connection activated.
|
* device has that connection activated.
|
||||||
*/
|
*/
|
||||||
parent_req = nm_device_get_act_request (priv->parent);
|
parent_req = nm_device_get_act_request (parent_device);
|
||||||
if (!parent_req)
|
if (!parent_req)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -276,7 +260,7 @@ match_parent (NMDeviceVxlan *self, const char *parent)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* interface name */
|
/* interface name */
|
||||||
if (g_strcmp0 (parent, nm_device_get_ip_iface (priv->parent)) != 0)
|
if (g_strcmp0 (parent, nm_device_get_ip_iface (parent_device)) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,8 +385,9 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
{
|
{
|
||||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) device);
|
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) device);
|
||||||
NMSettingVxlan *s_vxlan = nm_connection_get_setting_vxlan (connection);
|
NMSettingVxlan *s_vxlan = nm_connection_get_setting_vxlan (connection);
|
||||||
NMDevice *parent = NULL;
|
NMDevice *parent_device;
|
||||||
const char *setting_parent, *new_parent;
|
const char *setting_parent;
|
||||||
|
const char *new_parent = NULL;
|
||||||
|
|
||||||
if (!s_vxlan) {
|
if (!s_vxlan) {
|
||||||
s_vxlan = (NMSettingVxlan *) nm_setting_vxlan_new ();
|
s_vxlan = (NMSettingVxlan *) nm_setting_vxlan_new ();
|
||||||
@@ -412,12 +397,11 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
if (priv->props.id != nm_setting_vxlan_get_id (s_vxlan))
|
if (priv->props.id != nm_setting_vxlan_get_id (s_vxlan))
|
||||||
g_object_set (G_OBJECT (s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL);
|
g_object_set (G_OBJECT (s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL);
|
||||||
|
|
||||||
if (priv->props.parent_ifindex != NM_PLATFORM_LINK_OTHER_NETNS)
|
parent_device = nm_device_parent_get_device (device);
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex);
|
|
||||||
|
|
||||||
/* Update parent in the connection; default to parent's interface name */
|
/* Update parent in the connection; default to parent's interface name */
|
||||||
if (parent) {
|
if (parent_device) {
|
||||||
new_parent = nm_device_get_iface (parent);
|
new_parent = nm_device_get_iface (parent_device);
|
||||||
setting_parent = nm_setting_vxlan_get_parent (s_vxlan);
|
setting_parent = nm_setting_vxlan_get_parent (s_vxlan);
|
||||||
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
||||||
NMConnection *parent_connection;
|
NMConnection *parent_connection;
|
||||||
@@ -425,13 +409,11 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||||||
/* Don't change a parent specified by UUID if it's still valid */
|
/* Don't change a parent specified by UUID if it's still valid */
|
||||||
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device),
|
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device),
|
||||||
setting_parent);
|
setting_parent);
|
||||||
if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection))
|
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection))
|
||||||
new_parent = NULL;
|
new_parent = NULL;
|
||||||
}
|
}
|
||||||
if (new_parent)
|
}
|
||||||
g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, new_parent, NULL);
|
g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, new_parent, NULL);
|
||||||
} else
|
|
||||||
g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, NULL, NULL);
|
|
||||||
|
|
||||||
if (!address_matches (nm_setting_vxlan_get_remote (s_vxlan), priv->props.group, &priv->props.group6)) {
|
if (!address_matches (nm_setting_vxlan_get_remote (s_vxlan), priv->props.group, &priv->props.group6)) {
|
||||||
if (priv->props.group) {
|
if (priv->props.group) {
|
||||||
@@ -555,13 +537,8 @@ get_property (GObject *object, guint prop_id,
|
|||||||
GValue *value, GParamSpec *pspec)
|
GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) object);
|
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) object);
|
||||||
NMDevice *parent;
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PARENT:
|
|
||||||
parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->props.parent_ifindex);
|
|
||||||
nm_utils_g_value_set_object_path (value, parent);
|
|
||||||
break;
|
|
||||||
case PROP_ID:
|
case PROP_ID:
|
||||||
g_value_set_uint (value, priv->props.id);
|
g_value_set_uint (value, priv->props.id);
|
||||||
break;
|
break;
|
||||||
@@ -626,15 +603,6 @@ nm_device_vxlan_init (NMDeviceVxlan *self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dispose (GObject *object)
|
|
||||||
{
|
|
||||||
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) object);
|
|
||||||
|
|
||||||
g_clear_object (&priv->parent);
|
|
||||||
G_OBJECT_CLASS (nm_device_vxlan_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
||||||
{
|
{
|
||||||
@@ -644,10 +612,8 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VXLAN)
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_VXLAN)
|
||||||
|
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->dispose = dispose;
|
|
||||||
|
|
||||||
device_class->link_changed = link_changed;
|
device_class->link_changed = link_changed;
|
||||||
device_class->realize_start_notify = realize_start_notify;
|
|
||||||
device_class->unrealize_notify = unrealize_notify;
|
device_class->unrealize_notify = unrealize_notify;
|
||||||
device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME;
|
device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME;
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
@@ -658,12 +624,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||||
|
|
||||||
obj_properties[PROP_PARENT] =
|
|
||||||
g_param_spec_string (NM_DEVICE_VXLAN_PARENT, "", "",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
obj_properties[PROP_ID] =
|
obj_properties[PROP_ID] =
|
||||||
g_param_spec_uint (NM_DEVICE_VXLAN_ID, "", "",
|
g_param_spec_uint (NM_DEVICE_VXLAN_ID, "", "",
|
||||||
0, G_MAXUINT32, 0,
|
0, G_MAXUINT32, 0,
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#define NM_IS_DEVICE_VXLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VXLAN))
|
#define NM_IS_DEVICE_VXLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_VXLAN))
|
||||||
#define NM_DEVICE_VXLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanClass))
|
#define NM_DEVICE_VXLAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanClass))
|
||||||
|
|
||||||
#define NM_DEVICE_VXLAN_PARENT "parent"
|
|
||||||
#define NM_DEVICE_VXLAN_ID "id"
|
#define NM_DEVICE_VXLAN_ID "id"
|
||||||
#define NM_DEVICE_VXLAN_GROUP "group"
|
#define NM_DEVICE_VXLAN_GROUP "group"
|
||||||
#define NM_DEVICE_VXLAN_LOCAL "local"
|
#define NM_DEVICE_VXLAN_LOCAL "local"
|
||||||
@@ -47,6 +46,9 @@
|
|||||||
#define NM_DEVICE_VXLAN_L2MISS "l2miss"
|
#define NM_DEVICE_VXLAN_L2MISS "l2miss"
|
||||||
#define NM_DEVICE_VXLAN_L3MISS "l3miss"
|
#define NM_DEVICE_VXLAN_L3MISS "l3miss"
|
||||||
|
|
||||||
|
/* defined in the parent class, but exposed on D-Bus by the subclass. */
|
||||||
|
#define NM_DEVICE_VXLAN_PARENT NM_DEVICE_PARENT
|
||||||
|
|
||||||
typedef struct _NMDeviceVxlan NMDeviceVxlan;
|
typedef struct _NMDeviceVxlan NMDeviceVxlan;
|
||||||
typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass;
|
typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass;
|
||||||
|
|
||||||
|
@@ -123,6 +123,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDevice,
|
|||||||
PROP_PHYSICAL_PORT_ID,
|
PROP_PHYSICAL_PORT_ID,
|
||||||
PROP_IS_MASTER,
|
PROP_IS_MASTER,
|
||||||
PROP_MASTER,
|
PROP_MASTER,
|
||||||
|
PROP_PARENT,
|
||||||
PROP_HW_ADDRESS,
|
PROP_HW_ADDRESS,
|
||||||
PROP_PERM_HW_ADDRESS,
|
PROP_PERM_HW_ADDRESS,
|
||||||
PROP_HAS_PENDING_ACTION,
|
PROP_HAS_PENDING_ACTION,
|
||||||
@@ -225,10 +226,14 @@ typedef struct _NMDevicePrivate {
|
|||||||
GSList *pending_actions;
|
GSList *pending_actions;
|
||||||
GSList *dad6_failed_addrs;
|
GSList *dad6_failed_addrs;
|
||||||
|
|
||||||
|
NMDevice *parent_device;
|
||||||
|
|
||||||
char * udi;
|
char * udi;
|
||||||
char * iface; /* may change, could be renamed by user */
|
char * iface; /* may change, could be renamed by user */
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
|
int parent_ifindex;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
const guint8 hw_addr_len; /* read-only */
|
const guint8 hw_addr_len; /* read-only */
|
||||||
guint8 hw_addr_len_;
|
guint8 hw_addr_len_;
|
||||||
@@ -790,43 +795,212 @@ void
|
|||||||
nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
char *old_ip_iface;
|
int ifindex;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_DEVICE (self));
|
g_return_if_fail (NM_IS_DEVICE (self));
|
||||||
|
|
||||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
if (!g_strcmp0 (iface, priv->ip_iface))
|
if (nm_streq0 (iface, priv->ip_iface)) {
|
||||||
return;
|
if (!iface)
|
||||||
|
return;
|
||||||
|
ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface);
|
||||||
|
if ( ifindex <= 0
|
||||||
|
|| priv->ip_ifindex == ifindex)
|
||||||
|
return;
|
||||||
|
|
||||||
old_ip_iface = priv->ip_iface;
|
priv->ip_ifindex = ifindex;
|
||||||
priv->ip_ifindex = 0;
|
_LOGD (LOGD_DEVICE, "ip-ifname: update ifindex for ifname '%s': %d", iface, priv->ip_ifindex);
|
||||||
|
} else {
|
||||||
|
g_free (priv->ip_iface);
|
||||||
|
priv->ip_iface = g_strdup (iface);
|
||||||
|
|
||||||
priv->ip_iface = g_strdup (iface);
|
if (iface) {
|
||||||
if (priv->ip_iface) {
|
/* The @iface name is not in sync with the platform cache.
|
||||||
priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
|
* So, there is no point asking the platform cache to resolve
|
||||||
if (priv->ip_ifindex > 0) {
|
* the ifindex. Instead, we can only hope that the interface
|
||||||
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
|
* with this name still exists and we resolve the ifindex
|
||||||
nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE);
|
* anew.
|
||||||
|
*/
|
||||||
if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex))
|
priv->ip_ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface);
|
||||||
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL);
|
if (priv->ip_ifindex > 0)
|
||||||
|
_LOGD (LOGD_DEVICE, "ip-ifname: set ifname '%s', ifindex %d", iface, priv->ip_ifindex);
|
||||||
|
else
|
||||||
|
_LOGW (LOGD_DEVICE, "ip-ifname: set ifname '%s', unknown ifindex", iface);
|
||||||
} else {
|
} else {
|
||||||
/* Device IP interface must always be a kernel network interface */
|
priv->ip_ifindex = 0;
|
||||||
_LOGW (LOGD_PLATFORM, "failed to look up interface index");
|
_LOGD (LOGD_DEVICE, "ip-ifname: clear ifname");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->ip_ifindex > 0) {
|
||||||
|
if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
|
||||||
|
nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE);
|
||||||
|
|
||||||
|
if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex))
|
||||||
|
nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* We don't care about any saved values from the old iface */
|
/* We don't care about any saved values from the old iface */
|
||||||
g_hash_table_remove_all (priv->ip6_saved_properties);
|
g_hash_table_remove_all (priv->ip6_saved_properties);
|
||||||
|
|
||||||
/* Emit change notification */
|
if (priv->ip_ifindex)
|
||||||
if (g_strcmp0 (old_ip_iface, priv->ip_iface)) {
|
priv->ip_mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex);
|
||||||
if (priv->ip_ifindex)
|
|
||||||
priv->ip_mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex);
|
_notify (self, PROP_IP_IFACE);
|
||||||
_notify (self, PROP_IP_IFACE);
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_ip_iface_update (NMDevice *self, const char *ip_iface)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (priv->ip_iface, FALSE);
|
||||||
|
g_return_val_if_fail (priv->ip_ifindex > 0, FALSE);
|
||||||
|
g_return_val_if_fail (ip_iface, FALSE);
|
||||||
|
|
||||||
|
if (!ip_iface[0])
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (nm_streq (priv->ip_iface, ip_iface))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
_LOGI (LOGD_DEVICE, "ip-ifname: interface index %d renamed ip_iface (%d) from '%s' to '%s'",
|
||||||
|
priv->ifindex, priv->ip_ifindex,
|
||||||
|
priv->ip_iface, ip_iface);
|
||||||
|
g_free (priv->ip_iface);
|
||||||
|
priv->ip_iface = g_strdup (ip_iface);
|
||||||
|
_notify (self, PROP_IP_IFACE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
|
nm_device_parent_get_ifindex (NMDevice *self)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), 0);
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
return priv->parent_ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
NMDevice *
|
||||||
|
nm_device_parent_get_device (NMDevice *self)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
return priv->parent_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_changed_notify (NMDevice *self,
|
||||||
|
int old_ifindex,
|
||||||
|
NMDevice *old_parent,
|
||||||
|
int new_ifindex,
|
||||||
|
NMDevice *new_parent)
|
||||||
|
{
|
||||||
|
/* empty handler to allow subclasses to always chain up the virtual function. */
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_parent_set_ifindex (NMDevice *self,
|
||||||
|
int parent_ifindex,
|
||||||
|
gboolean force_check)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
NMDevice *parent_device;
|
||||||
|
gboolean changed = FALSE;
|
||||||
|
int old_ifindex;
|
||||||
|
NMDevice *old_device;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
if (parent_ifindex <= 0)
|
||||||
|
parent_ifindex = 0;
|
||||||
|
|
||||||
|
old_ifindex = priv->parent_ifindex;
|
||||||
|
old_device = priv->parent_device;
|
||||||
|
|
||||||
|
if (priv->parent_ifindex == parent_ifindex) {
|
||||||
|
if (parent_ifindex > 0) {
|
||||||
|
if ( !force_check
|
||||||
|
&& priv->parent_device
|
||||||
|
&& nm_device_get_ifindex (priv->parent_device) == parent_ifindex)
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
if (!priv->parent_device)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
priv->parent_ifindex = parent_ifindex;
|
||||||
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
g_free (old_ip_iface);
|
|
||||||
|
if (parent_ifindex > 0) {
|
||||||
|
parent_device = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex);
|
||||||
|
if (parent_device == self)
|
||||||
|
parent_device = NULL;
|
||||||
|
} else
|
||||||
|
parent_device = NULL;
|
||||||
|
|
||||||
|
if (parent_device != priv->parent_device) {
|
||||||
|
priv->parent_device = parent_device;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
if (priv->parent_ifindex <= 0)
|
||||||
|
_LOGD (LOGD_DEVICE, "parent: clear");
|
||||||
|
else if (!priv->parent_device)
|
||||||
|
_LOGD (LOGD_DEVICE, "parent: ifindex %d, no device", priv->parent_ifindex);
|
||||||
|
else {
|
||||||
|
_LOGD (LOGD_DEVICE, "parent: ifindex %d, device %p, %s", priv->parent_ifindex,
|
||||||
|
priv->parent_device, nm_device_get_iface (priv->parent_device));
|
||||||
|
}
|
||||||
|
|
||||||
|
NM_DEVICE_GET_CLASS (self)->parent_changed_notify (self, old_ifindex, old_device, priv->parent_ifindex, priv->parent_device);
|
||||||
|
|
||||||
|
_notify (self, PROP_PARENT);
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_device_parent_set_ifindex (NMDevice *self,
|
||||||
|
int parent_ifindex)
|
||||||
|
{
|
||||||
|
_parent_set_ifindex (self, parent_ifindex, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
nm_device_parent_notify_changed (NMDevice *self,
|
||||||
|
NMDevice *change_candidate,
|
||||||
|
gboolean device_removed)
|
||||||
|
{
|
||||||
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
nm_assert (NM_IS_DEVICE (self));
|
||||||
|
nm_assert (NM_IS_DEVICE (change_candidate));
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
if (priv->parent_ifindex > 0) {
|
||||||
|
if ( priv->parent_device == change_candidate
|
||||||
|
|| priv->parent_ifindex == nm_device_get_ifindex (change_candidate))
|
||||||
|
return _parent_set_ifindex (self, priv->parent_ifindex, device_removed);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -1981,8 +2155,12 @@ device_link_changed (NMDevice *self)
|
|||||||
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
|
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (klass->link_changed)
|
/* Update carrier from link event if applicable. */
|
||||||
klass->link_changed (self, &info);
|
if ( nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)
|
||||||
|
&& !nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
|
||||||
|
nm_device_set_carrier (self, pllink->connected);
|
||||||
|
|
||||||
|
klass->link_changed (self, &info);
|
||||||
|
|
||||||
/* Update DHCP, etc, if needed */
|
/* Update DHCP, etc, if needed */
|
||||||
if (ip_ifname_changed)
|
if (ip_ifname_changed)
|
||||||
@@ -2075,16 +2253,8 @@ device_ip_link_changed (NMDevice *self)
|
|||||||
if (priv->ip_mtu != pllink->mtu)
|
if (priv->ip_mtu != pllink->mtu)
|
||||||
priv->ip_mtu = pllink->mtu;
|
priv->ip_mtu = pllink->mtu;
|
||||||
|
|
||||||
if (pllink->name[0] && g_strcmp0 (priv->ip_iface, pllink->name)) {
|
if (_ip_iface_update (self, pllink->name))
|
||||||
_LOGI (LOGD_DEVICE, "interface index %d renamed ip_iface (%d) from '%s' to '%s'",
|
|
||||||
priv->ifindex, nm_device_get_ip_ifindex (self),
|
|
||||||
priv->ip_iface, pllink->name);
|
|
||||||
g_free (priv->ip_iface);
|
|
||||||
priv->ip_iface = g_strdup (pllink->name);
|
|
||||||
|
|
||||||
_notify (self, PROP_IP_IFACE);
|
|
||||||
nm_device_update_dynamic_ip_setup (self);
|
nm_device_update_dynamic_ip_setup (self);
|
||||||
}
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
@@ -2119,12 +2289,9 @@ link_changed_cb (NMPlatform *platform,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed (NMDevice *self, NMPlatformLink *info)
|
link_changed (NMDevice *self, const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
/* Update carrier from link event if applicable. */
|
/* stub implementation of virtual function to allow subclasses to chain up. */
|
||||||
if ( nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)
|
|
||||||
&& !nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
|
|
||||||
nm_device_set_carrier (self, info->connected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -2284,8 +2451,10 @@ update_device_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
|
|||||||
_notify (self, PROP_IFACE);
|
_notify (self, PROP_IFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->ifindex = plink->ifindex;
|
if (priv->ifindex != plink->ifindex) {
|
||||||
_notify (self, PROP_IFINDEX);
|
priv->ifindex = plink->ifindex;
|
||||||
|
_notify (self, PROP_IFINDEX);
|
||||||
|
}
|
||||||
|
|
||||||
priv->up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP);
|
priv->up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP);
|
||||||
if (plink->driver && g_strcmp0 (plink->driver, priv->driver) != 0) {
|
if (plink->driver && g_strcmp0 (plink->driver, priv->driver) != 0) {
|
||||||
@@ -2319,11 +2488,12 @@ check_carrier (NMDevice *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
realize_start_notify (NMDevice *self, const NMPlatformLink *plink)
|
realize_start_notify (NMDevice *self,
|
||||||
|
const NMPlatformLink *pllink)
|
||||||
{
|
{
|
||||||
/* Stub implementation for realize_start_notify(). It does nothing,
|
/* the default implementation of realize_start_notify() just calls
|
||||||
* but allows derived classes to uniformly invoke the parent
|
* link_changed() -- which by default does nothing. */
|
||||||
* implementation. */
|
NM_DEVICE_GET_CLASS (self)->link_changed (self, pllink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2583,15 +2753,16 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
|
|||||||
|
|
||||||
NM_DEVICE_GET_CLASS (self)->unrealize_notify (self);
|
NM_DEVICE_GET_CLASS (self)->unrealize_notify (self);
|
||||||
|
|
||||||
|
_parent_set_ifindex (self, 0, FALSE);
|
||||||
|
|
||||||
if (priv->ifindex > 0) {
|
if (priv->ifindex > 0) {
|
||||||
priv->ifindex = 0;
|
priv->ifindex = 0;
|
||||||
_notify (self, PROP_IFINDEX);
|
_notify (self, PROP_IFINDEX);
|
||||||
}
|
}
|
||||||
priv->ip_ifindex = 0;
|
priv->ip_ifindex = 0;
|
||||||
if (priv->ip_iface) {
|
if (nm_clear_g_free (&priv->ip_iface))
|
||||||
g_clear_pointer (&priv->ip_iface, g_free);
|
|
||||||
_notify (self, PROP_IP_IFACE);
|
_notify (self, PROP_IP_IFACE);
|
||||||
}
|
|
||||||
if (priv->driver_version) {
|
if (priv->driver_version) {
|
||||||
g_clear_pointer (&priv->driver_version, g_free);
|
g_clear_pointer (&priv->driver_version, g_free);
|
||||||
_notify (self, PROP_DRIVER_VERSION);
|
_notify (self, PROP_DRIVER_VERSION);
|
||||||
@@ -2658,27 +2829,6 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* nm_device_notify_new_device_added():
|
|
||||||
* @self: the #NMDevice
|
|
||||||
* @device: the newly added device
|
|
||||||
*
|
|
||||||
* Called by the manager to notify the device that a new device has
|
|
||||||
* been found and added.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
nm_device_notify_new_device_added (NMDevice *self, NMDevice *device)
|
|
||||||
{
|
|
||||||
NMDeviceClass *klass;
|
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_DEVICE (self));
|
|
||||||
g_return_if_fail (NM_IS_DEVICE (device));
|
|
||||||
|
|
||||||
klass = NM_DEVICE_GET_CLASS (self);
|
|
||||||
if (klass->notify_new_device_added)
|
|
||||||
klass->notify_new_device_added (self, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_device_notify_component_added():
|
* nm_device_notify_component_added():
|
||||||
* @self: the #NMDevice
|
* @self: the #NMDevice
|
||||||
@@ -3710,9 +3860,9 @@ recheck_available (gpointer user_data)
|
|||||||
|
|
||||||
if (new_state > NM_DEVICE_STATE_UNKNOWN) {
|
if (new_state > NM_DEVICE_STATE_UNKNOWN) {
|
||||||
_LOGD (LOGD_DEVICE, "is %savailable, %s %s",
|
_LOGD (LOGD_DEVICE, "is %savailable, %s %s",
|
||||||
now_available ? "" : "not ",
|
now_available ? "" : "not ",
|
||||||
new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to",
|
new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to",
|
||||||
state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state));
|
state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state));
|
||||||
|
|
||||||
priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE;
|
priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||||
priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE;
|
priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||||
@@ -12684,6 +12834,8 @@ dispose (GObject *object)
|
|||||||
|
|
||||||
_LOGD (LOGD_DEVICE, "disposing");
|
_LOGD (LOGD_DEVICE, "disposing");
|
||||||
|
|
||||||
|
_parent_set_ifindex (self, 0, FALSE);
|
||||||
|
|
||||||
platform = NM_PLATFORM_GET;
|
platform = NM_PLATFORM_GET;
|
||||||
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ipx_changed), self);
|
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ipx_changed), self);
|
||||||
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self);
|
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self);
|
||||||
@@ -12720,6 +12872,11 @@ dispose (GObject *object)
|
|||||||
|
|
||||||
link_disconnect_action_cancel (self);
|
link_disconnect_action_cancel (self);
|
||||||
|
|
||||||
|
if (priv->ifindex > 0) {
|
||||||
|
priv->ifindex = 0;
|
||||||
|
_notify (self, PROP_IFINDEX);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->settings) {
|
if (priv->settings) {
|
||||||
g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_added, self);
|
g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_added, self);
|
||||||
g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_updated, self);
|
g_signal_handlers_disconnect_by_func (priv->settings, cp_connection_updated, self);
|
||||||
@@ -12998,6 +13155,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_MASTER:
|
case PROP_MASTER:
|
||||||
g_value_set_object (value, nm_device_get_master (self));
|
g_value_set_object (value, nm_device_get_master (self));
|
||||||
break;
|
break;
|
||||||
|
case PROP_PARENT:
|
||||||
|
nm_utils_g_value_set_object_path (value, priv->parent_device);
|
||||||
|
break;
|
||||||
case PROP_HW_ADDRESS:
|
case PROP_HW_ADDRESS:
|
||||||
g_value_set_string (value, priv->hw_addr);
|
g_value_set_string (value, priv->hw_addr);
|
||||||
break;
|
break;
|
||||||
@@ -13102,6 +13262,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||||||
klass->get_ip_iface_identifier = get_ip_iface_identifier;
|
klass->get_ip_iface_identifier = get_ip_iface_identifier;
|
||||||
klass->unmanaged_on_quit = unmanaged_on_quit;
|
klass->unmanaged_on_quit = unmanaged_on_quit;
|
||||||
klass->deactivate_reset_hw_addr = deactivate_reset_hw_addr;
|
klass->deactivate_reset_hw_addr = deactivate_reset_hw_addr;
|
||||||
|
klass->parent_changed_notify = parent_changed_notify;
|
||||||
|
|
||||||
obj_properties[PROP_UDI] =
|
obj_properties[PROP_UDI] =
|
||||||
g_param_spec_string (NM_DEVICE_UDI, "", "",
|
g_param_spec_string (NM_DEVICE_UDI, "", "",
|
||||||
@@ -13256,6 +13417,11 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||||||
NM_TYPE_DEVICE,
|
NM_TYPE_DEVICE,
|
||||||
G_PARAM_READABLE |
|
G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS);
|
G_PARAM_STATIC_STRINGS);
|
||||||
|
obj_properties[PROP_PARENT] =
|
||||||
|
g_param_spec_string (NM_DEVICE_PARENT, "", "",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_STATIC_STRINGS);
|
||||||
obj_properties[PROP_HW_ADDRESS] =
|
obj_properties[PROP_HW_ADDRESS] =
|
||||||
g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "",
|
g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "",
|
||||||
NULL,
|
NULL,
|
||||||
|
@@ -66,6 +66,9 @@
|
|||||||
#define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors"
|
#define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors"
|
||||||
#define NM_DEVICE_REAL "real"
|
#define NM_DEVICE_REAL "real"
|
||||||
|
|
||||||
|
/* "parent" is exposed on D-Bus by subclasses like NMDeviceIPTunnel */
|
||||||
|
#define NM_DEVICE_PARENT "parent"
|
||||||
|
|
||||||
/* the "slaves" property is internal in the parent class, but exposed
|
/* the "slaves" property is internal in the parent class, but exposed
|
||||||
* by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam.
|
* by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam.
|
||||||
* It is thus important that the property name matches. */
|
* It is thus important that the property name matches. */
|
||||||
@@ -153,7 +156,8 @@ typedef struct {
|
|||||||
NMDeviceState old_state,
|
NMDeviceState old_state,
|
||||||
NMDeviceStateReason reason);
|
NMDeviceStateReason reason);
|
||||||
|
|
||||||
void (* link_changed) (NMDevice *self, NMPlatformLink *info);
|
void (* link_changed) (NMDevice *self,
|
||||||
|
const NMPlatformLink *pllink);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create_and_realize():
|
* create_and_realize():
|
||||||
@@ -181,12 +185,15 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* realize_start_notify():
|
* realize_start_notify():
|
||||||
* @self: the #NMDevice
|
* @self: the #NMDevice
|
||||||
* @plink: the #NMPlatformLink if backed by a kernel netdevice
|
* @pllink: the #NMPlatformLink if backed by a kernel netdevice
|
||||||
*
|
*
|
||||||
* Hook for derived classes to be notfied during realize_start_setup()
|
* Hook for derived classes to be notfied during realize_start_setup()
|
||||||
* and perform additional setup.
|
* and perform additional setup.
|
||||||
|
*
|
||||||
|
* The default implemention of NMDevice calls link_changed().
|
||||||
*/
|
*/
|
||||||
void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink);
|
void (*realize_start_notify) (NMDevice *self,
|
||||||
|
const NMPlatformLink *pllink);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unrealize():
|
* unrealize():
|
||||||
@@ -310,7 +317,11 @@ typedef struct {
|
|||||||
gboolean (* have_any_ready_slaves) (NMDevice *self,
|
gboolean (* have_any_ready_slaves) (NMDevice *self,
|
||||||
const GSList *slaves);
|
const GSList *slaves);
|
||||||
|
|
||||||
void (* notify_new_device_added) (NMDevice *self, NMDevice *new_device);
|
void (* parent_changed_notify) (NMDevice *self,
|
||||||
|
int old_ifindex,
|
||||||
|
NMDevice *old_parent,
|
||||||
|
int new_ifindex,
|
||||||
|
NMDevice *new_parent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* component_added:
|
* component_added:
|
||||||
@@ -386,6 +397,14 @@ void nm_device_replace_vpn6_config (NMDevice *dev,
|
|||||||
|
|
||||||
void nm_device_capture_initial_config (NMDevice *dev);
|
void nm_device_capture_initial_config (NMDevice *dev);
|
||||||
|
|
||||||
|
int nm_device_parent_get_ifindex (NMDevice *dev);
|
||||||
|
NMDevice *nm_device_parent_get_device (NMDevice *dev);
|
||||||
|
void nm_device_parent_set_ifindex (NMDevice *self,
|
||||||
|
int parent_ifindex);
|
||||||
|
gboolean nm_device_parent_notify_changed (NMDevice *self,
|
||||||
|
NMDevice *change_candidate,
|
||||||
|
gboolean device_removed);
|
||||||
|
|
||||||
/* Master */
|
/* Master */
|
||||||
gboolean nm_device_is_master (NMDevice *dev);
|
gboolean nm_device_is_master (NMDevice *dev);
|
||||||
|
|
||||||
@@ -575,7 +594,6 @@ gboolean nm_device_check_connection_available (NMDevice *device,
|
|||||||
NMDeviceCheckConAvailableFlags flags,
|
NMDeviceCheckConAvailableFlags flags,
|
||||||
const char *specific_object);
|
const char *specific_object);
|
||||||
|
|
||||||
void nm_device_notify_new_device_added (NMDevice *self, NMDevice *new_device);
|
|
||||||
gboolean nm_device_notify_component_added (NMDevice *device, GObject *component);
|
gboolean nm_device_notify_component_added (NMDevice *device, GObject *component);
|
||||||
|
|
||||||
gboolean nm_device_owns_iface (NMDevice *device, const char *iface);
|
gboolean nm_device_owns_iface (NMDevice *device, const char *iface);
|
||||||
|
@@ -32,13 +32,10 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
/* Cannot include <net/if.h> due to conflict with <linux/if.h>.
|
|
||||||
* Forward declare if_nametoindex. */
|
|
||||||
extern unsigned int if_nametoindex (const char *__ifname);
|
|
||||||
|
|
||||||
#include "main-utils.h"
|
#include "main-utils.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "platform/nm-linux-platform.h"
|
#include "platform/nm-linux-platform.h"
|
||||||
|
#include "platform/nm-platform-utils.h"
|
||||||
#include "dhcp/nm-dhcp-manager.h"
|
#include "dhcp/nm-dhcp-manager.h"
|
||||||
#include "ndisc/nm-ndisc.h"
|
#include "ndisc/nm-ndisc.h"
|
||||||
#include "ndisc/nm-lndp-ndisc.h"
|
#include "ndisc/nm-lndp-ndisc.h"
|
||||||
@@ -394,7 +391,7 @@ main (int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.ifindex = if_nametoindex (global_opt.ifname);
|
gl.ifindex = nmp_utils_if_nametoindex (global_opt.ifname);
|
||||||
if (gl.ifindex <= 0) {
|
if (gl.ifindex <= 0) {
|
||||||
fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
|
fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -949,6 +949,26 @@ settings_startup_complete_changed (NMSettings *settings,
|
|||||||
check_if_startup_complete (self);
|
check_if_startup_complete (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_parent_notify_changed (NMManager *self,
|
||||||
|
NMDevice *device,
|
||||||
|
gboolean device_removed)
|
||||||
|
{
|
||||||
|
GSList *iter;
|
||||||
|
|
||||||
|
nm_assert (NM_IS_DEVICE (device));
|
||||||
|
nm_assert (NM_IS_MANAGER (self));
|
||||||
|
|
||||||
|
for (iter = NM_MANAGER_GET_PRIVATE (self)->devices; iter; ) {
|
||||||
|
if (nm_device_parent_notify_changed (iter->data, device, device_removed)) {
|
||||||
|
/* in the unlikely event that this changes anything, we start iterating
|
||||||
|
* again, to be sure that the device list is up-to-date. */
|
||||||
|
iter = NM_MANAGER_GET_PRIVATE (self)->devices;
|
||||||
|
} else
|
||||||
|
iter = iter->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_device (NMManager *self,
|
remove_device (NMManager *self,
|
||||||
NMDevice *device,
|
NMDevice *device,
|
||||||
@@ -985,6 +1005,8 @@ remove_device (NMManager *self,
|
|||||||
nm_settings_device_removed (priv->settings, device, quitting);
|
nm_settings_device_removed (priv->settings, device, quitting);
|
||||||
priv->devices = g_slist_remove (priv->devices, device);
|
priv->devices = g_slist_remove (priv->devices, device);
|
||||||
|
|
||||||
|
_parent_notify_changed (self, device, TRUE);
|
||||||
|
|
||||||
if (nm_device_is_real (device)) {
|
if (nm_device_is_real (device)) {
|
||||||
gboolean unconfigure_ip_config = !quitting || unmanage;
|
gboolean unconfigure_ip_config = !quitting || unmanage;
|
||||||
|
|
||||||
@@ -1860,6 +1882,14 @@ recheck_assume_connection_cb (NMDevice *device, gpointer user_data)
|
|||||||
recheck_assume_connection (user_data, device);
|
recheck_assume_connection (user_data, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
device_ifindex_changed (NMDevice *device,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
NMManager *self)
|
||||||
|
{
|
||||||
|
_parent_notify_changed (self, device, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_ip_iface_changed (NMDevice *device,
|
device_ip_iface_changed (NMDevice *device,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
@@ -1998,6 +2028,10 @@ add_device (NMManager *self, NMDevice *device, GError **error)
|
|||||||
G_CALLBACK (device_ip_iface_changed),
|
G_CALLBACK (device_ip_iface_changed),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
g_signal_connect (device, "notify::" NM_DEVICE_IFINDEX,
|
||||||
|
G_CALLBACK (device_ifindex_changed),
|
||||||
|
self);
|
||||||
|
|
||||||
g_signal_connect (device, "notify::" NM_DEVICE_IFACE,
|
g_signal_connect (device, "notify::" NM_DEVICE_IFACE,
|
||||||
G_CALLBACK (device_iface_changed),
|
G_CALLBACK (device_iface_changed),
|
||||||
self);
|
self);
|
||||||
@@ -2040,12 +2074,7 @@ add_device (NMManager *self, NMDevice *device, GError **error)
|
|||||||
g_signal_emit (self, signals[INTERNAL_DEVICE_ADDED], 0, device);
|
g_signal_emit (self, signals[INTERNAL_DEVICE_ADDED], 0, device);
|
||||||
_notify (self, PROP_ALL_DEVICES);
|
_notify (self, PROP_ALL_DEVICES);
|
||||||
|
|
||||||
for (iter = priv->devices; iter; iter = iter->next) {
|
_parent_notify_changed (self, device, FALSE);
|
||||||
NMDevice *d = iter->data;
|
|
||||||
|
|
||||||
if (d != device)
|
|
||||||
nm_device_notify_new_device_added (d, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Virtual connections may refer to the new device as
|
/* Virtual connections may refer to the new device as
|
||||||
* parent device, retry to activate them.
|
* parent device, retry to activate them.
|
||||||
|
@@ -38,7 +38,29 @@
|
|||||||
|
|
||||||
#include "nm-core-utils.h"
|
#include "nm-core-utils.h"
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* utils
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
|
extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
|
||||||
|
unsigned int if_nametoindex (const char *__ifname);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nmp_utils_if_indextoname (int ifindex, char *out_ifname/*IFNAMSIZ*/)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (ifindex > 0, NULL);
|
||||||
|
g_return_val_if_fail (out_ifname, NULL);
|
||||||
|
|
||||||
|
return if_indextoname (ifindex, out_ifname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nmp_utils_if_nametoindex (const char *ifname)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (ifname, 0);
|
||||||
|
|
||||||
|
return if_nametoindex (ifname);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* ethtool
|
* ethtool
|
||||||
@@ -91,7 +113,7 @@ ethtool_get (int ifindex, gpointer edata)
|
|||||||
* This does not solve the renaming race, but it minimizes the time for
|
* This does not solve the renaming race, but it minimizes the time for
|
||||||
* the race to happen as much as possible. */
|
* the race to happen as much as possible. */
|
||||||
|
|
||||||
if (!if_indextoname (ifindex, ifname)) {
|
if (!nmp_utils_if_indextoname (ifindex, ifname)) {
|
||||||
nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: request fails resolving ifindex: %s",
|
nm_log_trace (LOGD_PLATFORM, "ethtool[%d]: %s: request fails resolving ifindex: %s",
|
||||||
ifindex,
|
ifindex,
|
||||||
_ethtool_data_to_string (edata, sbuf, sizeof (sbuf)),
|
_ethtool_data_to_string (edata, sbuf, sizeof (sbuf)),
|
||||||
@@ -461,7 +483,7 @@ nmp_utils_mii_supports_carrier_detect (int ifindex)
|
|||||||
|
|
||||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||||
|
|
||||||
if (!if_indextoname (ifindex, ifname)) {
|
if (!nmp_utils_if_indextoname (ifindex, ifname)) {
|
||||||
nm_log_trace (LOGD_PLATFORM, "mii[%d]: carrier-detect no: request fails resolving ifindex: %s", ifindex, g_strerror (errno));
|
nm_log_trace (LOGD_PLATFORM, "mii[%d]: carrier-detect no: request fails resolving ifindex: %s", ifindex, g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -696,7 +718,7 @@ nmp_utils_sysctl_open_netdir (int ifindex,
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (!ifname) {
|
if (!ifname) {
|
||||||
ifname = if_indextoname (ifindex, ifname_buf);
|
ifname = nmp_utils_if_indextoname (ifindex, ifname_buf);
|
||||||
if (!ifname)
|
if (!ifname)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -74,6 +74,9 @@ NMIPConfigSource nmp_utils_ip_config_source_coerce_from_rtprot (NMIPConfigSource
|
|||||||
NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot (NMIPConfigSource source) _nm_const;
|
NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot (NMIPConfigSource source) _nm_const;
|
||||||
const char * nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize len);
|
const char * nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize len);
|
||||||
|
|
||||||
|
const char *nmp_utils_if_indextoname (int ifindex, char *out_ifname/*IFNAMSIZ*/);
|
||||||
|
int nmp_utils_if_nametoindex (const char *ifname);
|
||||||
|
|
||||||
int nmp_utils_sysctl_open_netdir (int ifindex,
|
int nmp_utils_sysctl_open_netdir (int ifindex,
|
||||||
const char *ifname_guess,
|
const char *ifname_guess,
|
||||||
char *out_ifname);
|
char *out_ifname);
|
||||||
|
@@ -770,6 +770,22 @@ nm_platform_link_get_ifindex (NMPlatform *self, const char *name)
|
|||||||
return pllink ? pllink->ifindex : 0;
|
return pllink ? pllink->ifindex : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */)
|
||||||
|
{
|
||||||
|
_CHECK_SELF_NETNS (self, klass, netns, FALSE);
|
||||||
|
|
||||||
|
return nmp_utils_if_indextoname (ifindex, out_ifname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nm_platform_if_nametoindex (NMPlatform *self, const char *ifname)
|
||||||
|
{
|
||||||
|
_CHECK_SELF_NETNS (self, klass, netns, FALSE);
|
||||||
|
|
||||||
|
return nmp_utils_if_nametoindex (ifname);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_platform_link_get_name:
|
* nm_platform_link_get_name:
|
||||||
* @self: platform instance
|
* @self: platform instance
|
||||||
|
@@ -738,6 +738,9 @@ gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *pathid,
|
|||||||
|
|
||||||
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value);
|
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value);
|
||||||
|
|
||||||
|
const char *nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */);
|
||||||
|
int nm_platform_if_nametoindex (NMPlatform *self, const char *ifname);
|
||||||
|
|
||||||
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
|
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
|
||||||
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
|
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
|
||||||
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
||||||
|
@@ -197,8 +197,8 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
|
|||||||
devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self)));
|
devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self)));
|
||||||
|
|
||||||
priv->devtimeout_link_changed_handler =
|
priv->devtimeout_link_changed_handler =
|
||||||
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
||||||
G_CALLBACK (link_changed), self);
|
G_CALLBACK (link_changed), self);
|
||||||
priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self);
|
priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user