shithub: riscv

Download patch

ref: 22d3ade38438a1a28f67422d5c2ad9cde177e351
parent: 705a2c3c28d61447487abd48b3db58450f8e70e0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jan 7 06:52:48 EST 2025

devether: don't print link-status until netif is initialized

--- a/sys/src/9/port/devether.c
+++ b/sys/src/9/port/devether.c
@@ -410,6 +410,7 @@
 	ether->irq = -1;
 	ether->ctlrno = ctlrno;
 	ether->mbps = 10;
+	ether->link = 0;
 	ether->minmtu = ETHERMINTU;
 	ether->maxmtu = ETHERMAXTU;
 
@@ -422,13 +423,6 @@
 			memmove(&ether->opt[0], &ether->opt[1], --ether->nopt*sizeof(ether->opt[0]));
 		} else if(isaconfig("ether", ctlrno, ether) == 0)
 			goto Nope;
-
-		for(cardno = 0; cards[cardno].type != nil; cardno++)
-			if(cistrcmp(cards[cardno].type, ether->type) == 0)
-				break;
-		if(cards[cardno].type == nil)
-			goto Nope;
-
 		for(i = 0; i < ether->nopt; i++){
 			if(strncmp(ether->opt[i], "ea=", 3) == 0){
 				if(parseether(ether->ea, &ether->opt[i][3]))
@@ -435,6 +429,9 @@
 					memset(ether->ea, 0, Eaddrlen);
 			}
 		}
+		for(cardno = 0; cards[cardno].type != nil; cardno++)
+			if(cistrcmp(cards[cardno].type, ether->type) == 0)
+				break;
 	}
 	if(cardno >= MaxEther || cards[cardno].type == nil)
 		goto Nope;
@@ -471,8 +468,10 @@
 	if(ether->mbps == mbps)
 		return;
 	ether->mbps = mbps;
-	if(mbps <= 0 || ether->oq == nil)
+
+	if(mbps <= 0 || ether->f == nil || ether->oq == nil)
 		return;
+
 	netifsetlimit(ether, etherqueuesize(ether));
 	qsetlimit(ether->oq, ether->limit);
 }
@@ -484,6 +483,10 @@
 	if(!!ether->link == link)
 		return;
 	ether->link = link;
+
+	if(ether->f == nil)
+		return;
+
 	if(link)
 		print("#l%d: %s: link up: %dMbps\n",
 			ether->ctlrno, ether->type, ether->mbps);
--