ifcfg-rh: read/write ipv4.dad-timeout using ARPING_WAIT

ARPING_WAIT is used for DAD by Red Hat initscrips (ifup-eth).
This commit is contained in:
Jiří Klimeš
2015-09-08 10:55:11 +02:00
committed by Beniamino Galvani
parent 31ea5a99cb
commit adbbf3aa5c
3 changed files with 29 additions and 3 deletions

View File

@@ -682,6 +682,16 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/* ---ifcfg-rh---
* property: dad-timeout
* variable: ARPING_WAIT
* default: missing variable means global default (config override or 3)
* description: Timeout (in seconds) for performing DAD before configuring
* IPv4 addresses. 0 turns off the DAD completely, -1 means default value.
* example: ARPING_WAIT=2
* ---end---
*/
/** /**
* NMSettingIP4Config:dhcp-timeout: * NMSettingIP4Config:dhcp-timeout:
* *

View File

@@ -924,6 +924,7 @@ make_ip4_setting (shvarFile *ifcfg,
shvarFile *network_ifcfg; shvarFile *network_ifcfg;
shvarFile *route_ifcfg; shvarFile *route_ifcfg;
gboolean never_default = FALSE; gboolean never_default = FALSE;
gint64 timeout;
s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
@@ -1199,6 +1200,11 @@ make_ip4_setting (shvarFile *ifcfg,
} }
} }
timeout = svGetValueInt64 (ifcfg, "ARPING_WAIT", 10, -1,
NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX / 1000, -1);
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT,
(gint) (timeout <= 0 ? timeout : timeout * 1000), NULL);
return NM_SETTING (s_ip4); return NM_SETTING (s_ip4);
done: done:

View File

@@ -1947,7 +1947,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
gint32 j; gint32 j;
guint32 i, n, num; guint32 i, n, num;
gint64 route_metric; gint64 route_metric;
int dhcp_timeout; int timeout;
GString *searches; GString *searches;
gboolean success = FALSE; gboolean success = FALSE;
gboolean fake_ip4 = FALSE; gboolean fake_ip4 = FALSE;
@@ -2156,8 +2156,8 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (value) if (value)
svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE);
dhcp_timeout = nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4)); timeout = nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4));
tmp = dhcp_timeout ? g_strdup_printf ("%d", dhcp_timeout) : NULL; tmp = timeout ? g_strdup_printf ("%d", timeout) : NULL;
svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE); svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE);
g_free (tmp); g_free (tmp);
} }
@@ -2248,6 +2248,16 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
goto out; goto out;
} }
timeout = nm_setting_ip_config_get_dad_timeout (s_ip4);
if (timeout < 0)
svSetValue (ifcfg, "ARPING_WAIT", NULL, FALSE);
else if (timeout == 0)
svSetValue (ifcfg, "ARPING_WAIT", "0", FALSE);
else {
/* Round the value up to next integer */
svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1);
}
success = TRUE; success = TRUE;
out: out: