summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-09-07 12:02:54 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-09-18 11:48:37 +0200
commit94fea0b581ef3b01f78de59faac883ec16bb39b4 (patch)
tree6520973af8307a2745b42648f8907bd15b0be283
parent54afd0400bf940b87c973418fd3a7ef605f1c458 (diff)
downloadNetworkManager-94fea0b581ef3b01f78de59faac883ec16bb39b4.tar.gz
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.
-rw-r--r--src/nm-policy.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c
index b01110bfbb..b22608b530 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -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;
+
+ /* 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;
+ }
+ }
- firewall_update_zone (policy, connection);
+ if (device)
+ firewall_update_zone (policy, connection, device);
schedule_activate_all (policy);
}