summaryrefslogtreecommitdiff
path: root/src/udev/udev-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev/udev-event.c')
-rw-r--r--src/udev/udev-event.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index beb09439c7..e5b2259fda 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -846,23 +846,25 @@ void udev_event_execute_rules(struct udev_event *event,
/* rename a new network interface, if needed */
if (udev_device_get_ifindex(dev) > 0 && streq(udev_device_get_action(dev), "add") &&
event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
- char syspath[UTIL_PATH_SIZE];
- char *pos;
int r;
r = rename_netif(event);
- if (r >= 0) {
- /* remember old name */
- udev_device_add_property(dev, "INTERFACE_OLD", udev_device_get_sysname(dev));
+ if (r < 0)
+ log_warning_errno(r, "could not rename interface '%d' from '%s' to '%s': %m", udev_device_get_ifindex(dev),
+ udev_device_get_sysname(dev), event->name);
+ else {
+ const char *interface_old;
- /* now change the devpath, because the kernel device name has changed */
- strscpy(syspath, sizeof(syspath), udev_device_get_syspath(dev));
- pos = strrchr(syspath, '/');
- if (pos != NULL) {
- pos++;
- strscpy(pos, sizeof(syspath) - (pos - syspath), event->name);
- udev_device_set_syspath(event->dev, syspath);
- udev_device_add_property(dev, "INTERFACE", udev_device_get_sysname(dev));
+ /* remember old name */
+ interface_old = udev_device_get_sysname(dev);
+
+ r = udev_device_rename(dev, event->name);
+ if (r < 0)
+ log_warning_errno(r, "renamed interface '%d' from '%s' to '%s', but could not update udev_device: %m",
+ udev_device_get_ifindex(dev), udev_device_get_sysname(dev), event->name);
+ else {
+ udev_device_add_property(dev, "INTERFACE_OLD", interface_old);
+ udev_device_add_property(dev, "INTERFACE", event->name);
log_debug("changed devpath to '%s'", udev_device_get_devpath(dev));
}
}