device: move have_ip6_address() to nm_ip6_config_get_address_first_nontentative()

This commit is contained in:
Thomas Haller
2016-01-30 22:28:23 +01:00
parent 5ff8decb8f
commit 9ff161b2a1
3 changed files with 28 additions and 27 deletions

View File

@@ -405,7 +405,6 @@ static void nm_device_slave_notify_enslave (NMDevice *self, gboolean success);
static void nm_device_slave_notify_release (NMDevice *self, NMDeviceStateReason reason);
static gboolean addrconf6_start_with_link_ready (NMDevice *self);
static gboolean dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection);
static NMActStageReturn linklocal6_start (NMDevice *self);
static void _carrier_wait_check_queued_act_request (NMDevice *self);
@@ -5397,27 +5396,6 @@ nm_device_dhcp6_renew (NMDevice *self, gboolean release)
/******************************************/
static gboolean
have_ip6_address (const NMIP6Config *ip6_config, gboolean linklocal)
{
guint i;
if (!ip6_config)
return FALSE;
linklocal = !!linklocal;
for (i = 0; i < nm_ip6_config_get_num_addresses (ip6_config); i++) {
const NMPlatformIP6Address *addr = nm_ip6_config_get_address (ip6_config, i);
if ((IN6_IS_ADDR_LINKLOCAL (&addr->address) == linklocal) &&
!(addr->flags & IFA_F_TENTATIVE))
return TRUE;
}
return FALSE;
}
static void
linklocal6_cleanup (NMDevice *self)
{
@@ -5451,7 +5429,7 @@ linklocal6_complete (NMDevice *self)
const char *method;
g_assert (priv->linklocal6_timeout_id);
g_assert (have_ip6_address (priv->ip6_config, TRUE));
g_assert (nm_ip6_config_get_address_first_nontentative (priv->ip6_config, TRUE));
linklocal6_cleanup (self);
@@ -5568,7 +5546,7 @@ linklocal6_start (NMDevice *self)
linklocal6_cleanup (self);
if (have_ip6_address (priv->ip6_config, TRUE))
if (nm_ip6_config_get_address_first_nontentative (priv->ip6_config, TRUE))
return NM_ACT_STAGE_RETURN_FINISH;
connection = nm_device_get_applied_connection (self);
@@ -5803,7 +5781,7 @@ rdisc_ra_timeout (NMRDisc *rdisc, NMDevice *self)
* IPv6 configuration, like manual IPv6 addresses or external IPv6
* config, consider that sufficient for IPv6 success.
*/
if (have_ip6_address (priv->ip6_config, FALSE))
if (nm_ip6_config_get_address_first_nontentative (priv->ip6_config, FALSE))
nm_device_activate_schedule_ip6_config_result (self);
else
nm_device_activate_schedule_ip6_config_timeout (self);
@@ -8735,7 +8713,7 @@ update_ip6_config (NMDevice *self, gboolean initial)
if ( priv->linklocal6_timeout_id
&& priv->ext_ip6_config_captured
&& have_ip6_address (priv->ext_ip6_config_captured, TRUE)) {
&& nm_ip6_config_get_address_first_nontentative (priv->ext_ip6_config_captured, TRUE)) {
/* linklocal6 is ready now, do the state transition... we are also
* invoked as g_idle_add, so no problems with reentrance doing it now.
*/

View File

@@ -1362,6 +1362,29 @@ nm_ip6_config_address_exists (const NMIP6Config *config,
return _addresses_get_index (config, needle) >= 0;
}
const NMPlatformIP6Address *
nm_ip6_config_get_address_first_nontentative (const NMIP6Config *config, gboolean linklocal)
{
NMIP6ConfigPrivate *priv;
guint i;
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
priv = NM_IP6_CONFIG_GET_PRIVATE (config);
linklocal = !!linklocal;
for (i = 0; i < priv->addresses->len; i++) {
const NMPlatformIP6Address *addr = &g_array_index (priv->addresses, NMPlatformIP6Address, i);
if ( ((!!IN6_IS_ADDR_LINKLOCAL (&addr->address)) == linklocal)
&& !(addr->flags & IFA_F_TENTATIVE))
return addr;
}
return NULL;
}
/******************************************************************/
void

View File

@@ -97,10 +97,10 @@ void nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address
void nm_ip6_config_del_address (NMIP6Config *config, guint i);
guint nm_ip6_config_get_num_addresses (const NMIP6Config *config);
const NMPlatformIP6Address *nm_ip6_config_get_address (const NMIP6Config *config, guint i);
const NMPlatformIP6Address *nm_ip6_config_get_address_first_nontentative (const NMIP6Config *config, gboolean linklocal);
gboolean nm_ip6_config_address_exists (const NMIP6Config *config, const NMPlatformIP6Address *address);
gboolean nm_ip6_config_addresses_sort (NMIP6Config *config, NMSettingIP6ConfigPrivacy use_temporary);
/* Routes */
void nm_ip6_config_reset_routes (NMIP6Config *config);
void nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *route);