mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 11:20:12 +01:00
core: merge IPv4 and IPv6 versions of nm_active_connection_get_default()
This commit is contained in:
parent
3a907377ac
commit
10a46c5ae2
6 changed files with 38 additions and 52 deletions
|
|
@ -12446,7 +12446,7 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type)
|
|||
nm_assert (priv->needs_ip6_subnet == FALSE);
|
||||
|
||||
if (priv->act_request) {
|
||||
nm_active_connection_set_default (NM_ACTIVE_CONNECTION (priv->act_request), FALSE);
|
||||
nm_active_connection_set_default (NM_ACTIVE_CONNECTION (priv->act_request), AF_INET, FALSE);
|
||||
|
||||
priv->master_ready_handled = FALSE;
|
||||
nm_clear_g_signal_handler (priv->act_request, &priv->master_ready_id);
|
||||
|
|
|
|||
|
|
@ -454,10 +454,8 @@ device_state_changed (NMActiveConnection *active,
|
|||
}
|
||||
|
||||
if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|
||||
|| ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
|
||||
nm_active_connection_set_default (active, FALSE);
|
||||
nm_active_connection_set_default6 (active, FALSE);
|
||||
}
|
||||
|| ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN)
|
||||
nm_active_connection_set_default (active, AF_UNSPEC, FALSE);
|
||||
|
||||
nm_active_connection_set_state (active, ac_state, ac_state_reason);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -494,53 +494,46 @@ nm_active_connection_set_specific_object (NMActiveConnection *self,
|
|||
}
|
||||
|
||||
void
|
||||
nm_active_connection_set_default (NMActiveConnection *self, gboolean is_default)
|
||||
nm_active_connection_set_default (NMActiveConnection *self,
|
||||
int addr_family,
|
||||
gboolean is_default)
|
||||
{
|
||||
NMActiveConnectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
||||
nm_assert (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET, AF_INET6));
|
||||
|
||||
is_default = !!is_default;
|
||||
|
||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
||||
if (priv->is_default == is_default)
|
||||
return;
|
||||
|
||||
priv->is_default = is_default;
|
||||
_notify (self, PROP_DEFAULT);
|
||||
if (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET)) {
|
||||
if (priv->is_default != is_default) {
|
||||
priv->is_default = is_default;
|
||||
_notify (self, PROP_DEFAULT);
|
||||
}
|
||||
}
|
||||
if (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET6)) {
|
||||
if (priv->is_default6 != is_default) {
|
||||
priv->is_default6 = is_default;
|
||||
_notify (self, PROP_DEFAULT6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_active_connection_get_default (NMActiveConnection *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
||||
|
||||
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->is_default;
|
||||
}
|
||||
|
||||
void
|
||||
nm_active_connection_set_default6 (NMActiveConnection *self, gboolean is_default6)
|
||||
nm_active_connection_get_default (NMActiveConnection *self, int addr_family)
|
||||
{
|
||||
NMActiveConnectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
||||
|
||||
is_default6 = !!is_default6;
|
||||
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
||||
nm_assert (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET, AF_INET6));
|
||||
|
||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
||||
if (priv->is_default6 == is_default6)
|
||||
return;
|
||||
|
||||
priv->is_default6 = is_default6;
|
||||
_notify (self, PROP_DEFAULT6);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_active_connection_get_default6 (NMActiveConnection *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
||||
|
||||
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->is_default6;
|
||||
switch (addr_family) {
|
||||
case AF_INET: return priv->is_default;
|
||||
case AF_INET6: return priv->is_default6;
|
||||
default: return priv->is_default || priv->is_default6;
|
||||
}
|
||||
}
|
||||
|
||||
NMAuthSubject *
|
||||
|
|
@ -1263,10 +1256,10 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->specific_object = g_strdup (tmp);
|
||||
break;
|
||||
case PROP_DEFAULT:
|
||||
priv->is_default = !!g_value_get_boolean (value);
|
||||
priv->is_default = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_DEFAULT6:
|
||||
priv->is_default6 = !!g_value_get_boolean (value);
|
||||
priv->is_default6 = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_VPN:
|
||||
priv->vpn = g_value_get_boolean (value);
|
||||
|
|
|
|||
|
|
@ -137,14 +137,10 @@ void nm_active_connection_set_specific_object (NMActiveConnection *self
|
|||
const char *specific_object);
|
||||
|
||||
void nm_active_connection_set_default (NMActiveConnection *self,
|
||||
int addr_family,
|
||||
gboolean is_default);
|
||||
|
||||
gboolean nm_active_connection_get_default (NMActiveConnection *self);
|
||||
|
||||
void nm_active_connection_set_default6 (NMActiveConnection *self,
|
||||
gboolean is_default6);
|
||||
|
||||
gboolean nm_active_connection_get_default6 (NMActiveConnection *self);
|
||||
gboolean nm_active_connection_get_default (NMActiveConnection *self, int addr_family);
|
||||
|
||||
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -814,8 +814,7 @@ find_best_device_state (NMManager *manager)
|
|||
|
||||
switch (ac_state) {
|
||||
case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
||||
if ( nm_active_connection_get_default (ac)
|
||||
|| nm_active_connection_get_default6 (ac)) {
|
||||
if (nm_active_connection_get_default (ac, AF_UNSPEC)) {
|
||||
if (priv->connectivity_state == NM_CONNECTIVITY_FULL)
|
||||
return NM_STATE_CONNECTED_GLOBAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -819,8 +819,8 @@ update_system_hostname (NMPolicy *self, const char *msg)
|
|||
|
||||
static void
|
||||
update_default_ac (NMPolicy *self,
|
||||
NMActiveConnection *best,
|
||||
void (*set_active_func)(NMActiveConnection*, gboolean))
|
||||
int addr_family,
|
||||
NMActiveConnection *best)
|
||||
{
|
||||
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
|
||||
const CList *tmp_list;
|
||||
|
|
@ -832,12 +832,12 @@ update_default_ac (NMPolicy *self,
|
|||
*/
|
||||
nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) {
|
||||
if (ac != best)
|
||||
set_active_func (ac, FALSE);
|
||||
nm_active_connection_set_default (ac, addr_family, FALSE);
|
||||
}
|
||||
|
||||
/* Mark new default active connection */
|
||||
if (best)
|
||||
set_active_func (best, TRUE);
|
||||
nm_active_connection_set_default (best, addr_family, TRUE);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
|
|
@ -959,7 +959,7 @@ update_ip4_routing (NMPolicy *self, gboolean force_update)
|
|||
if (vpn)
|
||||
best = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (vpn));
|
||||
|
||||
update_default_ac (self, best_ac, nm_active_connection_set_default);
|
||||
update_default_ac (self, AF_INET, best_ac);
|
||||
|
||||
if (!nm_g_object_ref_set (&priv->default_device4, best))
|
||||
return;
|
||||
|
|
@ -1042,7 +1042,7 @@ update_ip6_routing (NMPolicy *self, gboolean force_update)
|
|||
if (vpn)
|
||||
best = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (vpn));
|
||||
|
||||
update_default_ac (self, best_ac, nm_active_connection_set_default6);
|
||||
update_default_ac (self, AF_INET6, best_ac);
|
||||
|
||||
if (!nm_g_object_ref_set (&priv->default_device6, best))
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue