device: introduce a global default value for ipv4.dhcp-timeout
authorBeniamino Galvani <bgalvani@redhat.com>
Mon, 12 Oct 2015 08:56:16 +0000 (10:56 +0200)
committerBeniamino Galvani <bgalvani@redhat.com>
Tue, 13 Oct 2015 07:37:34 +0000 (09:37 +0200)
This allows the ipv4.dhcp-timeout default value to be set from user
configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=756423

man/NetworkManager.conf.xml.in
src/devices/nm-device.c

index 9bf1388..53f46d1 100644 (file)
@@ -583,6 +583,11 @@ ipv6.ip6-privacy=1
         <varlistentry>
           <term><varname>ipv4.route-metric</varname></term>
         </varlistentry>
+        <varlistentry>
+          <term><varname>ipv4.dhcp-timeout</varname></term>
+          <listitem><para>If left unspecified, the default value for
+           the interface type is used.</para></listitem>
+        </varlistentry>
         <varlistentry>
           <term><varname>ipv6.ip6-privacy</varname></term>
           <listitem><para>If <literal>ipv6.ip6-privacy</literal> is unset, use the content of
index fcd5dfe..eeffbe9 100644 (file)
@@ -3883,6 +3883,28 @@ dhcp4_state_changed (NMDhcpClient *client,
        }
 }
 
+static int
+dhcp4_get_timeout (NMDevice *self, NMSettingIP4Config *s_ip4)
+{
+       NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+       gs_free char *value = NULL;
+       int timeout;
+
+       timeout = nm_setting_ip4_config_get_dhcp_timeout (s_ip4);
+       if (timeout)
+               return timeout;
+
+       value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
+                                                      "ipv4.dhcp-timeout",
+                                                      self);
+       timeout = _nm_utils_ascii_str_to_int64 (value, 10,
+                                               0, G_MAXINT32, 0);
+       if (timeout)
+               return timeout;
+
+       return priv->dhcp_timeout;
+}
+
 static NMActStageReturn
 dhcp4_start (NMDevice *self,
              NMConnection *connection,
@@ -3918,7 +3940,7 @@ dhcp4_start (NMDevice *self,
                                                        nm_setting_ip_config_get_dhcp_send_hostname (s_ip4),
                                                        nm_setting_ip_config_get_dhcp_hostname (s_ip4),
                                                        nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)),
-                                                       nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4)) ?: priv->dhcp_timeout,
+                                                       dhcp4_get_timeout (self, NM_SETTING_IP4_CONFIG (s_ip4)),
                                                        priv->dhcp_anycast_address,
                                                        NULL);