Re: [PATCH] Add dhcp timeout and anycast config options



On Mon, 2008-08-04 at 12:28 +0100, Sjoerd Simons wrote:
> Add configuration options for apply a dhcp timeout and using DHCP using anycast
> instead of broadcast.

So; does the DHCP timeout change for the mesh devices at all in the new
scheme?  At what points might the DHCP timeout be something other than
the max or the min?  I'd rather not have configurable DHCP timeouts in
this manner because for non-mesh cases, the DHCP timeout never needs to
change.  If we can set the DHCP timeout for mesh operations in the
activation request like the old code did, that would be preferable.

Dan

> Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
> ---
>  libnm-util/nm-setting-ip4-config.c |   53 ++++++++++++++++++++++++++++++++++-
>  libnm-util/nm-setting-ip4-config.h |    7 +++++
>  2 files changed, 58 insertions(+), 2 deletions(-)
> 
> diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c
> index 1def822..c7b58d0 100644
> --- a/libnm-util/nm-setting-ip4-config.c
> +++ b/libnm-util/nm-setting-ip4-config.c
> @@ -24,6 +24,7 @@
>   */
>  
>  #include <string.h>
> +#include <netinet/ether.h>
>  
>  #include <dbus/dbus-glib.h>
>  #include "nm-setting-ip4-config.h"
> @@ -79,7 +80,8 @@ enum {
>  	PROP_IGNORE_DHCP_DNS,
>  	PROP_DHCP_CLIENT_ID,
>  	PROP_DHCP_HOSTNAME,
> -
> +	PROP_DHCP_TIMEOUT,
> +	PROP_DHCP_ANYCAST_ADDRESS,
>  	LAST_PROP
>  };
>  
> @@ -205,6 +207,22 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
>  		}
>  	}
>  
> +	if (self->dhcp_timeout < NM_SETTING_IP4_MINIMAL_DHCP_TIMEOUT) {
> +		g_set_error (error,
> +		             NM_SETTING_IP4_CONFIG_ERROR,
> +		             NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
> +		             NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT);
> +		return FALSE;
> +	}
> +
> +	if (self->anycast_address != NULL && self->anycast_address->len != ETH_ALEN) {
> +		g_set_error (error,
> +		             NM_SETTING_IP4_CONFIG_ERROR,
> +		             NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
> +		             NM_SETTING_IP4_CONFIG_DHCP_ANYCAST);
> +		return FALSE;
> +	}
> +
>  	return TRUE;
>  }
>  
> @@ -271,6 +289,14 @@ set_property (GObject *object, guint prop_id,
>  		g_free (setting->dhcp_hostname);
>  		setting->dhcp_hostname = g_value_dup_string (value);
>  		break;
> +	case PROP_DHCP_TIMEOUT:
> +		setting->dhcp_timeout = g_value_get_uint (value);
> +		break;
> +	case PROP_DHCP_ANYCAST_ADDRESS:
> +		if (setting->anycast_address)
> +			g_byte_array_free (setting->anycast_address, TRUE);
> +		setting->anycast_address = g_value_dup_boxed (value);
> +		break;
>  	default:
>  		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>  		break;
> @@ -308,6 +334,12 @@ get_property (GObject *object, guint prop_id,
>  	case PROP_DHCP_HOSTNAME:
>  		g_value_set_string (value, setting->dhcp_hostname);
>  		break;
> +	case PROP_DHCP_TIMEOUT:
> +		g_value_set_uint (value, setting->dhcp_timeout);
> +		break;
> +	case PROP_DHCP_ANYCAST_ADDRESS:
> +		g_value_set_boxed (value, setting->anycast_address);
> +		break;
>  	default:
>  		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>  		break;
> @@ -390,5 +422,22 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
>  						   "DHCP Hostname",
>  						   NULL,
>  						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
> -}
>  
> +	g_object_class_install_property
> +		(object_class, PROP_DHCP_TIMEOUT,
> +		 g_param_spec_uint (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT,
> +						   "DHCP Timeout",
> +						   "DHCP Timeout",
> +						   NM_SETTING_IP4_MINIMAL_DHCP_TIMEOUT,
> +						   G_MAXUINT,
> +						   NM_SETTING_IP4_DEFAULT_DHCP_TIMEOUT,
> +						   G_PARAM_CONSTRUCT| G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
> +
> +	g_object_class_install_property
> +		(object_class, PROP_DHCP_ANYCAST_ADDRESS,
> +		 nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_DHCP_ANYCAST,
> +						   "Anycast dhcp mac address",
> +						   "Anycast dhcp mac address",
> +						   DBUS_TYPE_G_UCHAR_ARRAY,
> +						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
> +}
> diff --git a/libnm-util/nm-setting-ip4-config.h b/libnm-util/nm-setting-ip4-config.h
> index a6928a4..e5b079c 100644
> --- a/libnm-util/nm-setting-ip4-config.h
> +++ b/libnm-util/nm-setting-ip4-config.h
> @@ -61,12 +61,17 @@ GQuark nm_setting_ip4_config_error_quark (void);
>  #define NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS "ignore-dhcp-dns"
>  #define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID  "dhcp-client-id"
>  #define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME   "dhcp-hostname"
> +#define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT    "dhcp-timeout"
> +#define NM_SETTING_IP4_CONFIG_DHCP_ANYCAST    "dhcp-anycast-address"
>  
>  #define NM_SETTING_IP4_CONFIG_METHOD_AUTO       "auto"
>  #define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
>  #define NM_SETTING_IP4_CONFIG_METHOD_MANUAL     "manual"
>  #define NM_SETTING_IP4_CONFIG_METHOD_SHARED     "shared"
>  
> +#define NM_SETTING_IP4_MINIMAL_DHCP_TIMEOUT 10
> +#define NM_SETTING_IP4_DEFAULT_DHCP_TIMEOUT 45
> +
>  typedef struct {
>  	guint32 address;   /* network byte order */
>  	guint32 prefix;
> @@ -84,6 +89,8 @@ typedef struct {
>  	gboolean ignore_dhcp_dns;
>  	char *dhcp_client_id;
>  	char *dhcp_hostname;
> +	guint dhcp_timeout;
> +	GByteArray *anycast_address; /* Mac address */
>  } NMSettingIP4Config;
>  
>  typedef struct {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]