mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 18:58:05 +02:00
core: use streq() instead of strcmp() for comparing ip-config methods
Refactor some code to use nm_streq() and NM_IN_STRSET() instead of strcmp(). Note that nm_utils_get_ip_config_method() never returns %NULL (not even with g_return*() assertion failures). nm_streq() is sufficent.
This commit is contained in:
parent
589063db3b
commit
b16e09a707
4 changed files with 77 additions and 91 deletions
|
|
@ -49,11 +49,11 @@ nm_utils_get_shared_wifi_permission (NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
const char *method = NULL;
|
const char *method;
|
||||||
|
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
|
if (!nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
||||||
return NULL; /* Not shared */
|
return NULL;
|
||||||
|
|
||||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||||
if (s_wifi) {
|
if (s_wifi) {
|
||||||
|
|
@ -223,16 +223,13 @@ nm_utils_connection_has_default_route (NMConnection *connection,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
method = nm_utils_get_ip_config_method (connection, addr_family);
|
||||||
if (addr_family == AF_INET) {
|
if (addr_family == AF_INET) {
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
if (NM_IN_STRSET (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
||||||
if (NM_IN_STRSET (method, NULL,
|
|
||||||
NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
|
||||||
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
|
||||||
if (NM_IN_STRSET (method, NULL,
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
|
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -343,29 +340,28 @@ check_ip6_method (NMConnection *orig,
|
||||||
if (!props)
|
if (!props)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* If the generated connection is 'link-local' and the candidate is both 'auto'
|
|
||||||
* and may-fail=TRUE, then the candidate is OK to use. may-fail is included
|
|
||||||
* in the decision because if the candidate is 'auto' but may-fail=FALSE, then
|
|
||||||
* the connection could not possibly have been previously activated on the
|
|
||||||
* device if the device has no non-link-local IPv6 address.
|
|
||||||
*/
|
|
||||||
orig_ip6_method = nm_utils_get_ip_config_method (orig, AF_INET6);
|
orig_ip6_method = nm_utils_get_ip_config_method (orig, AF_INET6);
|
||||||
candidate_ip6_method = nm_utils_get_ip_config_method (candidate, AF_INET6);
|
candidate_ip6_method = nm_utils_get_ip_config_method (candidate, AF_INET6);
|
||||||
candidate_ip6 = nm_connection_get_setting_ip6_config (candidate);
|
candidate_ip6 = nm_connection_get_setting_ip6_config (candidate);
|
||||||
|
|
||||||
if ( strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
|
if ( nm_streq (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
|
||||||
&& strcmp (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
&& nm_streq (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|
||||||
&& (!candidate_ip6 || nm_setting_ip_config_get_may_fail (candidate_ip6))) {
|
&& ( !candidate_ip6
|
||||||
|
|| nm_setting_ip_config_get_may_fail (candidate_ip6))) {
|
||||||
|
/* If the generated connection is 'link-local' and the candidate is both 'auto'
|
||||||
|
* and may-fail=TRUE, then the candidate is OK to use. may-fail is included
|
||||||
|
* in the decision because if the candidate is 'auto' but may-fail=FALSE, then
|
||||||
|
* the connection could not possibly have been previously activated on the
|
||||||
|
* device if the device has no non-link-local IPv6 address.
|
||||||
|
*/
|
||||||
allow = TRUE;
|
allow = TRUE;
|
||||||
}
|
} else if ( NM_IN_STRSET (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
|
||||||
|
NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|
||||||
/* If the generated connection method is 'link-local' or 'auto' and the candidate
|
&& nm_streq0 (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
|
||||||
* method is 'ignore' we can take the connection, because NM didn't simply take care
|
/* If the generated connection method is 'link-local' or 'auto' and the candidate
|
||||||
* of IPv6.
|
* method is 'ignore' we can take the connection, because NM didn't simply take care
|
||||||
*/
|
* of IPv6.
|
||||||
if ( ( strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
|
*/
|
||||||
|| strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0)
|
|
||||||
&& strcmp (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) {
|
|
||||||
allow = TRUE;
|
allow = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,6 +370,7 @@ check_ip6_method (NMConnection *orig,
|
||||||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||||
NM_SETTING_IP_CONFIG_METHOD);
|
NM_SETTING_IP_CONFIG_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return allow;
|
return allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,19 +518,20 @@ check_ip4_method (NMConnection *orig,
|
||||||
if (!props)
|
if (!props)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* If the generated connection is 'disabled' (device had no IP addresses)
|
|
||||||
* but it has no carrier, that most likely means that IP addressing could
|
|
||||||
* not complete and thus no IP addresses were assigned. In that case, allow
|
|
||||||
* matching to the "auto" method.
|
|
||||||
*/
|
|
||||||
orig_ip4_method = nm_utils_get_ip_config_method (orig, AF_INET);
|
orig_ip4_method = nm_utils_get_ip_config_method (orig, AF_INET);
|
||||||
candidate_ip4_method = nm_utils_get_ip_config_method (candidate, AF_INET);
|
candidate_ip4_method = nm_utils_get_ip_config_method (candidate, AF_INET);
|
||||||
candidate_ip4 = nm_connection_get_setting_ip4_config (candidate);
|
candidate_ip4 = nm_connection_get_setting_ip4_config (candidate);
|
||||||
|
|
||||||
if ( strcmp (orig_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0
|
if ( nm_streq (orig_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
|
||||||
&& strcmp (candidate_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0
|
&& nm_streq (candidate_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|
||||||
&& (!candidate_ip4 || nm_setting_ip_config_get_may_fail (candidate_ip4))
|
&& ( !candidate_ip4
|
||||||
&& (device_has_carrier == FALSE)) {
|
|| nm_setting_ip_config_get_may_fail (candidate_ip4))
|
||||||
|
&& !device_has_carrier) {
|
||||||
|
/* If the generated connection is 'disabled' (device had no IP addresses)
|
||||||
|
* but it has no carrier, that most likely means that IP addressing could
|
||||||
|
* not complete and thus no IP addresses were assigned. In that case, allow
|
||||||
|
* matching to the "auto" method.
|
||||||
|
*/
|
||||||
remove_from_hash (settings, props,
|
remove_from_hash (settings, props,
|
||||||
NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||||
NM_SETTING_IP_CONFIG_METHOD);
|
NM_SETTING_IP_CONFIG_METHOD);
|
||||||
|
|
|
||||||
|
|
@ -2860,6 +2860,7 @@ nm_device_get_effective_ip_config_method (NMDevice *self,
|
||||||
nm_assert_addr_family (addr_family);
|
nm_assert_addr_family (addr_family);
|
||||||
|
|
||||||
method = nm_utils_get_ip_config_method (connection, addr_family);
|
method = nm_utils_get_ip_config_method (connection, addr_family);
|
||||||
|
|
||||||
if ( (addr_family == AF_INET && nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
|
if ( (addr_family == AF_INET && nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
|
||||||
|| (addr_family == AF_INET6 && nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))) {
|
|| (addr_family == AF_INET6 && nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))) {
|
||||||
klass = NM_DEVICE_GET_CLASS (self);
|
klass = NM_DEVICE_GET_CLASS (self);
|
||||||
|
|
@ -6931,7 +6932,7 @@ nm_device_handle_ipv4ll_event (sd_ipv4ll *ll, int event, void *data)
|
||||||
|
|
||||||
/* Ignore if the connection isn't an AutoIP connection */
|
/* Ignore if the connection isn't an AutoIP connection */
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
||||||
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
|
if (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -7863,34 +7864,26 @@ static gboolean
|
||||||
connection_ip4_method_requires_carrier (NMConnection *connection,
|
connection_ip4_method_requires_carrier (NMConnection *connection,
|
||||||
gboolean *out_ip4_enabled)
|
gboolean *out_ip4_enabled)
|
||||||
{
|
{
|
||||||
const char *method = nm_utils_get_ip_config_method (connection, AF_INET);
|
const char *method;
|
||||||
static const char *ip4_carrier_methods[] = {
|
|
||||||
NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
|
||||||
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
if (out_ip4_enabled)
|
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
||||||
*out_ip4_enabled = !!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED);
|
NM_SET_OUT (out_ip4_enabled, !nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED));
|
||||||
return g_strv_contains (ip4_carrier_methods, method);
|
return NM_IN_STRSET (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||||
|
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
connection_ip6_method_requires_carrier (NMConnection *connection,
|
connection_ip6_method_requires_carrier (NMConnection *connection,
|
||||||
gboolean *out_ip6_enabled)
|
gboolean *out_ip6_enabled)
|
||||||
{
|
{
|
||||||
const char *method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
const char *method;
|
||||||
static const char *ip6_carrier_methods[] = {
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_DHCP,
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_SHARED,
|
|
||||||
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
if (out_ip6_enabled)
|
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
||||||
*out_ip6_enabled = !!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
|
NM_SET_OUT (out_ip6_enabled, !nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE));
|
||||||
return g_strv_contains (ip6_carrier_methods, method);
|
return NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||||
|
NM_SETTING_IP6_CONFIG_METHOD_DHCP,
|
||||||
|
NM_SETTING_IP6_CONFIG_METHOD_SHARED,
|
||||||
|
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -7964,7 +7957,7 @@ ip4_requires_slaves (NMDevice *self)
|
||||||
const char *method;
|
const char *method;
|
||||||
|
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
||||||
return strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
|
return nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMActStageReturn
|
static NMActStageReturn
|
||||||
|
|
@ -8818,15 +8811,15 @@ linklocal6_check_complete (NMDevice *self)
|
||||||
|
|
||||||
_LOGD (LOGD_DEVICE, "linklocal6: waiting for link-local addresses successful, continue with method %s", method);
|
_LOGD (LOGD_DEVICE, "linklocal6: waiting for link-local addresses successful, continue with method %s", method);
|
||||||
|
|
||||||
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||||
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0)
|
NM_SETTING_IP6_CONFIG_METHOD_SHARED))
|
||||||
addrconf6_start_with_link_ready (self);
|
addrconf6_start_with_link_ready (self);
|
||||||
else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
|
else if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
|
||||||
if (!dhcp6_start_with_link_ready (self, connection)) {
|
if (!dhcp6_start_with_link_ready (self, connection)) {
|
||||||
/* Time out IPv6 instead of failing the entire activation */
|
/* Time out IPv6 instead of failing the entire activation */
|
||||||
nm_device_activate_schedule_ip6_config_timeout (self);
|
nm_device_activate_schedule_ip6_config_timeout (self);
|
||||||
}
|
}
|
||||||
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0)
|
} else if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
|
||||||
nm_device_activate_schedule_ip6_config_result (self);
|
nm_device_activate_schedule_ip6_config_result (self);
|
||||||
else
|
else
|
||||||
g_return_if_fail (FALSE);
|
g_return_if_fail (FALSE);
|
||||||
|
|
@ -8911,7 +8904,6 @@ static gboolean
|
||||||
linklocal6_start (NMDevice *self)
|
linklocal6_start (NMDevice *self)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
const char *method;
|
|
||||||
|
|
||||||
nm_clear_g_source (&priv->linklocal6_timeout_id);
|
nm_clear_g_source (&priv->linklocal6_timeout_id);
|
||||||
|
|
||||||
|
|
@ -8921,8 +8913,8 @@ linklocal6_start (NMDevice *self)
|
||||||
| NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL))
|
| NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET6);
|
_LOGD (LOGD_DEVICE, "linklocal6: starting IPv6 with method '%s', but the device has no link-local addresses configured. Wait.",
|
||||||
_LOGD (LOGD_DEVICE, "linklocal6: starting IPv6 with method '%s', but the device has no link-local addresses configured. Wait.", method);
|
nm_device_get_effective_ip_config_method (self, AF_INET6));
|
||||||
|
|
||||||
check_and_add_ipv6ll_addr (self);
|
check_and_add_ipv6ll_addr (self);
|
||||||
|
|
||||||
|
|
@ -9427,11 +9419,10 @@ addrconf6_start_with_link_ready (NMDevice *self)
|
||||||
static NMNDiscNodeType
|
static NMNDiscNodeType
|
||||||
ndisc_node_type (NMDevice *self)
|
ndisc_node_type (NMDevice *self)
|
||||||
{
|
{
|
||||||
if (strcmp (nm_device_get_effective_ip_config_method (self, AF_INET6),
|
if (nm_streq (nm_device_get_effective_ip_config_method (self, AF_INET6),
|
||||||
NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0)
|
NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
||||||
return NM_NDISC_NODE_TYPE_ROUTER;
|
return NM_NDISC_NODE_TYPE_ROUTER;
|
||||||
else
|
return NM_NDISC_NODE_TYPE_HOST;
|
||||||
return NM_NDISC_NODE_TYPE_HOST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -9690,8 +9681,8 @@ ip6_requires_slaves (NMDevice *self)
|
||||||
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
|
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
|
||||||
* to complete addressing. SLAAC and DHCP need a peer to provide a prefix.
|
* to complete addressing. SLAAC and DHCP need a peer to provide a prefix.
|
||||||
*/
|
*/
|
||||||
return strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
return NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||||
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0;
|
NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMActStageReturn
|
static NMActStageReturn
|
||||||
|
|
@ -9730,8 +9721,7 @@ act_stage3_ip6_config_start (NMDevice *self,
|
||||||
|
|
||||||
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE;
|
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_NONE;
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET6);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET6);
|
||||||
|
if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
|
||||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) {
|
|
||||||
if ( !priv->master
|
if ( !priv->master
|
||||||
&& !nm_device_sys_iface_state_is_external (self)) {
|
&& !nm_device_sys_iface_state_is_external (self)) {
|
||||||
gboolean ipv6ll_handle_old = priv->ipv6ll_handle;
|
gboolean ipv6ll_handle_old = priv->ipv6ll_handle;
|
||||||
|
|
@ -9777,27 +9767,27 @@ act_stage3_ip6_config_start (NMDevice *self,
|
||||||
|
|
||||||
ip6_privacy = _ip6_privacy_get (self);
|
ip6_privacy = _ip6_privacy_get (self);
|
||||||
|
|
||||||
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||||
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) {
|
NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
|
||||||
if (!addrconf6_start (self, ip6_privacy)) {
|
if (!addrconf6_start (self, ip6_privacy)) {
|
||||||
/* IPv6 might be disabled; allow IPv4 to proceed */
|
/* IPv6 might be disabled; allow IPv4 to proceed */
|
||||||
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
||||||
} else
|
} else
|
||||||
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
||||||
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) {
|
} else if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) {
|
||||||
ret = linklocal6_start (self)
|
ret = linklocal6_start (self)
|
||||||
? NM_ACT_STAGE_RETURN_SUCCESS
|
? NM_ACT_STAGE_RETURN_SUCCESS
|
||||||
: NM_ACT_STAGE_RETURN_POSTPONE;
|
: NM_ACT_STAGE_RETURN_POSTPONE;
|
||||||
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
|
} else if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
|
||||||
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED;
|
priv->dhcp6.mode = NM_NDISC_DHCP_LEVEL_MANAGED;
|
||||||
if (!dhcp6_start (self, TRUE)) {
|
if (!dhcp6_start (self, TRUE)) {
|
||||||
/* IPv6 might be disabled; allow IPv4 to proceed */
|
/* IPv6 might be disabled; allow IPv4 to proceed */
|
||||||
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
||||||
} else
|
} else
|
||||||
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
||||||
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) {
|
} else if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
|
||||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||||
} else
|
else
|
||||||
_LOGW (LOGD_IP6, "unhandled IPv6 config method '%s'; will fail", method);
|
_LOGW (LOGD_IP6, "unhandled IPv6 config method '%s'; will fail", method);
|
||||||
|
|
||||||
if ( ret != NM_ACT_STAGE_RETURN_FAILURE
|
if ( ret != NM_ACT_STAGE_RETURN_FAILURE
|
||||||
|
|
@ -10397,8 +10387,7 @@ activate_stage5_ip4_config_result (NMDevice *self)
|
||||||
|
|
||||||
/* Start IPv4 sharing if we need it */
|
/* Start IPv4 sharing if we need it */
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
||||||
|
if (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
|
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
|
|
||||||
if (!start_sharing (self, priv->ip_config_4, &error)) {
|
if (!start_sharing (self, priv->ip_config_4, &error)) {
|
||||||
|
|
@ -10581,8 +10570,7 @@ activate_stage5_ip6_config_commit (NMDevice *self)
|
||||||
|
|
||||||
/* Start IPv6 forwarding if we need it */
|
/* Start IPv6 forwarding if we need it */
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET6);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET6);
|
||||||
|
if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
|
||||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) {
|
|
||||||
if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) {
|
if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv6/conf/all/forwarding"), "1")) {
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
_LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv));
|
_LOGE (LOGD_SHARING, "share: error enabling IPv6 forwarding: (%d) %s", errsv, strerror (errsv));
|
||||||
|
|
@ -14544,7 +14532,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
||||||
dhcp4_address = find_dhcp4_address (self);
|
dhcp4_address = find_dhcp4_address (self);
|
||||||
|
|
||||||
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
method = nm_device_get_effective_ip_config_method (self, AF_INET);
|
||||||
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) {
|
if (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
|
|
@ -14587,7 +14575,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
||||||
if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0) {
|
if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
|
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -709,10 +709,10 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
method = nm_utils_get_ip_config_method (connection, AF_INET);
|
||||||
|
|
||||||
/* Only Disabled and Auto methods make sense for WWAN */
|
/* Only Disabled and Auto methods make sense for WWAN */
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0)
|
if (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
||||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||||
|
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) {
|
if (!nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
||||||
_LOGE ("unhandled WWAN IPv4 method '%s'; will fail", method);
|
_LOGE ("unhandled WWAN IPv4 method '%s'; will fail", method);
|
||||||
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED);
|
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED);
|
||||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
|
|
@ -826,10 +826,10 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
|
||||||
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
||||||
|
|
||||||
/* Only Ignore and Auto methods make sense for WWAN */
|
/* Only Ignore and Auto methods make sense for WWAN */
|
||||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0)
|
if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
|
||||||
return NM_ACT_STAGE_RETURN_IP_DONE;
|
return NM_ACT_STAGE_RETURN_IP_DONE;
|
||||||
|
|
||||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) != 0) {
|
if (!nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
|
||||||
_LOGW ("unhandled WWAN IPv6 method '%s'; will fail",
|
_LOGW ("unhandled WWAN IPv6 method '%s'; will fail",
|
||||||
method);
|
method);
|
||||||
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
||||||
|
|
|
||||||
|
|
@ -1031,9 +1031,9 @@ _ppp_manager_start (NMPPPManager *self,
|
||||||
|
|
||||||
/* Figure out what address methods should be enabled */
|
/* Figure out what address methods should be enabled */
|
||||||
ip4_method = nm_utils_get_ip_config_method (connection, AF_INET);
|
ip4_method = nm_utils_get_ip_config_method (connection, AF_INET);
|
||||||
ip4_enabled = g_strcmp0 (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
|
ip4_enabled = nm_streq (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
ip6_method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
ip6_method = nm_utils_get_ip_config_method (connection, AF_INET6);
|
||||||
ip6_enabled = g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0;
|
ip6_enabled = nm_streq (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||||
|
|
||||||
ppp_cmd = create_pppd_cmd_line (self,
|
ppp_cmd = create_pppd_cmd_line (self,
|
||||||
s_ppp,
|
s_ppp,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue