Commit 943a12c6 authored by Beniamino Galvani's avatar Beniamino Galvani

ifcfg-rh: persist ipv4.dad-timeout without rounding

Introduce a new ifcfg-rh variable ACD_TIMEOUT that stores the exact
value of ipv4.dad-timeout without rounding. We still write the
initscripts-compatible ARPING_WAIT variable, and read it when
ACD_TIMEOUT is missing.
parent df488184
......@@ -748,11 +748,12 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
/* ---ifcfg-rh---
* property: dad-timeout
* variable: ARPING_WAIT
* variable: ACD_TIMEOUT, 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
* description: Timeout (in milliseconds for ACD_TIMEOUT or in seconds
* for ARPING_WAIT) for address conflict detection before configuring
* IPv4 addresses. 0 turns off the ACD completely, -1 means default value.
* example: ACD_TIMEOUT=2000 or ARPING_WAIT=2
* ---end---
*/
......
......@@ -1555,10 +1555,14 @@ make_ip4_setting (shvarFile *ifcfg,
}
}
timeout = svGetValueInt64 (ifcfg, "ACD_TIMEOUT", 10, -1, NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX, -2);
if (timeout == -2) {
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);
if (timeout > 0)
timeout *= 1000;
}
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, (gint) timeout, NULL);
return g_steal_pointer (&s_ip4);
}
......
......@@ -2417,12 +2417,15 @@ write_ip4_setting (NMConnection *connection,
NM_SET_OUT (out_route_content, write_route_file (s_ip4));
timeout = nm_setting_ip_config_get_dad_timeout (s_ip4);
if (timeout < 0)
if (timeout < 0) {
svUnsetValue (ifcfg, "ACD_TIMEOUT");
svUnsetValue (ifcfg, "ARPING_WAIT");
else if (timeout == 0)
} else if (timeout == 0) {
svSetValueStr (ifcfg, "ACD_TIMEOUT", "0");
svSetValueStr (ifcfg, "ARPING_WAIT", "0");
else {
/* Round the value up to next integer */
} else {
svSetValueInt64 (ifcfg, "ACD_TIMEOUT", timeout);
/* Round the value up to next integer for initscripts */
svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1);
}
......
......@@ -14,6 +14,8 @@ DNS2=4.2.2.2
DOMAIN="foobar.com lab.foobar.com"
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
ACD_TIMEOUT=400
ARPING_WAIT=1
IPV6INIT=no
NAME="Test Write Wired Static Routes"
UUID=${UUID}
......
......@@ -10,3 +10,5 @@ PREFIX1=16
IPADDR2=3.3.3.3
PREFIX2=8
GATEWAY=1.1.1.1
ACD_TIMEOUT=2000
ARPING_WAIT=1
......@@ -9,3 +9,5 @@ IPADDR2=9.8.7.6
PREFIX2=16
IPADDR3=3.3.3.3
PREFIX3=8
ACD_TIMEOUT=2000
ARPING_WAIT=1
......@@ -9,3 +9,5 @@ IPADDR3=9.8.7.6
PREFIX3=16
IPADDR4=3.3.3.3
PREFIX4=8
ACD_TIMEOUT=2000
ARPING_WAIT=1
......@@ -9,3 +9,5 @@ IPADDR1=9.8.7.6
PREFIX1=16
IPADDR2=3.3.3.3
PREFIX2=8
ACD_TIMEOUT=2000
ARPING_WAIT=1
......@@ -1473,6 +1473,7 @@ test_read_wired_ipv4_manual (gconstpointer data)
s_ip4 = nm_connection_get_setting_ip4_config (connection);
g_assert (s_ip4);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
g_assert_cmpint (nm_setting_ip_config_get_dad_timeout (s_ip4), ==, 2000);
/* IP addresses */
g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 3);
......@@ -4764,6 +4765,7 @@ test_write_wired_static_routes (void)
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1",
NM_SETTING_IP_CONFIG_DAD_TIMEOUT, 400,
NULL);
addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment