--- cci/sys/tahoeif/if_ace.c 2019/07/28 12:24:19 1.1.1.1 +++ cci/sys/tahoeif/if_ace.c 2019/07/28 12:29:50 1.1.1.2 @@ -30,6 +30,7 @@ #include "../machine/mtpr.h" #include "../tahoeif/if_acereg.h" #include "../vba/vbavar.h" +#include "../tahoeif/if_debug.h" #define LONET 124 #define LOHOST 1 @@ -89,6 +90,11 @@ struct ace_softc ace_softc[NACE]; extern struct ifnet loif; int numace = NACE; /* for nstat unix command */ +int printerror = 1; +int save_ace_inpkt = 0; +struct inp_err aceerr[NACE]; +extern int saverrpkt(); +#define INPTRACE(X) if (save_ace_inpkt) X /*------ debugging tools ------------*/ #ifdef ACEPRINTFS @@ -453,7 +459,8 @@ register long tripnum = 0; struct acedevice *addr = (struct acedevice *)aceinfo[unit]->ui_addr; short eistat; struct mbuf *m; -int len, s, off, resid; +struct inp_err *acer = &aceerr[unit]; +int len, s, off, resid, orglen; ACESTUDY(is->is_stats.rx_rintcnt++;) more: @@ -496,6 +503,7 @@ more: return; } ace = (struct ether_header *)(rxseg->rx_data); + orglen = len; len -= SIZEOF_ETHEADER; /* @@ -506,22 +514,31 @@ more: ace->ether_type = ntohs((u_short)ace->ether_type); #define acedataaddr(ace, off, type) ((type)(((caddr_t)(((char *)ace)+SIZEOF_ETHEADER)+(off)))) -/* #define acedataaddr(ace, off, type) ((type)(((caddr_t)((ace)+1)+(off)))) -*/ +/*#define acedataaddr(ace, off, type) ((type)(((caddr_t)((ace)+1)+(off)))) */ + if (ace->ether_type >= ETHERPUP_TRAIL && ace->ether_type < ETHERPUP_TRAIL+ETHERPUP_NTRAILER) { off = (ace->ether_type - ETHERPUP_TRAIL) * 512; - if (off >= ETHERMTU) + if (off >= ETHERMTU) { + acer->bad_offset++; + INPTRACE(saverrpkt(rxseg->rx_data, B_OFFSET, orglen);) goto setup; /* sanity */ + } ace->ether_type = ntohs(*acedataaddr(ace, off, u_short *)); resid = ntohs(*(acedataaddr(ace, off+2, u_short *))); - if (off + resid > len) + if (off + resid > len) { + acer->bad_length++; + INPTRACE(saverrpkt(rxseg->rx_data, B_LENGTH, orglen);) goto setup; /* sanity */ + } len = off + resid; } else off = 0; - if (len == 0) + if (len == 0) { + acer->bad_length++; + INPTRACE(saverrpkt(rxseg->rx_data, B_LENGTH, orglen);) goto setup; + } /* * Pull packet off interface. Off is nonzero if packet @@ -530,8 +547,10 @@ more: * the type and length which are at the front of any trailer data. */ m = aceget((int)unit, rxseg->rx_data, len, off); - if (m == 0) + if (m == 0) { + acer->h_nobuffer++; /* host runs out of buf */ goto setup; + } if (off) { m->m_off += 2 * sizeof (u_short); m->m_len -= 2 * sizeof (u_short); @@ -554,13 +573,22 @@ more: goto setup; #endif default: - ACETRACE(RTINTRACE, - printf("\nUndefined packet type %d\n",ace->ether_type);) + acer->bad_packetype++; + if (printerror) { + printf("\nace%d: Undefined packet type 0x%x ", unit, + ace->ether_type); + printf("from host: %x.%x.%x.%x.%x.%x\n", + ace->ether_shost[0], ace->ether_shost[1], + ace->ether_shost[2], ace->ether_shost[3], + ace->ether_shost[4], ace->ether_shost[5]); + } + INPTRACE(saverrpkt(rxseg->rx_data, B_PACKETYPE, orglen);) m_freem(m); goto setup; } if (IF_QFULL(inq)) { + acer->inq_full++; IF_DROP(inq); m_freem(m); goto setup; @@ -569,8 +597,9 @@ more: IF_ENQUEUE(inq, m); splx(s); - ACETRACE(RTINTRACE1,printf("acerint: enqlen %d: ",inq->ifq_len);) - ACETRACE(RTINTRACE1,aceprm(m);) + ACETRACE(RTINTRACE1,printf("ace%dacerint: enqlen %d: ", + unit, inq->ifq_len);) + ACETRACE(RTINTRACE1,aceprm(unit, m);) setup: rxseg->rx_csr = 0; goto more; @@ -601,7 +630,7 @@ struct in_addr idst; ACETRACE(ACEOTRACE, printf("ace%doutput: ifp %lx, m0 %lx, dst ADDR %lx: ", unit,ifp,m0, dst);) - ACETRACE(ACEOTRACE,aceprm(m0);) + ACETRACE(ACEOTRACE,aceprm(unit, m0);) #endif switch (dst->sa_family) { @@ -612,7 +641,7 @@ struct in_addr idst; ACETRACE(ACEOTRACE, printf("ace%doutput: ifp %lx, m0 %lx, dst %lx: ", unit,ifp,m0, idst.S_un.S_addr);) - ACETRACE(ACEOTRACE,aceprm(m0);) + ACETRACE(ACEOTRACE,aceprm(unit, m0);) /* translate internet to ethernet address */ switch(arpresolve(&is->is_ac, m, &idst, edst)) { @@ -655,7 +684,8 @@ struct in_addr idst; goto gottype; default: - printf("ace%d: can't handle af%d\n", unit,dst->sa_family); + if (printerror) + printf("ace%d: can't handle af%d\n", unit,dst->sa_family); error = EAFNOSUPPORT; goto bad; } @@ -712,7 +742,7 @@ gottype: splx(s); ACETRACE (ACEOTRACE, printf("ace%doutput: enqu mbuf %lx: ",unit,m);) - ACETRACE (ACEOTRACE, aceprm(m);) + ACETRACE (ACEOTRACE, aceprm(unit, m);) ACESTUDY (is->is_stats.tx_outcnt++;) aceStart((int)unit); @@ -755,9 +785,9 @@ register unsigned len; register struct mbuf *mp; int total, idx; - ACETRACE(STARTTRACE, printf("aceput: txbuf %X, mbuf %X, m->m_off %d\n", - txbuf,m,m->m_off);) - ACETRACE(STARTTRACE,aceprm(m);) + ACETRACE(STARTTRACE, printf("ace%daceput: txbuf %X, mbuf %X, m->m_off %d\n", + unit, txbuf, m, m->m_off);) + ACETRACE(STARTTRACE,aceprm(unit, m);) total = 0; bp = (u_char *)txbuf; @@ -817,7 +847,8 @@ short *to; #ifdef ACEPRINTFS -aceprm(mp) +aceprm(unit, mp) +int unit; struct mbuf *mp; { register u_char *mcp; @@ -829,8 +860,8 @@ struct mbuf *mp; totlen += mpp->m_len; mcp = mtod(mp, u_char *); - printf("mbuf[len %d,off %d],[next %lx,totlen %ld],[", - mp->m_len,mp->m_off,mp->m_next,totlen); + printf("ace%d mbuf[len %d,off %d],[next %lx,totlen %ld],[", + unit, mp->m_len,mp->m_off,mp->m_next,totlen); for (idx=0 ; (idx < 20 ); idx++) { printf("%x ",mcp[idx] & 0xff); @@ -860,8 +891,8 @@ register struct mbuf *m; struct mbuf *top = 0, **mp = ⊤ int off = off0; - ACETRACE(RTINTRACE, printf("aceget: rxbuf %lx, len %d, off %d\n", - rxbuf,totlen,off0);) + ACETRACE(RTINTRACE, printf("ace%daceget: rxbuf %lx, len %d, off %d\n", + unit, rxbuf,totlen,off0);) cp = rxbuf + SIZEOF_ETHEADER; while (totlen > 0) @@ -974,15 +1005,16 @@ register struct ifnet *ifp; int cmd; caddr_t data; { +register short unit = ifp->if_unit; register struct vba_device *ui; register struct acedevice *addr; register struct sockaddr_in *et_addr; -register struct ace_softc *is; +register struct ace_softc *is = &ace_softc[ifp->if_unit]; register struct ifreq *ifr = (struct ifreq *)data; int s , error = 0; ACETRACE (IOCTLTRACE, - printf("aceioctl: ifp %X, cmd %X, data %X\n",ifp,cmd,data);) + printf("ace%daceioctl: ifp %X, cmd %X, data %X\n", unit, ifp, cmd, data);) switch (cmd) { @@ -1009,6 +1041,10 @@ int s , error = 0; splx(s); break; + case SIOCGETETADDR: /* Get Foreign Hosts' Ethernet address */ + arpwhohas(&is->is_ac, (struct in_addr *)ifr->ifr_data); + break; + default: error = EINVAL; } @@ -1019,8 +1055,9 @@ acesetaddr(ifp, sin) register struct ifnet *ifp; register struct sockaddr_in *sin; { +register short unit = ifp->if_unit; - ACETRACE (IOCTLTRACE, printf("acesetaddr: ifp %X, sin %X\n",ifp,sin);) + ACETRACE (IOCTLTRACE, printf("ace%dacesetaddr: ifp %X, sin %X\n",unit,ifp,sin);) arpremove(&ifp->if_addr); ifp->if_addr = *(struct sockaddr *)sin;