summaryrefslogtreecommitdiff
path: root/src/platform/nm-linux-platform.c
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-02-14 15:00:05 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-02-14 15:00:05 +0100
commitb4151537fbf0fa46447fa1b5a55b769b26fc7a09 (patch)
tree02d189c4ddf413998a23582214ac3f777e6d2162 /src/platform/nm-linux-platform.c
parent3e70fb20d4aabcdc3d874ae32f31a17eb5c76f60 (diff)
downloadNetworkManager-b4151537fbf0fa46447fa1b5a55b769b26fc7a09.tar.gz
---wip--- core, platform: handle interface name renaming (rh #1063383)jk/iface-rename-rh1063383
https://bugzilla.redhat.com/show_bug.cgi?id=1063383 https://bugzilla.redhat.com/show_bug.cgi?id=1063379
Diffstat (limited to 'src/platform/nm-linux-platform.c')
-rw-r--r--src/platform/nm-linux-platform.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 81630fe60b..9f3da20068 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2742,6 +2742,45 @@ udev_device_removed (NMPlatform *platform,
}
static void
+udev_device_changed (NMPlatform *platform,
+ GUdevDevice *udev_device)
+{
+ NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
+ const char *ifname;
+ int ifindex;
+
+ ifname = g_udev_device_get_name (udev_device);
+ if (!ifname) {
+ debug ("failed to get device's interface");
+ return;
+ }
+
+ if (g_udev_device_get_property (udev_device, "IFINDEX"))
+ ifindex = g_udev_device_get_property_as_int (udev_device, "IFINDEX");
+ else {
+ warning ("(%s): failed to get device's ifindex", ifname);
+ return;
+ }
+
+// if (!g_hash_table_lookup (priv->udev_devices, GINT_TO_POINTER (info->ifindex))) {
+// debug ("(%s): failed to get device's ifindex", ifname, ifindex);
+// return;
+// }
+
+ /* Replace the old udev device with the new one */
+ g_hash_table_insert (priv->udev_devices, GINT_TO_POINTER (ifindex),
+ g_object_ref (udev_device));
+
+ /* Announce device 'move'. */
+ if (ifindex) {
+ auto_nl_object struct rtnl_link *rtnllink = rtnl_link_get (priv->link_cache, ifindex);
+
+ if (rtnllink)
+ announce_object (platform, (struct nl_object *) rtnllink, CHANGED, NM_PLATFORM_REASON_EXTERNAL);
+ }
+}
+
+static void
handle_udev_event (GUdevClient *client,
const char *action,
GUdevDevice *udev_device,
@@ -2768,6 +2807,8 @@ handle_udev_event (GUdevClient *client,
udev_device_added (platform, udev_device);
if (!strcmp (action, "remove"))
udev_device_removed (platform, udev_device);
+ if (!strcmp (action, "move"))
+ udev_device_changed (platform, udev_device);
}
/******************************************************************/