ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars
Currently ipv4 and ipv6 settings share the ifcfg plugin vars for the dhcp-hostname and dhcp-send-hostname options (DHCP_HOSTNAME and DHCP_SEND_HOSTNAME). Add brand new vars DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME to have var-property one to one mappings.
This commit is contained in:
@@ -1506,11 +1506,23 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0)
|
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0)
|
||||||
return NM_SETTING (s_ip6);
|
return NM_SETTING (s_ip6);
|
||||||
|
|
||||||
value = svGetValueString (ifcfg, "DHCP_HOSTNAME");
|
value = svGetValueString (ifcfg, "DHCPV6_HOSTNAME");
|
||||||
if (value && value[0])
|
/* Use DHCP_HOSTNAME as fallback if it is in FQDN format and ipv6.method is
|
||||||
|
* auto or dhcp: this is required to support old ifcfg files
|
||||||
|
*/
|
||||||
|
if (!value && ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|
||||||
|
|| !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP))) {
|
||||||
|
value = svGetValueString (ifcfg, "DHCP_HOSTNAME");
|
||||||
|
if (value && !strchr (value, '.'))
|
||||||
|
g_clear_pointer (&value, g_free);
|
||||||
|
}
|
||||||
|
if (value)
|
||||||
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL);
|
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL);
|
||||||
g_free (value);
|
g_free (value);
|
||||||
|
|
||||||
|
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME,
|
||||||
|
svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE), NULL);
|
||||||
|
|
||||||
/* Read static IP addresses.
|
/* Read static IP addresses.
|
||||||
* Read them even for AUTO and DHCP methods - in this case the addresses are
|
* Read them even for AUTO and DHCP methods - in this case the addresses are
|
||||||
* added to the automatic ones. Note that this is not currently supported by
|
* added to the automatic ones. Note that this is not currently supported by
|
||||||
|
@@ -2442,6 +2442,23 @@ error:
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg)
|
||||||
|
{
|
||||||
|
const char *hostname;
|
||||||
|
|
||||||
|
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
|
||||||
|
svSetValueString (ifcfg, "DHCPV6_HOSTNAME", hostname);
|
||||||
|
|
||||||
|
/* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it
|
||||||
|
* explicitly in that case, because it is NM-specific variable
|
||||||
|
*/
|
||||||
|
if (nm_setting_ip_config_get_dhcp_send_hostname (s_ip6))
|
||||||
|
svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME");
|
||||||
|
else
|
||||||
|
svSetValueString (ifcfg, "DHCPV6_SEND_HOSTNAME", "no");
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
||||||
{
|
{
|
||||||
@@ -2469,6 +2486,8 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||||||
svUnsetValue (ifcfg, "IPV6INIT");
|
svUnsetValue (ifcfg, "IPV6INIT");
|
||||||
svUnsetValue (ifcfg, "IPV6_AUTOCONF");
|
svUnsetValue (ifcfg, "IPV6_AUTOCONF");
|
||||||
svUnsetValue (ifcfg, "DHCPV6C");
|
svUnsetValue (ifcfg, "DHCPV6C");
|
||||||
|
svUnsetValue (ifcfg, "DHCPV6_HOSTNAME");
|
||||||
|
svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME");
|
||||||
svUnsetValue (ifcfg, "IPV6_DEFROUTE");
|
svUnsetValue (ifcfg, "IPV6_DEFROUTE");
|
||||||
svUnsetValue (ifcfg, "IPV6_PEERDNS");
|
svUnsetValue (ifcfg, "IPV6_PEERDNS");
|
||||||
svUnsetValue (ifcfg, "IPV6_PEERROUTES");
|
svUnsetValue (ifcfg, "IPV6_PEERROUTES");
|
||||||
@@ -2506,9 +2525,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||||||
svUnsetValue (ifcfg, "DHCPV6C");
|
svUnsetValue (ifcfg, "DHCPV6C");
|
||||||
}
|
}
|
||||||
|
|
||||||
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
|
write_ip6_setting_dhcp_hostname (s_ip6, ifcfg);
|
||||||
if (hostname)
|
|
||||||
svSetValueString (ifcfg, "DHCP_HOSTNAME", hostname);
|
|
||||||
|
|
||||||
/* Write out IP addresses */
|
/* Write out IP addresses */
|
||||||
num = nm_setting_ip_config_get_num_addresses (s_ip6);
|
num = nm_setting_ip_config_get_num_addresses (s_ip6);
|
||||||
@@ -2566,6 +2583,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||||||
g_free (ip4_domains);
|
g_free (ip4_domains);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* handle IPV6_DEFROUTE */
|
/* handle IPV6_DEFROUTE */
|
||||||
/* IPV6_DEFROUTE has the opposite meaning from 'never-default' */
|
/* IPV6_DEFROUTE has the opposite meaning from 'never-default' */
|
||||||
if (nm_setting_ip_config_get_never_default(s_ip6))
|
if (nm_setting_ip_config_get_never_default(s_ip6))
|
||||||
|
@@ -3891,7 +3891,7 @@ test_read_write_wired_dhcp_send_hostname (void)
|
|||||||
g_assert (s_ip6);
|
g_assert (s_ip6);
|
||||||
g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == TRUE);
|
g_assert (nm_setting_ip_config_get_dhcp_send_hostname (s_ip4) == TRUE);
|
||||||
g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec");
|
g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "svata-pulec");
|
||||||
g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "svata-pulec");
|
g_assert_null (nm_setting_ip_config_get_dhcp_hostname (s_ip6));
|
||||||
|
|
||||||
/* Set dhcp-send-hostname=false dhcp-hostname="kamil-patka" and write the connection. */
|
/* Set dhcp-send-hostname=false dhcp-hostname="kamil-patka" and write the connection. */
|
||||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL);
|
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, FALSE, NULL);
|
||||||
|
Reference in New Issue
Block a user