diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-02-14 15:00:05 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-02-14 15:00:05 +0100 |
commit | b4151537fbf0fa46447fa1b5a55b769b26fc7a09 (patch) | |
tree | 02d189c4ddf413998a23582214ac3f777e6d2162 | |
parent | 3e70fb20d4aabcdc3d874ae32f31a17eb5c76f60 (diff) | |
download | NetworkManager-jk/iface-rename-rh1063383.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
-rw-r--r-- | src/devices/nm-device.c | 8 | ||||
-rw-r--r-- | src/nm-manager.c | 25 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 41 |
3 files changed, 73 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index fcc6afc8ed..fc43e93e6a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5608,6 +5608,12 @@ set_property (GObject *object, guint prop_id, } } break; + case PROP_IP_IFACE: + if (g_value_get_string (value)) { + g_free (priv->ip_iface); + priv->ip_iface = g_value_dup_string (value); + } + break; case PROP_DRIVER: if (g_value_get_string (value)) { g_free (priv->driver); @@ -5881,7 +5887,7 @@ nm_device_class_init (NMDeviceClass *klass) "IP Interface", "IP Interface", NULL, - G_PARAM_READABLE)); + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_DRIVER, diff --git a/src/nm-manager.c b/src/nm-manager.c index 8d37f4b68c..aed796fa34 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2310,6 +2310,27 @@ platform_link_removed_cb (NMPlatform *platform, } static void +platform_link_changed_cb (NMPlatform *platform, + int ifindex, + NMPlatformLink *plink, + NMPlatformReason reason, + gpointer user_data) +{ + NMManager *self = NM_MANAGER (user_data); + NMDevice *device; + const char *plink_name; + + /* Handle interface renaming */ + plink_name = nm_platform_link_get_name (ifindex); + device = find_device_by_ifindex (self, ifindex); +g_print (">>>>>>> NMManager: platform_link_changed_cb: old_name: %s, device name: %s\n", nm_device_get_ip_iface (device), plink_name); + if (device) { + if (g_strcmp0 (nm_device_get_ip_iface (device), plink_name) != 0) + g_object_set (G_OBJECT (device), NM_DEVICE_IP_IFACE, plink_name, NULL); + } +} + +static void atm_device_added_cb (NMAtmManager *atm_mgr, const char *iface, const char *sysfs_path, @@ -4781,6 +4802,10 @@ nm_manager_new (NMSettings *settings, NM_PLATFORM_LINK_REMOVED, G_CALLBACK (platform_link_removed_cb), singleton); + g_signal_connect (nm_platform_get (), + NM_PLATFORM_LINK_CHANGED, + G_CALLBACK (platform_link_changed_cb), + singleton); priv->atm_mgr = nm_atm_manager_new (); g_signal_connect (priv->atm_mgr, 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); } /******************************************************************/ |