libnm-util: add 'may-fail' for IPv4 and IPv6

When this property is TRUE, IP configuration can continue as long
as at least on IP configuration type succeeds.  This allows
connections to networks where the user does not necessarily know
whether the network supports IPv4 or IPv6 and does not require
that both complete succesfully.

Since most of the time the user doesn't really care what type
of connectivity they have, as long as they have *some* connectivity,
this allows better "Just Works" behavior as long as the system
settings plugins and connection editors/applets use the right
defaults.

Suggested defaults for may-fail are:

IPv4: no (ie, require IPv4 connectivity)
IPv6: yes (ie, do not require IPv6 connectivity)

Users who require a specific type of connectivity are probably
knowlegable enough to check the box as needed for their network.
This commit is contained in:
Dan Williams 2010-05-02 16:51:26 -07:00
parent 71c7ecba08
commit 806b74db34
6 changed files with 91 additions and 3 deletions

View file

@ -59,7 +59,7 @@ libnm_util_la_SOURCES= \
libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS)
libnm_util_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-util.ver \
-version-info "4:3:3"
-version-info "4:4:3"
if WITH_GNUTLS
libnm_util_la_SOURCES += crypto_gnutls.c

View file

@ -168,8 +168,7 @@ global:
nm_setting_ip4_config_get_dhcp_hostname;
nm_setting_ip4_config_get_dhcp_send_hostname;
nm_setting_ip4_config_get_never_default;
nm_setting_ip6_config_error_get_type;
nm_setting_ip6_config_error_quark;
nm_setting_ip4_config_get_may_fail;
nm_ip6_address_new;
nm_ip6_address_dup;
nm_ip6_address_ref;
@ -194,6 +193,8 @@ global:
nm_ip6_route_set_next_hop;
nm_ip6_route_get_metric;
nm_ip6_route_set_metric;
nm_setting_ip6_config_error_get_type;
nm_setting_ip6_config_error_quark;
nm_setting_ip6_config_get_type;
nm_setting_ip6_config_new;
nm_setting_ip6_config_get_method;
@ -220,6 +221,7 @@ global:
nm_setting_ip6_config_get_ignore_auto_routes;
nm_setting_ip6_config_get_ignore_auto_dns;
nm_setting_ip6_config_get_never_default;
nm_setting_ip6_config_get_may_fail;
nm_setting_need_secrets;
nm_setting_ppp_error_get_type;
nm_setting_ppp_error_quark;

View file

@ -83,6 +83,7 @@ typedef struct {
gboolean dhcp_send_hostname;
char *dhcp_hostname;
gboolean never_default;
gboolean may_fail;
} NMSettingIP4ConfigPrivate;
enum {
@ -98,6 +99,7 @@ enum {
PROP_DHCP_SEND_HOSTNAME,
PROP_DHCP_HOSTNAME,
PROP_NEVER_DEFAULT,
PROP_MAY_FAIL,
LAST_PROP
};
@ -438,6 +440,14 @@ nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting)
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->never_default;
}
gboolean
nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->may_fail;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@ -641,6 +651,9 @@ set_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
priv->never_default = g_value_get_boolean (value);
break;
case PROP_MAY_FAIL:
priv->may_fail = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -688,6 +701,9 @@ get_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
g_value_set_boolean (value, priv->never_default);
break;
case PROP_MAY_FAIL:
g_value_set_boolean (value, priv->may_fail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -968,6 +984,31 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"the default route by NetworkManager.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingIP4Config:may-fail:
*
* If TRUE, allow overall network configuration to proceed even if IPv4
* configuration fails or times out. Note that at least one IP configuration
* must succeed or overall network configuration will still fail. For
* example, in IPv6-only networks, setting this property to TRUE allows
* the overall network configuration to succeed if IPv4 configuration fails
* but IPv6 configuration completes successfully.
**/
g_object_class_install_property
(object_class, PROP_MAY_FAIL,
g_param_spec_boolean (NM_SETTING_IP4_CONFIG_MAY_FAIL,
"May Fail",
"If TRUE, allow overall network configuration to "
"proceed even if IPv4 configuration fails or times "
"out. Note that at least one IP configuration must "
"succeed or overall network configuration will still "
"fail. For example, in IPv6-only networks, setting "
"this property to TRUE allows the overall network "
"configuration to succeed if IPv4 configuration "
"fails but IPv6 configuration completes successfully.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
}

View file

@ -64,6 +64,7 @@ GQuark nm_setting_ip4_config_error_quark (void);
#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_NEVER_DEFAULT "never-default"
#define NM_SETTING_IP4_CONFIG_MAY_FAIL "may-fail"
#define NM_SETTING_IP4_CONFIG_METHOD_AUTO "auto"
#define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
@ -169,6 +170,8 @@ const char * nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *
gboolean nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting);
G_END_DECLS
#endif /* NM_SETTING_IP4_CONFIG_H */

View file

@ -79,6 +79,7 @@ typedef struct {
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
gboolean never_default;
gboolean may_fail;
} NMSettingIP6ConfigPrivate;
@ -92,6 +93,7 @@ enum {
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_NEVER_DEFAULT,
PROP_MAY_FAIL,
LAST_PROP
};
@ -414,6 +416,14 @@ nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting)
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->never_default;
}
gboolean
nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->may_fail;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@ -535,6 +545,9 @@ set_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
priv->never_default = g_value_get_boolean (value);
break;
case PROP_MAY_FAIL:
priv->may_fail = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -572,6 +585,9 @@ get_property (GObject *object, guint prop_id,
case PROP_NEVER_DEFAULT:
g_value_set_boolean (value, priv->never_default);
break;
case PROP_MAY_FAIL:
g_value_set_boolean (value, priv->may_fail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -802,6 +818,30 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingIP6Config:may-fail:
*
* If TRUE, allow overall network configuration to proceed even if IPv6
* configuration fails or times out. Note that at least one IP configuration
* must succeed or overall network configuration will still fail. For
* example, in IPv4-only networks, setting this property to TRUE allows
* the overall network configuration to succeed if IPv6 configuration fails
* but IPv4 configuration completes successfully.
**/
g_object_class_install_property
(object_class, PROP_MAY_FAIL,
g_param_spec_boolean (NM_SETTING_IP6_CONFIG_MAY_FAIL,
"May Fail",
"If TRUE, allow overall network configuration to "
"proceed even if IPv6 configuration fails or times "
"out. Note that at least one IP configuration must "
"succeed or overall network configuration will still "
"fail. For example, in IPv4-only networks, setting "
"this property to TRUE allows the overall network "
"configuration to succeed if IPv6 configuration "
"fails but IPv4 configuration completes successfully.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
}
/********************************************************************/

View file

@ -62,6 +62,7 @@ GQuark nm_setting_ip6_config_error_quark (void);
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
#define NM_SETTING_IP6_CONFIG_NEVER_DEFAULT "never-default"
#define NM_SETTING_IP6_CONFIG_MAY_FAIL "may-fail"
#define NM_SETTING_IP6_CONFIG_METHOD_IGNORE "ignore"
#define NM_SETTING_IP6_CONFIG_METHOD_AUTO "auto"
@ -163,6 +164,7 @@ gboolean nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP
gboolean nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_may_fail (NMSettingIP6Config *setting);
G_END_DECLS