diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-04 15:07:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-04 15:07:13 +0200 |
commit | 43e4b1b6f786e0e3482d15415f9b0d53bd3a1b1e (patch) | |
tree | 20481f79704a97ab1cec87e29bc995857a670bf9 | |
parent | 69dc3f96c59c21caf3bd43cce8fe70fe96f804cf (diff) | |
parent | c29388bf028d404066e46ea55abc4058abce4078 (diff) | |
download | NetworkManager-43e4b1b6f786e0e3482d15415f9b0d53bd3a1b1e.tar.gz |
firewall: merge branch 'th/rh1103782_firewall_zone_conflict'
https://bugzilla.redhat.com/show_bug.cgi?id=1103782
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/devices/nm-device.c | 10 | ||||
-rw-r--r-- | src/firewall-manager/nm-firewall-manager.c | 79 | ||||
-rw-r--r-- | src/nm-policy.c | 2 |
3 files changed, 57 insertions, 34 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4d94fd0185..c4fd15a12a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4010,7 +4010,7 @@ out: static void -fw_add_to_zone_cb (GError *error, gpointer user_data) +fw_change_zone_cb (GError *error, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); @@ -4059,8 +4059,8 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self) priv->fw_call = nm_firewall_manager_add_or_change_zone (priv->fw_manager, nm_device_get_ip_iface (self), zone, - TRUE, - fw_add_to_zone_cb, + FALSE, + fw_change_zone_cb, self); } @@ -4899,7 +4899,6 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason) NMDevicePrivate *priv; NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE; NMConnection *connection = NULL; - NMSettingConnection *s_con = NULL; int ifindex; g_return_if_fail (NM_IS_DEVICE (self)); @@ -4924,10 +4923,9 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason) if (priv->act_request) connection = nm_act_request_get_connection (priv->act_request); if (connection) { - s_con = nm_connection_get_setting_connection (connection); nm_firewall_manager_remove_from_zone (priv->fw_manager, nm_device_get_ip_iface (self), - nm_setting_connection_get_zone (s_con)); + NULL); } ip_check_gw_ping_cleanup (self); diff --git a/src/firewall-manager/nm-firewall-manager.c b/src/firewall-manager/nm-firewall-manager.c index 3bf2f241b7..c99372a1d3 100644 --- a/src/firewall-manager/nm-firewall-manager.c +++ b/src/firewall-manager/nm-firewall-manager.c @@ -44,7 +44,6 @@ typedef struct { guint name_owner_id; DBusGProxy * proxy; gboolean running; - gboolean disposed; } NMFirewallManagerPrivate; enum { @@ -61,16 +60,40 @@ typedef struct { char *iface; FwAddToZoneFunc callback; gpointer user_data; + guint id; + gboolean completed; } CBInfo; static void cb_info_free (CBInfo *info) { g_return_if_fail (info != NULL); + + if (!info->completed) + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone call cancelled [%u]", info->iface, info->id); + g_free (info->iface); g_free (info); } +static CBInfo * +_cb_info_create (const char *iface, FwAddToZoneFunc callback, gpointer user_data) +{ + static guint id; + CBInfo *info; + + info = g_malloc (sizeof (CBInfo)); + if (++id == 0) + ++id; + info->id = id; + info->iface = g_strdup (iface); + info->completed = FALSE; + info->callback = callback; + info->user_data = user_data; + + return info; +} + static void add_or_change_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { @@ -83,16 +106,20 @@ add_or_change_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data G_TYPE_INVALID)) { g_assert (error); if (g_strcmp0 (error->message, "ZONE_ALREADY_SET") != 0) { - nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s", - info->iface, error->code, error->message); + nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed [%u]: (%d) %s", + info->iface, info->id, error->code, error->message); } else { - nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s", - info->iface, error->code, error->message); + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change failed [%u]: (%d) %s", + info->iface, info->id, error->code, error->message); } + } else { + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change succeeded [%u]", + info->iface, info->id); } info->callback (error, info->user_data); + info->completed = TRUE; g_free (zone); g_clear_error (&error); } @@ -114,13 +141,10 @@ nm_firewall_manager_add_or_change_zone (NMFirewallManager *self, return NULL; } - info = g_malloc0 (sizeof (*info)); - info->iface = g_strdup (iface); - info->callback = callback; - info->user_data = user_data; + info = _cb_info_create (iface, callback, user_data); - nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s%s%s", iface, add ? "add" : "change", - zone?"\"":"", zone ? zone : "default", zone?"\"":""); + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s%s%s [%u]", iface, add ? "add" : "change", + zone?"\"":"", zone ? zone : "default", zone?"\"":"", info->id); return dbus_g_proxy_begin_call_with_timeout (priv->proxy, add ? "addInterface" : "changeZone", add_or_change_cb, @@ -145,11 +169,18 @@ remove_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) g_assert (error); /* ignore UNKNOWN_INTERFACE errors */ if (error->message && !strstr (error->message, "UNKNOWN_INTERFACE")) { - nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone remove failed: (%d) %s", - info->iface, error->code, error->message); + nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone remove failed [%u]: (%d) %s", + info->iface, info->id, error->code, error->message); + } else { + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove failed [%u]: (%d) %s", + info->iface, info->id, error->code, error->message); } + } else { + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove succeeded [%u]", + info->iface, info->id); } + info->completed = TRUE; g_free (zone); g_clear_error (&error); } @@ -167,10 +198,10 @@ nm_firewall_manager_remove_from_zone (NMFirewallManager *self, return NULL; } - info = g_malloc0 (sizeof (*info)); - info->iface = g_strdup (iface); + info = _cb_info_create (iface, NULL, NULL); - nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove -> %s", iface, zone ); + nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone remove -> %s%s%s [%u]", iface, + zone?"\"":"", zone ? zone : "*", zone?"\"":"", info->id); return dbus_g_proxy_begin_call_with_timeout (priv->proxy, "removeInterface", remove_cb, @@ -247,7 +278,7 @@ nm_firewall_manager_init (NMFirewallManager * self) NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self); DBusGConnection *bus; - priv->dbus_mgr = nm_dbus_manager_get (); + priv->dbus_mgr = g_object_ref (nm_dbus_manager_get ()); priv->name_owner_id = g_signal_connect (priv->dbus_mgr, NM_DBUS_MANAGER_NAME_OWNER_CHANGED, G_CALLBACK (name_owner_changed), @@ -286,20 +317,14 @@ dispose (GObject *object) { NMFirewallManagerPrivate *priv = NM_FIREWALL_MANAGER_GET_PRIVATE (object); - if (priv->disposed) - goto out; - priv->disposed = TRUE; - if (priv->dbus_mgr) { - if (priv->name_owner_id) - g_signal_handler_disconnect (priv->dbus_mgr, priv->name_owner_id); - priv->dbus_mgr = NULL; + g_signal_handler_disconnect (priv->dbus_mgr, priv->name_owner_id); + priv->name_owner_id = 0; + g_clear_object (&priv->dbus_mgr); } - if (priv->proxy) - g_object_unref (priv->proxy); + g_clear_object (&priv->proxy); -out: /* Chain up to the parent class */ G_OBJECT_CLASS (nm_firewall_manager_parent_class)->dispose (object); } diff --git a/src/nm-policy.c b/src/nm-policy.c index 90cb13af8e..c85f3217d3 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1886,7 +1886,7 @@ firewall_started (NMFirewallManager *manager, nm_firewall_manager_add_or_change_zone (priv->fw_manager, nm_device_get_ip_iface (dev), nm_setting_connection_get_zone (s_con), - TRUE, /* add zone */ + FALSE, /* still change zone */ add_or_change_zone_cb, g_object_ref (dev)); } |