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

This commit is contained in:
cinap_lenrek 2025-01-07 11:52:48 +00:00
parent 705a2c3c28
commit 22d3ade384

View file

@ -410,6 +410,7 @@ etherprobe(int cardno, int ctlrno, char *conf)
ether->irq = -1; ether->irq = -1;
ether->ctlrno = ctlrno; ether->ctlrno = ctlrno;
ether->mbps = 10; ether->mbps = 10;
ether->link = 0;
ether->minmtu = ETHERMINTU; ether->minmtu = ETHERMINTU;
ether->maxmtu = ETHERMAXTU; ether->maxmtu = ETHERMAXTU;
@ -422,19 +423,15 @@ etherprobe(int cardno, int ctlrno, char *conf)
memmove(&ether->opt[0], &ether->opt[1], --ether->nopt*sizeof(ether->opt[0])); memmove(&ether->opt[0], &ether->opt[1], --ether->nopt*sizeof(ether->opt[0]));
} else if(isaconfig("ether", ctlrno, ether) == 0) } else if(isaconfig("ether", ctlrno, ether) == 0)
goto Nope; 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++){ for(i = 0; i < ether->nopt; i++){
if(strncmp(ether->opt[i], "ea=", 3) == 0){ if(strncmp(ether->opt[i], "ea=", 3) == 0){
if(parseether(ether->ea, &ether->opt[i][3])) if(parseether(ether->ea, &ether->opt[i][3]))
memset(ether->ea, 0, Eaddrlen); 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) if(cardno >= MaxEther || cards[cardno].type == nil)
goto Nope; goto Nope;
@ -471,8 +468,10 @@ ethersetspeed(Ether *ether, int mbps)
if(ether->mbps == mbps) if(ether->mbps == mbps)
return; return;
ether->mbps = mbps; ether->mbps = mbps;
if(mbps <= 0 || ether->oq == nil)
if(mbps <= 0 || ether->f == nil || ether->oq == nil)
return; return;
netifsetlimit(ether, etherqueuesize(ether)); netifsetlimit(ether, etherqueuesize(ether));
qsetlimit(ether->oq, ether->limit); qsetlimit(ether->oq, ether->limit);
} }
@ -484,6 +483,10 @@ ethersetlink(Ether *ether, int link)
if(!!ether->link == link) if(!!ether->link == link)
return; return;
ether->link = link; ether->link = link;
if(ether->f == nil)
return;
if(link) if(link)
print("#l%d: %s: link up: %dMbps\n", print("#l%d: %s: link up: %dMbps\n",
ether->ctlrno, ether->type, ether->mbps); ether->ctlrno, ether->type, ether->mbps);