about summary refs log tree commit diff
path: root/libnm-core/nm-setting-ip-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core/nm-setting-ip-config.c')
-rw-r--r--libnm-core/nm-setting-ip-config.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c
index 3e7f93b0..bdcbc23b 100644
--- a/libnm-core/nm-setting-ip-config.c
+++ b/libnm-core/nm-setting-ip-config.c
@@ -1120,6 +1120,7 @@ typedef struct {
 	GPtrArray *dns;        /* array of IP address strings */
 	GPtrArray *dns_search; /* array of domain name strings */
 	GPtrArray *dns_options;/* array of DNS options */
+	gint dns_priority;
 	GPtrArray *addresses;  /* array of NMIPAddress */
 	GPtrArray *routes;     /* array of NMIPRoute */
 	gint64 route_metric;
@@ -1140,6 +1141,7 @@ enum {
 	PROP_DNS,
 	PROP_DNS_SEARCH,
 	PROP_DNS_OPTIONS,
+	PROP_DNS_PRIORITY,
 	PROP_ADDRESSES,
 	PROP_GATEWAY,
 	PROP_ROUTES,
@@ -1684,6 +1686,22 @@ nm_setting_ip_config_clear_dns_options (NMSettingIPConfig *setting, gboolean is_
 }
 
 /**
+ * nm_setting_ip_config_get_dns_priority:
+ * @setting: the #NMSettingIPConfig
+ *
+ * Returns: the priority of DNS servers
+ *
+ * Since: 1.2.4
+ **/
+gint
+nm_setting_ip_config_get_dns_priority (NMSettingIPConfig *setting)
+{
+	g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), 0);
+
+	return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dns_priority;
+}
+
+/**
  * nm_setting_ip_config_get_num_addresses:
  * @setting: the #NMSettingIPConfig
  *
@@ -2274,6 +2292,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
 		}
 	}
 
+	if (priv->gateway && priv->never_default) {
+		g_set_error (error,
+		             NM_CONNECTION_ERROR,
+		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
+		             _("a gateway is incompatible with '%s'"),
+		             NM_SETTING_IP_CONFIG_NEVER_DEFAULT);
+		g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_IP_CONFIG_GATEWAY);
+		return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
+	}
+
 	return TRUE;
 }
 
@@ -2352,6 +2380,9 @@ set_property (GObject *object, guint prop_id,
 			}
 		}
 		break;
+	case PROP_DNS_PRIORITY:
+		priv->dns_priority = g_value_get_int (value);
+		break;
 	case PROP_ADDRESSES:
 		g_ptr_array_unref (priv->addresses);
 		priv->addresses = _nm_utils_copy_array (g_value_get_boxed (value),
@@ -2424,6 +2455,9 @@ get_property (GObject *object, guint prop_id,
 	case PROP_DNS_OPTIONS:
 		g_value_take_boxed (value, priv->dns_options ? _nm_utils_ptrarray_to_strv (priv->dns_options) : NULL);
 		break;
+	case PROP_DNS_PRIORITY:
+		g_value_set_int (value, priv->dns_priority);
+		break;
 	case PROP_ADDRESSES:
 		g_value_take_boxed (value, _nm_utils_copy_array (priv->addresses,
 		                                                 (NMUtilsCopyFunc) nm_ip_address_dup,
@@ -2576,6 +2610,34 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *setting_class)
 		                     G_PARAM_STATIC_STRINGS));
 
 	/**
+	 * NMSettingIPConfig:dns-priority:
+	 *
+	 * DNS priority.
+	 *
+	 * The relative priority to be used when determining the order of DNS
+	 * servers in resolv.conf.  A lower value means that servers will be on top
+	 * of the file.  Zero selects the default value, which is 50 for VPNs and
+	 * 100 for other connections.  When multiple devices have configurations
+	 * with the same priority, the one with an active default route will be
+	 * preferred.  Note that when using dns=dnsmasq the order is meaningless
+	 * since dnsmasq forwards queries to all known servers at the same time.
+	 *
+	 * Negative values have the special effect of excluding other configurations
+	 * with a greater priority value; so in presence of at least a negative
+	 * priority, only DNS servers from configurations with the lowest priority
+	 * value will be used.
+	 *
+	 * Since: 1.2.4
+	 **/
+	g_object_class_install_property
+	    (object_class, PROP_DNS_PRIORITY,
+	     g_param_spec_int (NM_SETTING_IP_CONFIG_DNS_PRIORITY, "", "",
+	                       G_MININT32, G_MAXINT32, 0,
+	                       G_PARAM_READWRITE |
+	                       G_PARAM_CONSTRUCT |
+	                       G_PARAM_STATIC_STRINGS));
+
+	/**
 	 * NMSettingIPConfig:addresses:
 	 *
 	 * Array of IP addresses.