about summary refs log tree commit diff
path: root/src/devices
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2017-01-23 23:34:56 +0100
committerMichael Biebl <biebl@debian.org>2017-01-23 23:34:56 +0100
commitd462f64d6044349b0a4e3581cf2c97bbab7aec97 (patch)
tree0743acb1a191ce83b5722d77aeb896c6c0cdd952 /src/devices
parent58f8be580039b0575b197b9573a1c92745d96d30 (diff)
New upstream version 1.5.91 upstream/1.5.91
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/nm-device-ethernet.c17
-rw-r--r--src/devices/nm-device-veth.c1
-rw-r--r--src/devices/nm-device-vlan.c20
-rw-r--r--src/devices/nm-device.c82
-rw-r--r--src/devices/nm-device.h2
5 files changed, 51 insertions, 71 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index f9d753a5..327e54a8 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -1543,19 +1543,12 @@ new_default_connection (NMDevice *self)
 	return connection;
 }
 
-static NMMatchSpecMatchType
-spec_match_list (NMDevice *device, const GSList *specs)
+static const char *
+get_s390_subchannels (NMDevice *device)
 {
-	NMMatchSpecMatchType matched = NM_MATCH_SPEC_NO_MATCH, m;
-	NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device);
+	nm_assert (NM_IS_DEVICE_ETHERNET (device));
 
-	if (priv->subchannels)
-		matched = nm_match_spec_s390_subchannels (specs, priv->subchannels);
-	if (matched != NM_MATCH_SPEC_NEG_MATCH) {
-		m = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->spec_match_list (device, specs);
-		matched = MAX (matched, m);
-	}
-	return matched;
+	return NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->subchannels;
 }
 
 static void
@@ -1746,7 +1739,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
 	parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
 	parent_class->get_configured_mtu = get_configured_mtu;
 	parent_class->deactivate = deactivate;
-	parent_class->spec_match_list = spec_match_list;
+	parent_class->get_s390_subchannels = get_s390_subchannels;
 	parent_class->update_connection = update_connection;
 	parent_class->carrier_changed = carrier_changed;
 	parent_class->link_changed = link_changed;
diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c
index a5a87a2d..1971aeeb 100644
--- a/src/devices/nm-device-veth.c
+++ b/src/devices/nm-device-veth.c
@@ -111,6 +111,7 @@ notify (GObject *object, GParamSpec *pspec)
 {
 	if (nm_streq (pspec->name, NM_DEVICE_PARENT))
 		_notify (NM_DEVICE_VETH (object), PROP_PEER);
+	G_OBJECT_CLASS (nm_device_veth_parent_class)->notify (object, pspec);
 }
 
 static void
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 3979c95d..45d7cf67 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -572,6 +572,24 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
 	return ret;
 }
 
+static guint32
+get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
+{
+	guint32 mtu = 0;
+	int ifindex;
+
+	mtu = nm_device_get_configured_mtu_for_wired (self, out_is_user_config);
+	if (*out_is_user_config)
+		return mtu;
+
+	/* Inherit the MTU from parent device, if any */
+	ifindex = nm_device_parent_get_ifindex (self);
+	if (ifindex > 0)
+		mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex);
+
+	return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED;
+}
+
 /*****************************************************************************/
 
 static void
@@ -612,7 +630,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
 	parent_class->unrealize_notify = unrealize_notify;
 	parent_class->get_generic_capabilities = get_generic_capabilities;
 	parent_class->act_stage1_prepare = act_stage1_prepare;
-	parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
+	parent_class->get_configured_mtu = get_configured_mtu;
 	parent_class->is_available = is_available;
 	parent_class->parent_changed_notify = parent_changed_notify;
 
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index bc532ff9..b614894e 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2140,8 +2140,7 @@ device_link_changed (NMDevice *self)
 		_notify (self, PROP_UDI);
 	}
 
-	if (g_strcmp0 (info.driver, priv->driver)) {
-		/* Update driver to what udev gives us */
+	if (!nm_streq0 (info.driver, priv->driver)) {
 		g_free (priv->driver);
 		priv->driver = g_strdup (info.driver);
 		_notify (self, PROP_DRIVER);
@@ -2152,12 +2151,6 @@ device_link_changed (NMDevice *self)
 		_notify (self, PROP_MTU);
 	}
 
-	if (info.driver && g_strcmp0 (priv->driver, info.driver) != 0) {
-		g_free (priv->driver);
-		priv->driver = g_strdup (info.driver);
-		_notify (self, PROP_DRIVER);
-	}
-
 	if (ifindex == nm_device_get_ip_ifindex (self))
 		_stats_update_counters_from_pllink (self, &info);
 
@@ -5698,10 +5691,9 @@ act_stage3_ip4_config_start (NMDevice *self,
 				ret = NM_ACT_STAGE_RETURN_FAILURE;
 		} else
 			g_return_val_if_reached (NM_ACT_STAGE_RETURN_FAILURE);
-	} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) {
-		_commit_mtu (self, priv->ip4_config);
+	} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0)
 		ret = NM_ACT_STAGE_RETURN_SUCCESS;
-	} else
+	else
 		_LOGW (LOGD_IP4, "unhandled IPv4 config method '%s'; will fail", method);
 
 	return ret;
@@ -6630,7 +6622,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
 	struct {
 		gboolean initialized;
 		guint32 value;
-	} ip6_mtu_sysctl;
+	} ip6_mtu_sysctl = { 0, };
 	int ifindex;
 	char sbuf[64], sbuf1[64], sbuf2[64];
 
@@ -6729,7 +6721,6 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
 	       ip6_mtu == ip6_mtu_orig ? "" : nm_sprintf_buf (sbuf2, " (was %u)", (guint) ip6_mtu_orig),
 	       ifindex);
 
-	ip6_mtu_sysctl.initialized = FALSE;
 #define _IP6_MTU_SYS() \
 	({ \
 		if (!ip6_mtu_sysctl.initialized) { \
@@ -8317,7 +8308,7 @@ _hash_check_invalid_keys_impl (GHashTable *hash, const char *setting_name, GErro
 		gs_unref_hashtable GHashTable *check_dups = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
 
 		for (i = 0; argv[i]; i++) {
-			if (!g_hash_table_add (check_dups, (char *) argv[i]))
+			if (!nm_g_hash_table_add (check_dups, (char *) argv[i]))
 				nm_assert (FALSE);
 		}
 		nm_assert (g_hash_table_size (check_dups) > 0);
@@ -12870,42 +12861,19 @@ nm_device_get_initial_hw_address (NMDevice *self)
 gboolean
 nm_device_spec_match_list (NMDevice *self, const GSList *specs)
 {
-	g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
-
-	if (!specs)
-		return FALSE;
-
-	return NM_DEVICE_GET_CLASS (self)->spec_match_list (self, specs) == NM_MATCH_SPEC_MATCH;
-}
+	NMDeviceClass *klass;
+	NMMatchSpecMatchType m;
 
-static NMMatchSpecMatchType
-spec_match_list (NMDevice *self, const GSList *specs)
-{
-	NMMatchSpecMatchType matched = NM_MATCH_SPEC_NO_MATCH, m;
-	const GSList *iter;
-	const char *hw_addr_perm;
+	g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
 
-	for (iter = specs; iter; iter = g_slist_next (iter)) {
-		if (!strcmp ((const char *) iter->data, "*")) {
-			matched = NM_MATCH_SPEC_MATCH;
-			break;
-		}
-	}
+	klass = NM_DEVICE_GET_CLASS (self);
 
-	hw_addr_perm = nm_device_get_permanent_hw_address (self);
-	if (hw_addr_perm) {
-		m = nm_match_spec_hwaddr (specs, hw_addr_perm);
-		matched = MAX (matched, m);
-	}
-	if (matched != NM_MATCH_SPEC_NEG_MATCH) {
-		m = nm_match_spec_interface_name (specs, nm_device_get_iface (self));
-		matched = MAX (matched, m);
-	}
-	if (matched != NM_MATCH_SPEC_NEG_MATCH) {
-		m = nm_match_spec_device_type (specs, nm_device_get_type_description (self));
-		matched = MAX (matched, m);
-	}
-	return matched;
+	m = nm_match_spec_device (specs,
+	                          nm_device_get_iface (self),
+	                          nm_device_get_type_description (self),
+	                          nm_device_get_permanent_hw_address (self),
+	                          klass->get_s390_subchannels ? klass->get_s390_subchannels (self) : NULL);
+	return m == NM_MATCH_SPEC_MATCH;
 }
 
 /*****************************************************************************/
@@ -13186,17 +13154,15 @@ set_property (GObject *object, guint prop_id,
 		priv->iface = g_value_dup_string (value);
 		break;
 	case PROP_DRIVER:
-		if (g_value_get_string (value)) {
-			g_free (priv->driver);
-			priv->driver = g_value_dup_string (value);
-		}
+		/* construct-only */
+		priv->driver = g_value_dup_string (value);
 		break;
 	case PROP_DRIVER_VERSION:
-		g_free (priv->driver_version);
+		/* construct-only */
 		priv->driver_version = g_value_dup_string (value);
 		break;
 	case PROP_FIRMWARE_VERSION:
-		g_free (priv->firmware_version);
+		/* construct-only */
 		priv->firmware_version = g_value_dup_string (value);
 		break;
 	case PROP_IP4_ADDRESS:
@@ -13230,22 +13196,25 @@ set_property (GObject *object, guint prop_id,
 		priv->nm_plugin_missing = g_value_get_boolean (value);
 		break;
 	case PROP_DEVICE_TYPE:
-		g_return_if_fail (priv->type == NM_DEVICE_TYPE_UNKNOWN);
+		/* construct-only */
+		nm_assert (priv->type == NM_DEVICE_TYPE_UNKNOWN);
 		priv->type = g_value_get_uint (value);
 		break;
 	case PROP_LINK_TYPE:
 		/* construct-only */
-		g_return_if_fail (priv->link_type == NM_LINK_TYPE_NONE);
+		nm_assert (priv->link_type == NM_LINK_TYPE_NONE);
 		priv->link_type = g_value_get_uint (value);
 		break;
 	case PROP_TYPE_DESC:
-		g_free (priv->type_desc);
+		/* construct-only */
 		priv->type_desc = g_value_dup_string (value);
 		break;
 	case PROP_RFKILL_TYPE:
+		/* construct-only */
 		priv->rfkill_type = g_value_get_uint (value);
 		break;
 	case PROP_IS_MASTER:
+		/* construct-only */
 		priv->is_master = g_value_get_boolean (value);
 		break;
 	case PROP_PERM_HW_ADDRESS:
@@ -13469,7 +13438,6 @@ nm_device_class_init (NMDeviceClass *klass)
 	klass->have_any_ready_slaves = have_any_ready_slaves;
 
 	klass->get_type_description = get_type_description;
-	klass->spec_match_list = spec_match_list;
 	klass->can_auto_connect = can_auto_connect;
 	klass->check_connection_compatible = check_connection_compatible;
 	klass->check_connection_available = check_connection_available;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 52a74d26..311b5a2c 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -295,7 +295,7 @@ typedef struct {
 
 	const char *(*get_type_description) (NMDevice *self);
 
-	NMMatchSpecMatchType (* spec_match_list)   (NMDevice *self, const GSList *specs);
+	const char *(*get_s390_subchannels) (NMDevice *self);
 
 	/* Update the connection with currently configured L2 settings */
 	void            (* update_connection) (NMDevice *device, NMConnection *connection);