device: Log error message if device initialization failed
authorDustin Spicuzza <dustin@virtualroadside.com>
Wed, 19 Apr 2023 17:44:56 +0000 (13:44 -0400)
committerFelix Fietkau <nbd@nbd.name>
Thu, 4 Jan 2024 12:35:43 +0000 (13:35 +0100)
Signed-off-by: Dustin Spicuzza <dustin@virtualroadside.com>
device.c

index a40e1fe64ad4edfe1d2a8105271e02e812bf822a..cb97b9ab30868ca707fe042e177495d7b6ef9c6c 100644 (file)
--- a/device.c
+++ b/device.c
@@ -758,8 +758,10 @@ int device_init_virtual(struct device *dev, struct device_type *type, const char
                int ret;
 
                ret = device_set_ifname(dev, name);
-               if (ret < 0)
+               if (ret < 0) {
+                       netifd_log_message(L_WARNING, "Failed to initalize device '%s'\n", name);
                        return ret;
+               }
        }
 
        if (!dev->set_state)
@@ -977,8 +979,11 @@ int device_set_ifname(struct device *dev, const char *name)
        if (!strcmp(dev->ifname, name))
                return 0;
 
-       if (strlen(name) > sizeof(dev->ifname) - 1)
+       if (strlen(name) > sizeof(dev->ifname) - 1) {
+               netifd_log_message(L_WARNING, "Cannot set device name: '%s' is longer than max size %zd\n",
+                       name, sizeof(dev->ifname) - 1);
                return -1;
+       }
 
        if (dev->avl.key)
                avl_delete(&devices, &dev->avl);