From f7fe685b69e18fd9e3387770af6d7941e06ac145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0imerda?= Date: Fri, 24 May 2013 00:29:21 +0200 Subject: [PATCH] platform: detect missing firmware on IFF_UP change --- src/platform/nm-linux-platform.c | 8 ++++++++ src/platform/nm-platform.c | 2 ++ src/platform/nm-platform.h | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index b63ef1342..b8fcd46fc 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -886,6 +886,14 @@ link_change (NMPlatform *platform, int ifindex, struct rtnl_link *change) nle = rtnl_link_change (priv->nlh, rtnllink, change, 0); + /* When netlink returns this error, it usually means it failed to find + * firmware for the device, especially on nm_platform_link_set_up (). + * This is basically the same check as in the original code and could + * potentially be improved. + */ + if (nle == -NLE_OBJ_NOTFOUND) + return NM_PLATFORM_ERROR_NO_FIRMWARE; + return refresh_object (platform, (struct nl_object *) rtnllink, nle); } diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 6aeb39a45..823090d7d 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -177,6 +177,8 @@ nm_platform_get_error_msg (void) return "object already exists"; case NM_PLATFORM_ERROR_NOT_SLAVE: return "link not a slave"; + case NM_PLATFORM_ERROR_NO_FIRMWARE: + return "firmware not found"; default: return "invalid error number"; } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index eee526bd5..df967b5e4 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -42,7 +42,9 @@ typedef enum { /* object already exists */ NM_PLATFORM_ERROR_EXISTS, /* object is not a slave */ - NM_PLATFORM_ERROR_NOT_SLAVE + NM_PLATFORM_ERROR_NOT_SLAVE, + /* firmware is not found */ + NM_PLATFORM_ERROR_NO_FIRMWARE } NMPlatformError; typedef enum {