mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02: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);
|
nm_assert (priv->needs_ip6_subnet == FALSE);
|
||||||
|
|
||||||
if (priv->act_request) {
|
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;
|
priv->master_ready_handled = FALSE;
|
||||||
nm_clear_g_signal_handler (priv->act_request, &priv->master_ready_id);
|
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
|
if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|
||||||
|| ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
|
|| ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN)
|
||||||
nm_active_connection_set_default (active, FALSE);
|
nm_active_connection_set_default (active, AF_UNSPEC, FALSE);
|
||||||
nm_active_connection_set_default6 (active, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
nm_active_connection_set_state (active, ac_state, ac_state_reason);
|
nm_active_connection_set_state (active, ac_state, ac_state_reason);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -494,53 +494,46 @@ nm_active_connection_set_specific_object (NMActiveConnection *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
NMActiveConnectionPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
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;
|
is_default = !!is_default;
|
||||||
|
|
||||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
||||||
if (priv->is_default == is_default)
|
if (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET)) {
|
||||||
return;
|
if (priv->is_default != is_default) {
|
||||||
|
priv->is_default = is_default;
|
||||||
priv->is_default = is_default;
|
_notify (self, PROP_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
|
gboolean
|
||||||
nm_active_connection_get_default (NMActiveConnection *self)
|
nm_active_connection_get_default (NMActiveConnection *self, int addr_family)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
NMActiveConnectionPrivate *priv;
|
NMActiveConnectionPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
||||||
|
nm_assert (NM_IN_SET (addr_family, AF_UNSPEC, AF_INET, AF_INET6));
|
||||||
is_default6 = !!is_default6;
|
|
||||||
|
|
||||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
||||||
if (priv->is_default6 == is_default6)
|
switch (addr_family) {
|
||||||
return;
|
case AF_INET: return priv->is_default;
|
||||||
|
case AF_INET6: return priv->is_default6;
|
||||||
priv->is_default6 = is_default6;
|
default: return priv->is_default || priv->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NMAuthSubject *
|
NMAuthSubject *
|
||||||
|
|
@ -1263,10 +1256,10 @@ set_property (GObject *object, guint prop_id,
|
||||||
priv->specific_object = g_strdup (tmp);
|
priv->specific_object = g_strdup (tmp);
|
||||||
break;
|
break;
|
||||||
case PROP_DEFAULT:
|
case PROP_DEFAULT:
|
||||||
priv->is_default = !!g_value_get_boolean (value);
|
priv->is_default = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
case PROP_DEFAULT6:
|
case PROP_DEFAULT6:
|
||||||
priv->is_default6 = !!g_value_get_boolean (value);
|
priv->is_default6 = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
case PROP_VPN:
|
case PROP_VPN:
|
||||||
priv->vpn = g_value_get_boolean (value);
|
priv->vpn = g_value_get_boolean (value);
|
||||||
|
|
|
||||||
|
|
@ -137,14 +137,10 @@ void nm_active_connection_set_specific_object (NMActiveConnection *self
|
||||||
const char *specific_object);
|
const char *specific_object);
|
||||||
|
|
||||||
void nm_active_connection_set_default (NMActiveConnection *self,
|
void nm_active_connection_set_default (NMActiveConnection *self,
|
||||||
|
int addr_family,
|
||||||
gboolean is_default);
|
gboolean is_default);
|
||||||
|
|
||||||
gboolean nm_active_connection_get_default (NMActiveConnection *self);
|
gboolean nm_active_connection_get_default (NMActiveConnection *self, int addr_family);
|
||||||
|
|
||||||
void nm_active_connection_set_default6 (NMActiveConnection *self,
|
|
||||||
gboolean is_default6);
|
|
||||||
|
|
||||||
gboolean nm_active_connection_get_default6 (NMActiveConnection *self);
|
|
||||||
|
|
||||||
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *self);
|
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *self);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -814,8 +814,7 @@ find_best_device_state (NMManager *manager)
|
||||||
|
|
||||||
switch (ac_state) {
|
switch (ac_state) {
|
||||||
case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
||||||
if ( nm_active_connection_get_default (ac)
|
if (nm_active_connection_get_default (ac, AF_UNSPEC)) {
|
||||||
|| nm_active_connection_get_default6 (ac)) {
|
|
||||||
if (priv->connectivity_state == NM_CONNECTIVITY_FULL)
|
if (priv->connectivity_state == NM_CONNECTIVITY_FULL)
|
||||||
return NM_STATE_CONNECTED_GLOBAL;
|
return NM_STATE_CONNECTED_GLOBAL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -819,8 +819,8 @@ update_system_hostname (NMPolicy *self, const char *msg)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_default_ac (NMPolicy *self,
|
update_default_ac (NMPolicy *self,
|
||||||
NMActiveConnection *best,
|
int addr_family,
|
||||||
void (*set_active_func)(NMActiveConnection*, gboolean))
|
NMActiveConnection *best)
|
||||||
{
|
{
|
||||||
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
|
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
|
||||||
const CList *tmp_list;
|
const CList *tmp_list;
|
||||||
|
|
@ -832,12 +832,12 @@ update_default_ac (NMPolicy *self,
|
||||||
*/
|
*/
|
||||||
nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) {
|
nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) {
|
||||||
if (ac != best)
|
if (ac != best)
|
||||||
set_active_func (ac, FALSE);
|
nm_active_connection_set_default (ac, addr_family, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark new default active connection */
|
/* Mark new default active connection */
|
||||||
if (best)
|
if (best)
|
||||||
set_active_func (best, TRUE);
|
nm_active_connection_set_default (best, addr_family, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
|
|
@ -959,7 +959,7 @@ update_ip4_routing (NMPolicy *self, gboolean force_update)
|
||||||
if (vpn)
|
if (vpn)
|
||||||
best = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (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))
|
if (!nm_g_object_ref_set (&priv->default_device4, best))
|
||||||
return;
|
return;
|
||||||
|
|
@ -1042,7 +1042,7 @@ update_ip6_routing (NMPolicy *self, gboolean force_update)
|
||||||
if (vpn)
|
if (vpn)
|
||||||
best = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (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))
|
if (!nm_g_object_ref_set (&priv->default_device6, best))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue