From 22d3ade38438a1a28f67422d5c2ad9cde177e351 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 7 Jan 2025 11:52:48 +0000 Subject: [PATCH] devether: don't print link-status until netif is initialized --- sys/src/9/port/devether.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/src/9/port/devether.c b/sys/src/9/port/devether.c index 557e6e16b..8a12ac989 100644 --- a/sys/src/9/port/devether.c +++ b/sys/src/9/port/devether.c @@ -410,6 +410,7 @@ etherprobe(int cardno, int ctlrno, char *conf) ether->irq = -1; ether->ctlrno = ctlrno; ether->mbps = 10; + ether->link = 0; ether->minmtu = ETHERMINTU; ether->maxmtu = ETHERMAXTU; @@ -422,19 +423,15 @@ etherprobe(int cardno, int ctlrno, char *conf) memmove(ðer->opt[0], ðer->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, ðer->opt[i][3])) 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 @@ ethersetspeed(Ether *ether, int mbps) 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 @@ ethersetlink(Ether *ether, int link) 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);