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;
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;
}
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;
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];