|
@@ -62,6 +62,23 @@ struct errortab netdev_errors[] __errortab = {
|
62
|
62
|
__einfo_errortab ( EINFO_ENOTCONN_LINK_DOWN ),
|
63
|
63
|
};
|
64
|
64
|
|
|
65
|
+/**
|
|
66
|
+ * Check whether or not network device has a link-layer address
|
|
67
|
+ *
|
|
68
|
+ * @v netdev Network device
|
|
69
|
+ * @ret has_ll_addr Network device has a link-layer address
|
|
70
|
+ */
|
|
71
|
+static int netdev_has_ll_addr ( struct net_device *netdev ) {
|
|
72
|
+ uint8_t *ll_addr = netdev->ll_addr;
|
|
73
|
+ size_t remaining = sizeof ( netdev->ll_addr );
|
|
74
|
+
|
|
75
|
+ while ( remaining-- ) {
|
|
76
|
+ if ( *(ll_addr++) != 0 )
|
|
77
|
+ return 1;
|
|
78
|
+ }
|
|
79
|
+ return 0;
|
|
80
|
+}
|
|
81
|
+
|
65
|
82
|
/**
|
66
|
83
|
* Notify drivers of network device or link state change
|
67
|
84
|
*
|
|
@@ -432,8 +449,11 @@ int register_netdev ( struct net_device *netdev ) {
|
432
|
449
|
ifindex++ );
|
433
|
450
|
}
|
434
|
451
|
|
435
|
|
- /* Set initial link-layer address */
|
436
|
|
- netdev->ll_protocol->init_addr ( netdev->hw_addr, netdev->ll_addr );
|
|
452
|
+ /* Set initial link-layer address, if not already set */
|
|
453
|
+ if ( ! netdev_has_ll_addr ( netdev ) ) {
|
|
454
|
+ netdev->ll_protocol->init_addr ( netdev->hw_addr,
|
|
455
|
+ netdev->ll_addr );
|
|
456
|
+ }
|
437
|
457
|
|
438
|
458
|
/* Add to device list */
|
439
|
459
|
netdev_get ( netdev );
|