]> err.no Git - systemd/commitdiff
check ifindex > 0 instead of subsystem == "net"
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 14 Dec 2010 10:27:02 +0000 (11:27 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 14 Dec 2010 10:27:02 +0000 (11:27 +0100)
libudev/libudev-device.c
udev/udev-event.c
udev/udev-rules.c

index 8698d98e1c6871ee7ea3c2ddf88f95c75fe2fa95..8b0cccd533f01a76ff7ae5108c12691c999f9f34 100644 (file)
@@ -1287,7 +1287,7 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device)
                                     major(udev_device_get_devnum(udev_device)),
                                     minor(udev_device_get_devnum(udev_device))) < 0)
                                udev_device->id_filename = NULL;
-               } else if (strcmp(udev_device_get_subsystem(udev_device), "net") == 0) {
+               } else if (udev_device_get_ifindex(udev_device) > 0) {
                        /* use netdev ifindex -- n3 */
                        if (asprintf(&udev_device->id_filename, "n%u", udev_device_get_ifindex(udev_device)) < 0)
                                udev_device->id_filename = NULL;
@@ -1582,6 +1582,8 @@ int udev_device_set_watch_handle(struct udev_device *udev_device, int handle)
 
 int udev_device_get_ifindex(struct udev_device *udev_device)
 {
+       if (!udev_device->info_loaded)
+               udev_device_read_uevent_file(udev_device);
        return udev_device->ifindex;
 }
 
index f41f06b16a0b29a93d6c5e4f0bf3cba3a2a0db85..02a1767b1f8d7bd78c5d66af37344d3f66bc571e 100644 (file)
@@ -564,7 +564,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
                udev_rules_apply_to_event(rules, event);
 
                /* rename a new network interface, if needed */
-               if (strcmp(udev_device_get_subsystem(dev), "net") == 0 && strcmp(udev_device_get_action(dev), "add") == 0 &&
+               if (udev_device_get_ifindex(dev) > 0 && strcmp(udev_device_get_action(dev), "add") == 0 &&
                    event->name != NULL && strcmp(event->name, udev_device_get_sysname(dev)) != 0) {
                        char syspath[UTIL_PATH_SIZE];
                        char *pos;
index ab7b6aedb977e16f39687ebc39c017dea75c332f..6b473c4c2ef8a4c116f5a0e740e96d3eab9de7b7 100644 (file)
@@ -2080,7 +2080,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
 
        can_set_name = ((strcmp(udev_device_get_action(event->dev), "remove") != 0) &&
                        (major(udev_device_get_devnum(event->dev)) > 0 ||
-                        strcmp(udev_device_get_subsystem(event->dev), "net") == 0));
+                        udev_device_get_ifindex(event->dev) > 0));
 
        /* loop through token list, match, run actions or forward to next rule */
        cur = &rules->tokens[0];