ifcfg-rh: ignore IP config on bond slaves

NM was requiring that bond slaves have either no IP config or an
explicit "none"/"disabled" config. But the system scripts just ignore
any IP config that is present on a slave, so change NM to do that too
(but warn about it).

https://bugzilla.redhat.com/show_bug.cgi?id=838907
This commit is contained in:
Dan Winship 2012-07-23 10:39:05 -04:00
parent aa72d272ef
commit 3324bd2cdf
6 changed files with 20 additions and 38 deletions

View file

@ -4087,6 +4087,9 @@ connection_from_file (const char *filename,
g_object_unref (connection);
connection = NULL;
goto done;
} else if (s_ip6 && utils_ignore_ip_config (connection)) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP6 configuration");
g_object_unref (s_ip6);
} else if (s_ip6) {
const char *method;
@ -4096,14 +4099,14 @@ connection_from_file (const char *filename,
can_disable_ip4 = TRUE;
}
if (utils_disabling_ip4_config_allowed (connection))
can_disable_ip4 = TRUE;
s_ip4 = make_ip4_setting (parsed, network_file, iscsiadm_path, can_disable_ip4, &error);
if (error) {
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);
} else if (s_ip4)
nm_connection_add_setting (connection, s_ip4);

View file

@ -2,3 +2,5 @@ DEVICE=eth0
HWADDR=00:22:15:59:62:97
ONBOOT=no
MASTER=bond0
# This should be ignored
BOOTPROTO=dhcp

View file

@ -12511,8 +12511,6 @@ test_write_bond_slave (void)
NMConnection *reread;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd };
GByteArray *mac;
guint32 mtu = 1492;
@ -12564,29 +12562,6 @@ test_write_bond_slave (void)
NULL);
g_byte_array_free (mac, TRUE);
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
"bond-slave-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
NULL);
/* IP6 setting */
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
ASSERT (s_ip6 != NULL,
"bond-slave-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6,
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
NULL);
ASSERT (nm_connection_verify (connection, &error) == TRUE,
"bond-slave-write", "failed to verify connection: %s",
(error && error->message) ? error->message : "(unknown)");

View file

@ -444,14 +444,16 @@ gone:
}
gboolean
utils_disabling_ip4_config_allowed (NMConnection *connection)
utils_ignore_ip_config (NMConnection *connection)
{
NMSettingConnection *s_con;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
/* bonding slaves are allowed to have no ip configuration */
/* bonding slaves have no IP configuration, and the system
* scripts just ignore it if it's there.
*/
if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_BOND_SETTING_NAME))
return TRUE;

View file

@ -52,7 +52,7 @@ shvarFile *utils_get_route6_ifcfg (const char *parent, gboolean should_create);
gboolean utils_has_route_file_new_syntax (const char *filename);
gboolean utils_disabling_ip4_config_allowed (NMConnection *connection);
gboolean utils_ignore_ip_config (NMConnection *connection);
#endif /* _UTILS_H_ */

View file

@ -2009,16 +2009,16 @@ write_connection (NMConnection *connection,
goto out;
}
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4 || !utils_disabling_ip4_config_allowed (connection)) {
if (!utils_ignore_ip_config (connection)) {
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (!write_ip4_setting (connection, ifcfg, error))
goto out;
}
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) {
if (!write_ip6_setting (connection, ifcfg, error))
goto out;
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) {
if (!write_ip6_setting (connection, ifcfg, error))
goto out;
}
}
write_connection_setting (s_con, ifcfg);