瀏覽代碼

[netdevice] Simplify link-down status message

For devices that start in a link-down state, the user will see a
message such as:

  [Link status: The socket is not connected (http://ipxe.org/38086001)]
  Waiting for link-up on net0...

This is potentially misleading, since it suggests that there is a
genuine problem.  Add a dedicated error message for "link down",
giving instead:

  [Link status: Down (http://ipxe.org/38086101)]
  Waiting for link-up on net0...

Reported-by: Tal Aloni <tal.aloni.il@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年之前
父節點
當前提交
1588b9336e
共有 1 個檔案被更改,包括 9 行新增3 行删除
  1. 9
    3
      src/net/netdevice.c

+ 9
- 3
src/net/netdevice.c 查看文件

@@ -46,14 +46,20 @@ struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
46 46
 /** List of open network devices, in reverse order of opening */
47 47
 static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
48 48
 
49
-/** Default link status code */
49
+/** Default unknown link status code */
50 50
 #define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
51 51
 #define EINFO_EUNKNOWN_LINK_STATUS \
52 52
 	__einfo_uniqify ( EINFO_EINPROGRESS, 0x01, "Unknown" )
53 53
 
54
-/** Human-readable message for the default link status */
54
+/** Default link-down status code */
55
+#define ENOTCONN_LINK_DOWN __einfo_error ( EINFO_ENOTCONN_LINK_DOWN )
56
+#define EINFO_ENOTCONN_LINK_DOWN \
57
+	__einfo_uniqify ( EINFO_ENOTCONN, 0x01, "Down" )
58
+
59
+/** Human-readable message for the default link statuses */
55 60
 struct errortab netdev_errors[] __errortab = {
56 61
 	__einfo_errortab ( EINFO_EUNKNOWN_LINK_STATUS ),
62
+	__einfo_errortab ( EINFO_ENOTCONN_LINK_DOWN ),
57 63
 };
58 64
 
59 65
 /**
@@ -101,7 +107,7 @@ void netdev_link_down ( struct net_device *netdev ) {
101 107
 	 */
102 108
 	if ( ( netdev->link_rc == 0 ) ||
103 109
 	     ( netdev->link_rc == -EUNKNOWN_LINK_STATUS ) ) {
104
-		netdev_link_err ( netdev, -ENOTCONN );
110
+		netdev_link_err ( netdev, -ENOTCONN_LINK_DOWN );
105 111
 	}
106 112
 }
107 113
 

Loading…
取消
儲存