merge: branch 'lr/ipv4-dhcp-timeout-rh1262922'

https://bugzilla.redhat.com/show_bug.cgi?id=1262922
This commit is contained in:
Lubomir Rintel 2015-10-06 14:18:02 +02:00
commit 343bade03b
12 changed files with 126 additions and 11 deletions

View file

@ -278,10 +278,11 @@ NmcOutputField nmc_fields_setting_ip4_config[] = {
SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), /* 9 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), /* 10 */
SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), /* 11 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 12 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 13 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 14 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 15 */
SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT), /* 12 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 13 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 14 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 15 */
SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 16 */
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
};
#define NMC_FIELDS_SETTING_IP4_CONFIG_ALL "name"","\
@ -296,6 +297,7 @@ NmcOutputField nmc_fields_setting_ip4_config[] = {
NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES","\
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS","\
NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID","\
NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT","\
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME","\
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME","\
NM_SETTING_IP_CONFIG_NEVER_DEFAULT","\
@ -1384,6 +1386,7 @@ DEFINE_GETTER (nmc_property_ipv4_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_ME
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES)
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS)
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_timeout, NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT)
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME)
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME)
DEFINE_GETTER (nmc_property_ipv4_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT)
@ -5909,6 +5912,13 @@ nmc_properties_init (void)
NULL,
NULL,
NULL);
nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_TIMEOUT),
nmc_property_ipv4_get_dhcp_timeout,
nmc_property_set_uint,
NULL,
NULL,
NULL,
NULL);
nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME),
nmc_property_ipv4_get_dhcp_send_hostname,
nmc_property_set_bool,
@ -7237,10 +7247,11 @@ setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_pro
set_val_str (arr, 9, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 11, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 14, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 15, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 15, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY));
set_val_str (arr, 16, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY));
g_ptr_array_add (nmc->output_data, arr);
print_data (nmc); /* Print all data */

View file

@ -58,11 +58,13 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG)
typedef struct {
char *dhcp_client_id;
int dhcp_timeout;
} NMSettingIP4ConfigPrivate;
enum {
PROP_0,
PROP_DHCP_CLIENT_ID,
PROP_DHCP_TIMEOUT,
LAST_PROP
};
@ -98,6 +100,26 @@ nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting)
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_client_id;
}
/**
* nm_setting_ip4_config_get_dhcp_timeout:
* @setting: the #NMSettingIP4Config
*
* Returns the value contained in the #NMSettingIP4Config:dhcp-timeout
* property.
*
* Returns: the configured DHCP timeout in seconds. 0 = default for
* the particular kind of device.
*
* Since: 1.2
**/
int
nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_timeout;
}
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
@ -208,6 +230,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->dhcp_client_id);
priv->dhcp_client_id = g_value_dup_string (value);
break;
case PROP_DHCP_TIMEOUT:
priv->dhcp_timeout = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -224,6 +249,9 @@ get_property (GObject *object, guint prop_id,
case PROP_DHCP_CLIENT_ID:
g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (s_ip4));
break;
case PROP_DHCP_TIMEOUT:
g_value_set_uint (value, nm_setting_ip4_config_get_dhcp_timeout (s_ip4));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -599,6 +627,26 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP4Config:dhcp-timeout:
*
* A timeout for a DHCP transaction in seconds.
**/
/* ---ifcfg-rh---
* property: dhcp-client-id
* variable: DHCP_TIMEOUT(+)
* description: A timeout after which the DHCP transaction fails in case of no response.
* example: DHCP_TIMEOUT=10
* ---end---
*/
g_object_class_install_property
(object_class, PROP_DHCP_TIMEOUT,
g_param_spec_uint (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, "", "",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
/* IP4-specific property overrides */
/* ---dbus---

View file

@ -42,6 +42,8 @@ G_BEGIN_DECLS
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
#define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT "dhcp-timeout"
/**
* NM_SETTING_IP4_CONFIG_METHOD_AUTO:
*
@ -102,6 +104,8 @@ GType nm_setting_ip4_config_get_type (void);
NMSetting *nm_setting_ip4_config_new (void);
const char *nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting);
NM_AVAILABLE_IN_1_2
int nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting);
G_END_DECLS

View file

@ -2002,6 +2002,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A },

View file

@ -355,6 +355,7 @@ global:
nm_setting_ip4_config_get_dhcp_client_id;
nm_setting_ip4_config_get_dhcp_hostname;
nm_setting_ip4_config_get_dhcp_send_hostname;
nm_setting_ip4_config_get_dhcp_timeout;
nm_setting_ip4_config_get_dns;
nm_setting_ip4_config_get_dns_search;
nm_setting_ip4_config_get_ignore_auto_dns;

View file

@ -82,6 +82,7 @@ typedef struct {
char *dhcp_client_id;
gboolean dhcp_send_hostname;
char *dhcp_hostname;
int dhcp_timeout;
gboolean never_default;
gboolean may_fail;
} NMSettingIP4ConfigPrivate;
@ -97,6 +98,7 @@ enum {
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_DHCP_CLIENT_ID,
PROP_DHCP_TIMEOUT,
PROP_DHCP_SEND_HOSTNAME,
PROP_DHCP_HOSTNAME,
PROP_NEVER_DEFAULT,
@ -800,6 +802,24 @@ nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *setting)
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_hostname;
}
/**
* nm_setting_ip4_config_get_dhcp_timeout:
* @setting: the #NMSettingIP4Config
*
* Returns the value contained in the #NMSettingIP4Config:dhcp-timeout
* property.
*
* Returns: The number of seconds after which unfinished DHCP transaction
* fails or zero for "default".
**/
int
nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_timeout;
}
/**
* nm_setting_ip4_config_get_never_default:
* @setting: the #NMSettingIP4Config
@ -1050,6 +1070,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->dhcp_hostname);
priv->dhcp_hostname = g_value_dup_string (value);
break;
case PROP_DHCP_TIMEOUT:
priv->dhcp_timeout = g_value_get_uint (value);
break;
case PROP_NEVER_DEFAULT:
priv->never_default = g_value_get_boolean (value);
break;
@ -1103,6 +1126,9 @@ get_property (GObject *object, guint prop_id,
case PROP_DHCP_HOSTNAME:
g_value_set_string (value, nm_setting_ip4_config_get_dhcp_hostname (setting));
break;
case PROP_DHCP_TIMEOUT:
g_value_set_uint (value, nm_setting_ip4_config_get_dhcp_timeout (setting));
break;
case PROP_NEVER_DEFAULT:
g_value_set_boolean (value, priv->never_default);
break;
@ -1325,6 +1351,19 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP4Config:dhcp-timeout:
*
* Number of seconds after which the unfinished DHCP transaction fails
* or zero for default.
**/
g_object_class_install_property
(object_class, PROP_DHCP_TIMEOUT,
g_param_spec_uint (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, "", "",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP4Config:never-default:
*

View file

@ -66,6 +66,7 @@ GQuark nm_setting_ip4_config_error_quark (void);
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
#define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
#define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
#define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT "dhcp-timeout"
#define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT "never-default"
#define NM_SETTING_IP4_CONFIG_MAY_FAIL "may-fail"
@ -223,6 +224,8 @@ gboolean nm_setting_ip4_config_get_ignore_auto_dns (NMSettingIP4Config *
const char * nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting);
const char * nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *setting);
NM_AVAILABLE_IN_1_2
int nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting);

View file

@ -1283,6 +1283,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A },

View file

@ -870,6 +870,7 @@ global:
nm_setting_connection_autoconnect_slaves_get_type;
nm_setting_connection_get_autoconnect_slaves;
nm_setting_connection_get_metered;
nm_setting_ip4_config_get_dhcp_timeout;
nm_setting_ip_config_add_dns_option;
nm_setting_ip_config_clear_dns_options;
nm_setting_ip_config_get_dns_option;

View file

@ -3798,7 +3798,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)),
priv->dhcp_timeout,
nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4)) ?: priv->dhcp_timeout,
priv->dhcp_anycast_address,
NULL);

View file

@ -1014,8 +1014,8 @@ make_ip4_setting (shvarFile *ifcfg,
g_free (value);
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME,
svTrueValue (ifcfg, "DHCP_SEND_HOSTNAME", TRUE),
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svTrueValue (ifcfg, "DHCP_SEND_HOSTNAME", TRUE),
NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXUINT32, 0),
NULL);
value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE);

View file

@ -1916,6 +1916,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
gint32 j;
guint32 i, n, num;
gint64 route_metric;
int dhcp_timeout;
GString *searches;
gboolean success = FALSE;
gboolean fake_ip4 = FALSE;
@ -2119,6 +2120,11 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4));
if (value)
svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE);
dhcp_timeout = nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4));
tmp = dhcp_timeout ? g_strdup_printf ("%d", dhcp_timeout) : NULL;
svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE);
g_free (tmp);
}
svSetValue (ifcfg, "IPV4_FAILURE_FATAL",