summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-09-26 17:34:23 -0400
committerDan Winship <danw@gnome.org>2013-10-11 12:24:34 -0400
commit68f12b4e9c134d41e42cc8a1986cad6bb3c07b7a (patch)
treede39f242269a9e2b0bf5edfbb75bb61092639928
parent5bcdfd39853f5953a956fc88cc5a550f68f3153f (diff)
downloadNetworkManager-68f12b4e9c134d41e42cc8a1986cad6bb3c07b7a.tar.gz
settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via AddAndActivateConnection have an NMSettingIP4Config and an NMSettingIP6Config, with non-NULL methods, and get rid of now-unnecessary checks for those. Also move the slaves-can't-have-IP-config checks into the platform-independent code as well. This also gets rid of spurious "ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a slave ifcfg file. Partly based on a patch from Pavel. https://bugzilla.gnome.org/show_bug.cgi?id=708875
-rw-r--r--src/NetworkManagerUtils.c102
-rw-r--r--src/NetworkManagerUtils.h3
-rw-r--r--src/devices/nm-device-wifi.c20
-rw-r--r--src/devices/nm-device.c110
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient-utils.c55
-rw-r--r--src/dhcp-manager/nm-dhcp-manager.c29
-rw-r--r--src/nm-policy.c34
-rw-r--r--src/settings/nm-settings.c3
-rw-r--r--src/settings/plugins/ifcfg-rh/Makefile.am2
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c13
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/Makefile.am2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c118
12 files changed, 302 insertions, 189 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index bc3d1b2ae2..660367b5a6 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -298,10 +298,10 @@ nm_utils_get_shared_wifi_permission (NMConnection *connection)
const char *method = NULL;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ g_assert (method);
- if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
+ if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
return NULL; /* Not shared */
s_wifi = nm_connection_get_setting_wireless (connection);
@@ -577,6 +577,72 @@ get_new_connection_name (const GSList *existing,
}
void
+nm_utils_normalize_connection (NMConnection *connection,
+ gboolean default_enable_ipv6)
+{
+ NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
+ const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
+ const char *default_ip6_method =
+ default_enable_ipv6 ? NM_SETTING_IP6_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+ NMSettingIP4Config *s_ip4;
+ NMSettingIP6Config *s_ip6;
+ NMSetting *setting;
+ const char *method;
+
+ s_ip4 = nm_connection_get_setting_ip4_config (connection);
+ s_ip6 = nm_connection_get_setting_ip6_config (connection);
+
+ /* Slave connections don't have IP configuration. */
+ if (nm_setting_connection_get_master (s_con)) {
+ default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
+ default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+
+ if (s_ip4) {
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0) {
+ nm_log_warn (LOGD_SETTINGS, "ignoring IP4 config on slave '%s'",
+ nm_connection_get_id (connection));
+ nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
+ s_ip4 = NULL;
+ }
+ }
+
+ if (s_ip6) {
+ method = nm_setting_ip6_config_get_method (s_ip6);
+ if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
+ nm_log_warn (LOGD_SETTINGS, "ignoring IP6 config on slave '%s'",
+ nm_connection_get_id (connection));
+ nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
+ s_ip6 = NULL;
+ }
+ }
+ }
+
+ /* Ensure all connections have IP4 and IP6 settings objects. If no
+ * IP6 setting was specified, then assume that means IP6 config is allowed
+ * to fail. But if no IP4 setting was specified, assume the caller was just
+ * being lazy.
+ */
+ if (!s_ip4) {
+ setting = nm_setting_ip4_config_new ();
+ nm_connection_add_setting (connection, setting);
+
+ g_object_set (setting,
+ NM_SETTING_IP4_CONFIG_METHOD, default_ip4_method,
+ NULL);
+ }
+ if (!s_ip6) {
+ setting = nm_setting_ip6_config_new ();
+ nm_connection_add_setting (connection, setting);
+
+ g_object_set (setting,
+ NM_SETTING_IP6_CONFIG_METHOD, default_ip6_method,
+ NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
+ NULL);
+ }
+}
+
+void
nm_utils_complete_generic (NMConnection *connection,
const char *ctype,
const GSList *existing,
@@ -585,9 +651,6 @@ nm_utils_complete_generic (NMConnection *connection,
gboolean default_enable_ipv6)
{
NMSettingConnection *s_con;
- NMSettingIP4Config *s_ip4;
- NMSettingIP6Config *s_ip6;
- const char *method;
char *id, *uuid;
s_con = nm_connection_get_setting_connection (connection);
@@ -610,31 +673,8 @@ nm_utils_complete_generic (NMConnection *connection,
g_free (id);
}
- /* Add an 'auto' IPv4 connection if present */
- s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (!s_ip4) {
- s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip4));
- }
- method = nm_setting_ip4_config_get_method (s_ip4);
- if (!method) {
- g_object_set (G_OBJECT (s_ip4),
- NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
- NULL);
- }
-
- /* Add an 'auto' IPv6 setting if allowed and not preset */
- s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (!s_ip6 && default_enable_ipv6) {
- s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
- nm_connection_add_setting (connection, NM_SETTING (s_ip6));
- }
- if (s_ip6 && !nm_setting_ip6_config_get_method (s_ip6)) {
- g_object_set (G_OBJECT (s_ip6),
- NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
- NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
- NULL);
- }
+ /* Normalize */
+ nm_utils_normalize_connection (connection, default_enable_ipv6);
}
char *
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 819cb075c8..c6ab9a032d 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -82,6 +82,9 @@ gboolean nm_utils_get_proc_sys_net_value_with_bounds (const char *path,
gint32 valid_min,
gint32 valid_max);
+void nm_utils_normalize_connection (NMConnection *connection,
+ gboolean default_enable_ipv6);
+
void nm_utils_complete_generic (NMConnection *connection,
const char *ctype,
const GSList *existing,
diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c
index 7c75dee404..97d6e32f7c 100644
--- a/src/devices/nm-device-wifi.c
+++ b/src/devices/nm-device-wifi.c
@@ -1316,11 +1316,9 @@ can_auto_connect (NMDevice *dev,
/* Use the connection if it's a shared connection */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4) {
- method = nm_setting_ip4_config_get_method (s_ip4);
- if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
- return TRUE;
- }
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
+ return TRUE;
for (ap_iter = priv->ap_list; ap_iter; ap_iter = g_slist_next (ap_iter)) {
NMAccessPoint *ap = NM_AP (ap_iter->data);
@@ -1500,10 +1498,8 @@ scanning_allowed (NMDeviceWifi *self)
/* Don't scan when a shared connection is active; it makes drivers mad */
connection = nm_act_request_get_connection (req);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- ip4_method = nm_setting_ip4_config_get_method (s_ip4);
-
- if (s_ip4 && !strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
+ ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+ if (!strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
return FALSE;
/* Don't scan when the connection is locked to a specifc AP, since
@@ -3140,8 +3136,7 @@ act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (connection);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- may_fail = nm_setting_ip4_config_get_may_fail (s_ip4);
+ may_fail = nm_setting_ip4_config_get_may_fail (s_ip4);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
if (chain_up)
@@ -3162,8 +3157,7 @@ act_stage4_ip6_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (connection);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (s_ip6)
- may_fail = nm_setting_ip6_config_get_may_fail (s_ip6);
+ may_fail = nm_setting_ip6_config_get_may_fail (s_ip6);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
if (chain_up)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 4d61c6ac15..8b353b8fed 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1012,25 +1012,21 @@ nm_device_release_one_slave (NMDevice *dev, NMDevice *slave, gboolean failed)
static gboolean
connection_is_static (NMConnection *connection)
{
- NMSettingIP4Config *ip4;
- NMSettingIP6Config *ip6;
+ NMSettingIP4Config *s_ip4;
+ NMSettingIP6Config *s_ip6;
const char *method;
- ip4 = nm_connection_get_setting_ip4_config (connection);
- if (ip4) {
- method = nm_setting_ip4_config_get_method (ip4);
- if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
- && g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
+ s_ip4 = nm_connection_get_setting_ip4_config (connection);
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
+ && strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
return FALSE;
- }
- ip6 = nm_connection_get_setting_ip6_config (connection);
- if (ip6) {
- method = nm_setting_ip6_config_get_method (ip6);
- if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
- && g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
- return FALSE;
- }
+ s_ip6 = nm_connection_get_setting_ip6_config (connection);
+ method = nm_setting_ip6_config_get_method (s_ip6);
+ if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
+ && strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
+ return FALSE;
return TRUE;
}
@@ -1931,11 +1927,11 @@ nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6)
/* Fail the connection if the failed IP method is required to complete */
if (ip6) {
s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (s_ip6 && !nm_setting_ip6_config_get_may_fail (s_ip6))
+ if (!nm_setting_ip6_config_get_may_fail (s_ip6))
return TRUE;
} else {
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4 && !nm_setting_ip4_config_get_may_fail (s_ip4))
+ if (!nm_setting_ip4_config_get_may_fail (s_ip4))
return TRUE;
}
@@ -2188,10 +2184,8 @@ nm_device_handle_autoip4_event (NMDevice *self,
/* Ignore if the connection isn't an AutoIP connection */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
-
- if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
return;
iface = nm_device_get_iface (self);
@@ -2705,10 +2699,8 @@ ip4_requires_slaves (NMConnection *connection)
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
-
- return g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ return strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
}
static NMActStageReturn
@@ -2729,19 +2721,10 @@ act_stage3_ip4_config_start (NMDevice *self,
connection = nm_device_get_connection (self);
g_assert (connection);
- /* If we did not receive IP4 configuration information, default to DHCP.
- * Slaves, on the other hand, never have any IP configuration themselves,
- * since the master handles all of that.
- */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (priv->master) /* eg, device is a slave */
- method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
- else if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
- else
- method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
+ method = nm_setting_ip4_config_get_method (s_ip4);
- if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
+ if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
&& nm_device_is_master (self)
&& nm_device_is_unavailable_because_of_carrier (self)) {
nm_log_info (LOGD_IP4 | LOGD_DEVICE,
@@ -3249,16 +3232,15 @@ ip6_requires_slaves (NMConnection *connection)
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (s_ip6)
- method = nm_setting_ip6_config_get_method (s_ip6);
+ method = nm_setting_ip6_config_get_method (s_ip6);
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
* to complete addressing. SLAAC and DHCP obviously need a peer to
* provide a prefix, while Link-Local must perform DAD on the local link.
*/
- return g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
- || g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0
- || g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0;
+ return strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
+ || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0
+ || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0;
}
static NMActStageReturn
@@ -3285,19 +3267,10 @@ act_stage3_ip6_config_start (NMDevice *self,
connection = nm_device_get_connection (self);
g_assert (connection);
- /* If we did not receive IP6 configuration information, default to AUTO.
- * Slaves, on the other hand, never have any IP configuration themselves,
- * since the master handles all of that.
- */
s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (priv->master) /* eg, device is a slave */
- method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
- else if (s_ip6)
- method = nm_setting_ip6_config_get_method (s_ip6);
- else
- method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
+ method = nm_setting_ip6_config_get_method (s_ip6);
- if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
+ if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
&& nm_device_is_master (self)
&& nm_device_is_unavailable_because_of_carrier (self)) {
nm_log_info (LOGD_IP6 | LOGD_DEVICE,
@@ -3370,7 +3343,7 @@ act_stage3_ip6_config_start (NMDevice *self,
conf_use_tempaddr = ip6_use_tempaddr ();
if (conf_use_tempaddr >= 0)
ip6_privacy = conf_use_tempaddr;
- else if (s_ip6)
+ else
ip6_privacy = nm_setting_ip6_config_get_ip6_privacy (s_ip6);
ip6_privacy = CLAMP (ip6_privacy, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR);
@@ -3917,10 +3890,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
/* Start IPv4 sharing if we need it */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
+ method = nm_setting_ip4_config_get_method (s_ip4);
- if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
+ if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
if (!start_sharing (self, priv->ip4_config)) {
nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IPv4 Commit) start sharing failed.", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
@@ -5041,10 +5013,8 @@ dispose (GObject *object)
* to check that.
*/
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4)
- method = nm_setting_ip4_config_get_method (s_ip4);
- if ( !method
- || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if ( !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
deconfigure = FALSE;
@@ -6444,7 +6414,7 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
FALSE);
g_object_unref (dhcp_mgr);
- method = s_ip4 ? nm_setting_ip4_config_get_method (s_ip4) : NM_SETTING_IP4_CONFIG_METHOD_AUTO;
+ method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
gboolean found = FALSE;
@@ -6485,16 +6455,14 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
/* Everything below for static addressing */
/* Find all IP4 addresses of this connection on the device */
- if (s_ip4) {
- num = nm_setting_ip4_config_get_num_addresses (s_ip4);
- for (i = 0; i < num; i++) {
- NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
-
- if (!nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
- nm_ip4_address_get_address (addr),
- nm_ip4_address_get_prefix (addr)))
- return FALSE;
- }
+ num = nm_setting_ip4_config_get_num_addresses (s_ip4);
+ for (i = 0; i < num; i++) {
+ NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
+
+ if (!nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
+ nm_ip4_address_get_address (addr),
+ nm_ip4_address_get_prefix (addr)))
+ return FALSE;
}
/* Success; all the connection's static IP addresses are assigned to the device */
diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
index c318e8de96..07c049e7ea 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c
@@ -70,35 +70,33 @@ add_hostname (GString *str, const char *format, const char *hostname)
static void
add_ip4_config (GString *str, NMSettingIP4Config *s_ip4, const char *hostname)
{
- if (s_ip4) {
- const char *tmp;
-
- tmp = nm_setting_ip4_config_get_dhcp_client_id (s_ip4);
- if (tmp) {
- gboolean is_octets = TRUE;
- int i = 0;
-
- while (tmp[i]) {
- if ((i % 3) != 2 && !g_ascii_isxdigit (tmp[i])) {
- is_octets = FALSE;
- break;
- }
- if ((i % 3) == 2 && tmp[i] != ':') {
- is_octets = FALSE;
- break;
- }
- i++;
- }
+ const char *tmp;
- /* If the client ID is just hex digits and : then don't use quotes,
- * because dhclient expects either a quoted ASCII string, or a byte
- * array formated as hex octets separated by :
- */
- if (is_octets)
- g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", tmp);
- else
- g_string_append_printf (str, CLIENTID_FORMAT "\n", tmp);
+ tmp = nm_setting_ip4_config_get_dhcp_client_id (s_ip4);
+ if (tmp) {
+ gboolean is_octets = TRUE;
+ int i = 0;
+
+ while (tmp[i]) {
+ if ((i % 3) != 2 && !g_ascii_isxdigit (tmp[i])) {
+ is_octets = FALSE;
+ break;
+ }
+ if ((i % 3) == 2 && tmp[i] != ':') {
+ is_octets = FALSE;
+ break;
+ }
+ i++;
}
+
+ /* If the client ID is just hex digits and : then don't use quotes,
+ * because dhclient expects either a quoted ASCII string, or a byte
+ * array formated as hex octets separated by :
+ */
+ if (is_octets)
+ g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", tmp);
+ else
+ g_string_append_printf (str, CLIENTID_FORMAT "\n", tmp);
}
add_hostname (str, HOSTNAME4_FORMAT "\n", hostname);
@@ -159,8 +157,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
/* Override config file "dhcp-client-id" and use one from the
* connection.
*/
- if ( s_ip4
- && nm_setting_ip4_config_get_dhcp_client_id (s_ip4)
+ if ( nm_setting_ip4_config_get_dhcp_client_id (s_ip4)
&& !strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG)))
continue;
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index f2962e6b2c..1ec870b2fb 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -519,28 +519,21 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
guint8 *dhcp_anycast_addr)
{
NMDHCPManagerPrivate *priv;
- const char *hostname = NULL;
- gboolean send_hostname = TRUE;
+ const char *hostname, *method;
+ gboolean send_hostname;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
- if (s_ip4) {
- const char *method = nm_setting_ip4_config_get_method (s_ip4);
-
- if (method) {
- /* Method must be 'auto' */
- g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL);
- }
-
- send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4);
- if (send_hostname)
- hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4);
- }
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL);
+ send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4);
if (send_hostname) {
+ hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4);
+
/* If we're supposed to send the hostname to the DHCP server but
* the user didn't specify one, then use the hostname from the
* hostname provider if there is one, otherwise use the persistent
@@ -553,7 +546,8 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
!strcmp (hostname, "localhost6.localdomain6")))
hostname = NULL;
}
- }
+ } else
+ hostname = NULL;
return client_start (self, iface, hwaddr, uuid, FALSE, s_ip4, NULL, timeout, dhcp_anycast_addr, hostname, FALSE);
}
@@ -570,15 +564,14 @@ nm_dhcp_manager_start_ip6 (NMDHCPManager *self,
gboolean info_only)
{
NMDHCPManagerPrivate *priv;
- const char *hostname = NULL;
+ const char *hostname;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
- if (s_ip6)
- hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6);
+ hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6);
if (!hostname && priv->hostname_provider) {
hostname = nm_hostname_provider_get_hostname (priv->hostname_provider);
if ( g_strcmp0 (hostname, "localhost.localdomain") == 0
diff --git a/src/nm-policy.c b/src/nm-policy.c
index a0eda7ad22..8f3dbe6452 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -144,16 +144,15 @@ get_best_ip4_device (NMManager *manager, gboolean fully_activated)
g_assert (connection);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
- if (s_ip4) {
- /* Never set the default route through an IPv4LL-addressed device */
- method = nm_setting_ip4_config_get_method (s_ip4);
- if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
- continue;
- /* 'never-default' devices can't ever be the default */
- if (nm_setting_ip4_config_get_never_default (s_ip4))
- continue;
- }
+ /* Never set the default route through an IPv4LL-addressed device */
+ method = nm_setting_ip4_config_get_method (s_ip4);
+ if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
+ continue;
+
+ /* 'never-default' devices can't ever be the default */
+ if (nm_setting_ip4_config_get_never_default (s_ip4))
+ continue;
prio = nm_device_get_priority (dev);
if (prio > 0 && prio < best_prio) {
@@ -223,14 +222,13 @@ get_best_ip6_device (NMManager *manager, gboolean fully_activated)
g_assert (connection);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
- if (s_ip6) {
- method = nm_setting_ip6_config_get_method (s_ip6);
- if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
- continue;
- if (nm_setting_ip6_config_get_never_default (s_ip6))
- continue;
- }
+ method = nm_setting_ip6_config_get_method (s_ip6);
+ if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
+ continue;
+
+ if (nm_setting_ip6_config_get_never_default (s_ip6))
+ continue;
prio = nm_device_get_priority (dev);
if (prio > 0 && prio < best_prio) {
@@ -575,7 +573,7 @@ get_best_ip4_config (NMPolicy *policy,
/* Check the user's preference from the NMConnection */
s_ip4 = nm_connection_get_setting_ip4_config (tmp);
- if (s_ip4 && nm_setting_ip4_config_get_never_default (s_ip4))
+ if (nm_setting_ip4_config_get_never_default (s_ip4))
continue;
}
@@ -753,7 +751,7 @@ get_best_ip6_config (NMPolicy *policy,
/* Check the user's preference from the NMConnection */
s_ip6 = nm_connection_get_setting_ip6_config (tmp);
- if (s_ip6 && nm_setting_ip6_config_get_never_default (s_ip6))
+ if (nm_setting_ip6_config_get_never_default (s_ip6))
continue;
}
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 231db9996d..5e954de1dc 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -68,6 +68,7 @@
#include "nm-settings-utils.h"
#include "nm-connection-provider.h"
#include "nm-config.h"
+#include "NetworkManagerUtils.h"
/* LINKER CRACKROCK */
#define EXPORT(sym) void * __export_##sym = &sym;
@@ -800,6 +801,8 @@ claim_connection (NMSettings *self,
return;
}
+ nm_utils_normalize_connection (NM_CONNECTION (connection), TRUE);
+
if (!nm_connection_verify (NM_CONNECTION (connection), &error)) {
nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am
index 7d1684586e..e0214ddebe 100644
--- a/src/settings/plugins/ifcfg-rh/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/Makefile.am
@@ -25,6 +25,8 @@ libifcfg_rh_io_la_SOURCES = \
utils.h
AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/ \
+ -I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/posix-signals \
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index f9dd034037..4831247aea 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -52,6 +52,7 @@
#include "wifi-utils.h"
#include "nm-posix-signals.h"
+#include "NetworkManagerUtils.h"
#include "common.h"
#include "shvar.h"
@@ -4646,10 +4647,6 @@ connection_from_file (const char *filename,
g_object_unref (connection);
connection = NULL;
goto done;
- } else if (utils_ignore_ip_config (connection)) {
- PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP6 configuration");
- g_object_unref (s_ip6);
- s_ip6 = NULL;
} else {
const char *method;
@@ -4664,11 +4661,7 @@ connection_from_file (const char *filename,
g_object_unref (connection);
connection = NULL;
goto done;
- } else if (s_ip4 && utils_ignore_ip_config (connection)) {
- PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP4 configuration");
- g_object_unref (s_ip4);
- s_ip4 = NULL;
- } else if (s_ip4)
+ } else
nm_connection_add_setting (connection, s_ip4);
/* There is only one DOMAIN variable and it is read and put to IPv4 config
@@ -4703,6 +4696,8 @@ connection_from_file (const char *filename,
}
g_free (bootproto);
+ nm_utils_normalize_connection (connection, TRUE);
+
if (!nm_connection_verify (connection, error)) {
g_object_unref (connection);
connection = NULL;
diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
index 6e67fe008c..de02b110a2 100644
--- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
@@ -13,6 +13,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/libnm-util \
-I$(top_builddir)/libnm-util \
-I$(top_srcdir)/libnm-glib \
+ -I$(top_srcdir)/src/ \
+ -I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/posix-signals \
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 7c3d9897e7..7c79dbc7ad 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -47,6 +47,7 @@
#include <nm-setting-vlan.h>
#include "nm-test-helpers.h"
+#include "NetworkManagerUtils.h"
#include "common.h"
#include "reader.h"
@@ -6222,6 +6223,9 @@ test_write_wired_static (void)
ASSERT (testfile != NULL,
"wired-static-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -6342,6 +6346,9 @@ test_write_wired_dhcp (void)
ASSERT (testfile != NULL,
"wired-dhcp-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -6466,6 +6473,9 @@ test_write_wired_static_ip6_only (void)
ASSERT (testfile != NULL,
"wired-static-ip6-only-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -6610,6 +6620,9 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -6765,6 +6778,9 @@ test_read_write_static_routes_legacy (void)
ASSERT (testfile != NULL,
"read-write-static-routes-legacy-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -6937,6 +6953,9 @@ test_write_wired_static_routes (void)
ASSERT (testfile != NULL,
"wired-static-routes-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7066,6 +7085,9 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void)
ASSERT (testfile != NULL,
"wired-dhcp-8021x-peap-mschapv2write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7248,6 +7270,9 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme,
g_assert (success);
g_assert (testfile != NULL);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7433,6 +7458,9 @@ test_write_wifi_open (void)
ASSERT (testfile != NULL,
"wifi-open-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7561,6 +7589,9 @@ test_write_wifi_open_hex_ssid (void)
ASSERT (testfile != NULL,
"wifi-open-hex-ssid-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7689,6 +7720,9 @@ test_write_wifi_wep (void)
ASSERT (testfile != NULL,
"wifi-wep-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7837,6 +7871,9 @@ test_write_wifi_wep_adhoc (void)
ASSERT (testfile != NULL,
"wifi-wep-adhoc-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -7975,6 +8012,9 @@ test_write_wifi_wep_passphrase (void)
ASSERT (testfile != NULL,
"wifi-wep-passphrase-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8115,6 +8155,9 @@ test_write_wifi_wep_40_ascii (void)
ASSERT (testfile != NULL,
"wifi-wep-40-ascii-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8255,6 +8298,9 @@ test_write_wifi_wep_104_ascii (void)
ASSERT (testfile != NULL,
"wifi-wep-104-ascii-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8392,6 +8438,9 @@ test_write_wifi_leap (void)
ASSERT (testfile != NULL,
"wifi-leap-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8528,6 +8577,9 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8681,6 +8733,9 @@ test_write_wifi_wpa_psk (const char *name,
ASSERT (testfile != NULL,
test_name, "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8829,6 +8884,9 @@ test_write_wifi_wpa_psk_adhoc (void)
ASSERT (testfile != NULL,
"wifi-wpa-psk-adhoc-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -8992,6 +9050,9 @@ test_write_wifi_wpa_eap_tls (void)
ASSERT (testfile != NULL,
"wifi-wpa-eap-tls-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9173,6 +9234,9 @@ test_write_wifi_wpa_eap_ttls_tls (void)
ASSERT (testfile != NULL,
"wifi-wpa-eap-ttls-tls-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9326,6 +9390,9 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void)
ASSERT (testfile != NULL,
"wifi-wpa-eap-ttls-mschapv2-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9467,6 +9534,9 @@ test_write_wifi_wpa_then_open (void)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9511,6 +9581,9 @@ test_write_wifi_wpa_then_open (void)
g_free (keyfile);
keyfile = NULL;
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read it for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9660,6 +9733,9 @@ test_write_wifi_wpa_then_wep_with_perms (void)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9710,6 +9786,9 @@ test_write_wifi_wpa_then_wep_with_perms (void)
g_free (keyfile);
keyfile = NULL;
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read it for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -9852,6 +9931,9 @@ test_write_wifi_dynamic_wep_leap (void)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -10376,6 +10458,9 @@ test_write_wired_qeth_dhcp (void)
ASSERT (testfile != NULL,
"wired-qeth-dhcp-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -10509,6 +10594,9 @@ test_write_wired_ctc_dhcp (void)
svCloseFile (ifcfg);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -10618,6 +10706,9 @@ test_write_permissions (void)
ASSERT (testfile != NULL,
"permissions-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -10745,6 +10836,9 @@ test_write_wifi_wep_agent_keys (void)
g_assert (success);
g_assert (testfile != NULL);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -11138,6 +11232,9 @@ test_write_bridge_main (void)
g_assert (success);
g_assert_cmpstr (testfile, !=, NULL);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -11290,6 +11387,9 @@ test_write_bridge_component (void)
g_assert (success);
g_assert (testfile);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -11622,6 +11722,9 @@ test_write_vlan_only_vlanid (void)
&error);
g_assert (success);
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (written,
NULL,
@@ -11728,6 +11831,9 @@ test_write_ethernet_missing_ipv6 (void)
ASSERT (testfile != NULL,
"ethernet-missing-ipv6", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -11916,6 +12022,9 @@ test_write_bond_main (void)
ASSERT (testfile != NULL,
"bond-main-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -12063,6 +12172,9 @@ test_write_bond_slave (void)
ASSERT (testfile != NULL,
"bond-slave-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -12274,6 +12386,9 @@ test_write_infiniband (void)
ASSERT (testfile != NULL,
"infiniband-write", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
@@ -12424,6 +12539,9 @@ test_write_bond_slave_ib (void)
ASSERT (testfile != NULL,
"bond-slave-write-ib", "didn't get ifcfg file path back after writing connection");
+ /* reread will be normalized, so we must normalize connection too. */
+ nm_utils_normalize_connection (connection, TRUE);
+
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,