[ipxe-devel] [PATCH] rndis: register netdev with MAC filled

Roman Kagan rkagan at virtuozzo.com
Fri Jun 1 06:59:01 UTC 2018


register_netdev expects ->hw_addr and ->ll_addr to be already filled, so
move it towards the end of register_rndis, after the respective fields
have been successfully queried from the underlying device.

Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 src/net/rndis.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/net/rndis.c b/src/net/rndis.c
index 8c4fe8b3..f8a9f829 100644
--- a/src/net/rndis.c
+++ b/src/net/rndis.c
@@ -973,13 +973,6 @@ int register_rndis ( struct rndis_device *rndis ) {
 	/* Assign device name (for debugging) */
 	rndis->name = netdev->dev->name;
 
-	/* Register network device */
-	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
-		DBGC ( rndis, "RNDIS %s could not register: %s\n",
-		       rndis->name, strerror ( rc ) );
-		goto err_register;
-	}
-
 	/* Open RNDIS device to read MAC addresses */
 	if ( ( rc = rndis->op->open ( rndis ) ) != 0 ) {
 		DBGC ( rndis, "RNDIS %s could not open: %s\n",
@@ -1012,6 +1005,13 @@ int register_rndis ( struct rndis_device *rndis ) {
 	/* Close RNDIS device */
 	rndis->op->close ( rndis );
 
+	/* Register network device */
+	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
+		DBGC ( rndis, "RNDIS %s could not register: %s\n",
+		       rndis->name, strerror ( rc ) );
+		goto err_register;
+	}
+
 	return 0;
 
  err_query_link:
@@ -1021,7 +1021,6 @@ int register_rndis ( struct rndis_device *rndis ) {
  err_initialise:
 	rndis->op->close ( rndis );
  err_open:
-	unregister_netdev ( netdev );
  err_register:
 	return rc;
 }
-- 
2.17.0




More information about the ipxe-devel mailing list