mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 03:40:07 +01:00
policy: refactor handling of UPDATED signal
Obtain a reference to the device in connection_updated() so that it will be easier to call other functions needing it.
This commit is contained in:
parent
54afd0400b
commit
94fea0b581
1 changed files with 24 additions and 17 deletions
|
|
@ -1563,26 +1563,19 @@ add_or_change_zone_cb (GError *error, gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
firewall_update_zone (NMPolicy *policy, NMConnection *connection)
|
||||
firewall_update_zone (NMPolicy *policy, NMConnection *connection, NMDevice *device)
|
||||
{
|
||||
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
|
||||
const GSList *iter;
|
||||
|
||||
/* find dev with passed connection and change zone its interface belongs to */
|
||||
for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) {
|
||||
NMDevice *dev = NM_DEVICE (iter->data);
|
||||
|
||||
if ( (nm_device_get_connection (dev) == connection)
|
||||
&& (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED)
|
||||
&& !nm_device_uses_assumed_connection (dev)) {
|
||||
nm_firewall_manager_add_or_change_zone (priv->firewall_manager,
|
||||
nm_device_get_ip_iface (dev),
|
||||
nm_setting_connection_get_zone (s_con),
|
||||
FALSE, /* change zone */
|
||||
add_or_change_zone_cb,
|
||||
g_object_ref (dev));
|
||||
}
|
||||
if ( nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED
|
||||
&& !nm_device_uses_assumed_connection (device)) {
|
||||
nm_firewall_manager_add_or_change_zone (priv->firewall_manager,
|
||||
nm_device_get_ip_iface (device),
|
||||
nm_setting_connection_get_zone (s_con),
|
||||
FALSE, /* change zone */
|
||||
add_or_change_zone_cb,
|
||||
g_object_ref (device));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1656,8 +1649,22 @@ connection_updated (NMSettings *settings,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMPolicy *policy = (NMPolicy *) user_data;
|
||||
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
|
||||
const GSList *iter;
|
||||
NMDevice *device = NULL;
|
||||
|
||||
firewall_update_zone (policy, connection);
|
||||
/* find device with given connection */
|
||||
for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) {
|
||||
NMDevice *dev = NM_DEVICE (iter->data);
|
||||
|
||||
if (nm_device_get_connection (dev) == connection) {
|
||||
device = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (device)
|
||||
firewall_update_zone (policy, connection, device);
|
||||
|
||||
schedule_activate_all (policy);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue