diff options
| author | Michael Biebl <biebl@debian.org> | 2013-01-29 00:58:35 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2013-01-29 00:58:54 +0100 |
| commit | 422513e768d88a30fd7d56d62c61989341c0810b (patch) | |
| tree | 21aee95b05e339e2fdd66527b230e218b25541a9 /debian | |
| parent | 6f0ae6b0f1bee0940528bb2de39527b65b1c204e (diff) | |
Set global online state to CONNECTED when unmanaged devices are active
debian/patches/05-force-online-with-unmanaged-devices.patch: If network interfaces are configured in /etc/network/interfaces, NM will mark those devices as unmanaged by default. If such a network interface has been brought up by ifup, set the global online state to CONNECTED. (Closes: #512286)
Diffstat (limited to 'debian')
| -rw-r--r-- | debian/changelog | 5 | ||||
| -rw-r--r-- | debian/patches/05-force-online-with-unmanaged-devices.patch | 154 | ||||
| -rw-r--r-- | debian/patches/series | 1 |
3 files changed, 160 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 6c7753a6..1d7f8742 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,11 @@ network-manager (0.9.4.0-9) UNRELEASED; urgency=low depending on whether the connection has a valid IPv4 or IPv6 address. Using "NetworkManager" as ADDRFAM type did confuse most ifupdown hook scripts and e.g. broke async NFS mounts. (Closes: #475188, #656584) + * debian/patches/05-force-online-with-unmanaged-devices.patch: If network + interfaces are configured in /etc/network/interfaces, NM will mark those + devices as unmanaged by default. If such a network interface has been + brought up by ifup, set the global online state to CONNECTED. + (Closes: #512286) -- Michael Biebl <biebl@debian.org> Mon, 28 Jan 2013 18:25:50 +0100 diff --git a/debian/patches/05-force-online-with-unmanaged-devices.patch b/debian/patches/05-force-online-with-unmanaged-devices.patch new file mode 100644 index 00000000..30cd02b0 --- /dev/null +++ b/debian/patches/05-force-online-with-unmanaged-devices.patch @@ -0,0 +1,154 @@ +Description: Force online state with unmanaged devices + If we have unmanaged devices in /e/n/i, monitor the ifupdown state file + and in case we find active interfaces besides lo, forcefully set the + online state to CONNECTED. +Author: Michael Biebl <biebl@debian.org> +Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=512286 +Index: network-manager/src/nm-manager.c +=================================================================== +--- network-manager.orig/src/nm-manager.c 2013-01-15 14:18:54.847100261 +0100 ++++ network-manager/src/nm-manager.c 2013-01-15 14:22:20.945799751 +0100 +@@ -79,6 +79,8 @@ + + #define UPOWER_DBUS_SERVICE "org.freedesktop.UPower" + ++#define IFUPDOWN_STATE_FILE "/run/network/ifstate" ++ + static gboolean impl_manager_get_devices (NMManager *manager, + GPtrArray **devices, + GError **err); +@@ -237,6 +239,11 @@ + guint fw_monitor_id; + guint fw_changed_id; + ++ /* ifupdown state file monitor */ ++ GFileMonitor *ifstate_monitor; ++ guint ifstate_monitor_id; ++ gboolean ifstate_force_online; ++ + guint timestamp_update_id; + + gboolean disposed; +@@ -448,6 +455,14 @@ + break; + } + ++ if (state == NM_DEVICE_STATE_UNMANAGED) { ++ const char *iface = nm_device_get_ip_iface (dev); ++ if (priv->ifstate_force_online) { ++ new_state = NM_STATE_CONNECTED; ++ nm_log_dbg (LOGD_CORE, "Unmanaged device found: %s; state CONNECTED forced.", iface); ++ } ++ } ++ + if (nm_device_is_activating (dev)) + new_state = NM_STATE_CONNECTING; + else if (new_state != NM_STATE_CONNECTING) { +@@ -3766,6 +3781,65 @@ + } + } + ++static void ++check_ifstate_file (gpointer user_data) ++{ ++ NMManager *self = NM_MANAGER (user_data); ++ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); ++ GIOChannel *channel; ++ gchar *line; ++ gboolean online = FALSE; ++ ++ channel = g_io_channel_new_file (IFUPDOWN_STATE_FILE, "r", NULL); ++ if (!channel) { ++ nm_log_warn (LOGD_CORE, "Error: failed to open %s", IFUPDOWN_STATE_FILE); ++ return; ++ } ++ ++ while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL) ++ != G_IO_STATUS_EOF && !online) { ++ g_strstrip (line); ++ if (strlen (line) > 0 && g_strcmp0 (line, "lo=lo") != 0) { ++ online = TRUE; ++ } ++ g_free (line); ++ } ++ ++ g_io_channel_shutdown (channel, FALSE, NULL); ++ g_io_channel_unref (channel); ++ ++ if (priv->ifstate_force_online != online) { ++ priv->ifstate_force_online = online; ++ nm_manager_update_state (self); ++ } ++} ++ ++static void ++ifstate_file_changed (GFileMonitor *monitor, ++ GFile *file, ++ GFile *other_file, ++ GFileMonitorEvent event_type, ++ gpointer user_data) ++{ ++ NMManager *self = NM_MANAGER (user_data); ++ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); ++ ++ switch (event_type) { ++// case G_FILE_MONITOR_EVENT_CREATED: ++//#if GLIB_CHECK_VERSION(2,23,4) ++// case G_FILE_MONITOR_EVENT_MOVED: ++//#endif ++// case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: ++ case G_FILE_MONITOR_EVENT_CHANGED: ++ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: ++ nm_log_dbg (LOGD_CORE, "ifupdown state file %s was changed", IFUPDOWN_STATE_FILE); ++ check_ifstate_file (user_data); ++ break; ++ default: ++ break; ++ } ++} ++ + #define PERM_DENIED_ERROR "org.freedesktop.NetworkManager.PermissionDenied" + + static void +@@ -4121,6 +4195,17 @@ + g_object_unref (priv->fw_monitor); + } + ++ if (priv->ifstate_monitor) { ++ if (priv->ifstate_monitor_id) ++ g_signal_handler_disconnect (priv->ifstate_monitor, priv->ifstate_monitor_id); ++ ++ if (priv->ifstate_force_online) ++ g_source_remove (priv->ifstate_force_online); ++ ++ g_file_monitor_cancel (priv->ifstate_monitor); ++ g_object_unref (priv->ifstate_monitor); ++ } ++ + g_slist_free (priv->factories); + + if (priv->timestamp_update_id) { +@@ -4469,6 +4554,23 @@ + KERNEL_FIRMWARE_DIR); + } + ++ /* Monitor the ifupdown state file */ ++ file = g_file_new_for_path (IFUPDOWN_STATE_FILE); ++ priv->ifstate_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); ++ g_object_unref (file); ++ ++ if (priv->ifstate_monitor) { ++ priv->ifstate_monitor_id = g_signal_connect (priv->ifstate_monitor, "changed", ++ G_CALLBACK (ifstate_file_changed), ++ manager); ++ nm_log_info (LOGD_CORE, "monitoring ifupdown state file '%s'.", ++ IFUPDOWN_STATE_FILE); ++ } else { ++ nm_log_warn (LOGD_CORE, "failed to monitor ifupdown state file '%s'.", ++ IFUPDOWN_STATE_FILE); ++ } ++ priv->ifstate_force_online = FALSE; ++ + load_device_factories (manager); + + /* Update timestamps in active connections */ diff --git a/debian/patches/series b/debian/patches/series index ed9f3f03..3c1f2808 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,6 +2,7 @@ 02-dbus_access_network_manager.patch 03-systemd.patch 04-systemd-set-kill-mode-process.patch +05-force-online-with-unmanaged-devices.patch 10-format-security.patch 11-initialize-nm-remote-settings.patch 12-initialize-gerror.patch |