summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-12-30 12:06:30 +0100
committerThomas Haller <thaller@redhat.com>2017-01-01 22:05:35 +0100
commit3bd5244beb1afcfb5aeccde7817a30f9bf60c78d (patch)
tree0348e8bc1257401a4e0ed2a1e9cb277ed5f96fa1
parenta6b1c6df878db8130bdda21b32b104d89a3858b8 (diff)
downloadNetworkManager-th/device-parent.tar.gz
device: move tracking of parent device from NMDeviceIPTunnel to NMDeviceth/device-parent
-rw-r--r--src/devices/nm-device-ip-tunnel.c37
-rw-r--r--src/devices/nm-device-ip-tunnel.h4
-rw-r--r--src/devices/nm-device.h2
3 files changed, 9 insertions, 34 deletions
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index f51c9f35a0..17c7f90f40 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -46,7 +46,6 @@ _LOG_DECLARE_SELF(NMDeviceIPTunnel);
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel,
PROP_MODE,
- PROP_PARENT,
PROP_LOCAL,
PROP_REMOTE,
PROP_TTL,
@@ -60,8 +59,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceIPTunnel,
typedef struct {
NMIPTunnelMode mode;
- NMDevice *parent;
- int parent_ifindex;
char *local;
char *remote;
guint8 ttl;
@@ -126,8 +123,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex)
{
NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device);
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
- NMDevice *parent;
- int parent_ifindex;
+ int parent_ifindex = 0;
in_addr_t local4, remote4;
struct in6_addr local6, remote6;
guint8 ttl = 0, tos = 0, encap_limit = 0;
@@ -137,11 +133,7 @@ update_properties_from_ifindex (NMDevice *device, int ifindex)
if (ifindex <= 0) {
clear:
- if (priv->parent || priv->parent_ifindex) {
- g_clear_object (&priv->parent);
- priv->parent_ifindex = 0;
- _notify (self, PROP_PARENT);
- }
+ nm_device_parent_set_ifindex (device, 0);
if (priv->local) {
g_clear_pointer (&priv->local, g_free);
_notify (self, PROP_LOCAL);
@@ -257,14 +249,7 @@ clear:
} else
g_return_if_reached ();
- if (priv->parent_ifindex != 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);
- }
+ nm_device_parent_set_ifindex (device, parent_ifindex);
if (priv->addr_family == AF_INET) {
if (!address_equal_pn (AF_INET, priv->local, &local4)) {
@@ -382,8 +367,7 @@ update_connection (NMDevice *device, NMConnection *connection)
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);
- if (priv->parent_ifindex > 0)
- parent = nm_manager_get_device_by_ifindex (nm_manager_get (), priv->parent_ifindex);
+ parent = nm_device_parent_get_device (device);
/* Update parent in the connection; default to parent's interface name */
if (parent) {
@@ -512,7 +496,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
/* Check parent interface; could be an interface name or a UUID */
parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel);
if (parent) {
- if (!match_parent (priv->parent, parent))
+ if (!match_parent (nm_device_parent_get_device (device), parent))
return FALSE;
}
@@ -806,16 +790,11 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE ((NMDeviceIPTunnel *) object);
- NMDevice *parent;
switch (prop_id) {
case PROP_MODE:
g_value_set_uint (value, priv->mode);
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:
g_value_set_string (value, priv->local);
break;
@@ -919,12 +898,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
G_PARAM_CONSTRUCT_ONLY |
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] =
g_param_spec_string (NM_DEVICE_IP_TUNNEL_LOCAL, "", "",
NULL,
diff --git a/src/devices/nm-device-ip-tunnel.h b/src/devices/nm-device-ip-tunnel.h
index 5027a27b07..4bff6e33e8 100644
--- a/src/devices/nm-device-ip-tunnel.h
+++ b/src/devices/nm-device-ip-tunnel.h
@@ -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_MODE "mode"
-#define NM_DEVICE_IP_TUNNEL_PARENT "parent"
#define NM_DEVICE_IP_TUNNEL_LOCAL "local"
#define NM_DEVICE_IP_TUNNEL_REMOTE "remote"
#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_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 _NMDeviceIPTunnelClass NMDeviceIPTunnelClass;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index c592b68e25..98c9aae558 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -66,7 +66,7 @@
#define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors"
#define NM_DEVICE_REAL "real"
-/* "parent" will later be exposed by some subclasses */
+/* "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