M port/devip.c => port/devip.c +4 -3
@@ 604,8 604,9 @@ ipstatusfill(Chan *c, char *buf, int len)
tcpstate[cp->tcpctl.state],
cp->tcpctl.flags & CLONE ? "listen" : "connect");
else if(cp->stproto == &ilinfo)
- sprint(buf, "il/%d %d %s rtt %d ms\n", connection, cp->ref,
- ilstate[cp->ilctl.state], cp->ilctl.rtt);
+ sprint(buf, "il/%d %d %s rtt %d ms %d csum\n", connection, cp->ref,
+ ilstate[cp->ilctl.state], cp->ilctl.rtt,
+ cp->ipinterface ? cp->ipinterface->chkerrs : 0);
else
sprint(buf, "%s/%d %d\n", cp->stproto->name, connection, cp->ref);
}
@@ 652,7 653,7 @@ iplisten(Chan *c)
return new - base;
}
}
- print("no newcon\n");
+ print("iplisten: no newcon\n");
}
}
M port/devlance.c => port/devlance.c +2 -2
@@ 282,7 282,7 @@ lanceoput(Queue *q, Block *bp )
qlock(&l);
l.prom++;
if(l.prom == 1)
- lancestart(PROM, 1);
+/* lancestart(PROM, 1);/**/
qunlock(&l);
}
freeb(bp);
@@ 309,7 309,7 @@ lanceoput(Queue *q, Block *bp )
}
return;
}
- if(memcmp(l.bcast, p->d, sizeof(l.bcast)) == 0){
+ if(memcmp(l.bcast, p->d, sizeof(l.bcast)) == 0 || l.prom){
len = blen(bp);
nbp = copyb(bp, len);
nbp = expandb(nbp, len >= ETHERMINTU ? len : ETHERMINTU);
M port/fault.c => port/fault.c +12 -5
@@ 64,6 64,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
etp->last = pg;
switch(type) {
+ default:
+ panic("fault");
+
case SG_TEXT:
if(pagedout(*pg)) /* Demand load */
pio(s, addr, soff, pg);
@@ 72,6 75,12 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
(*pg)->modref = PG_REF;
break;
+ case SG_SHDATA: /* Shared data */
+ if(pagedout(*pg))
+ pio(s, addr, soff, pg);
+
+ goto done;
+
case SG_SHARED: /* Zero fill on demand */
case SG_BSS:
case SG_STACK:
@@ 80,15 89,16 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
if(new = newpage(1, &s, addr))
if(s == 0)
return -1;
+
*pg = new;
new = 0;
}
/* NO break */
- case SG_DATA: /* Demand load/page in/copy on write */
+ case SG_DATA: /* Demand load/pagein/copy on write */
if(pagedout(*pg))
pio(s, addr, soff, pg);
-
+
if(type == SG_SHARED)
goto done;
@@ 130,9 140,6 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
mmuphys = PPN((*pg)->pa) | PTEWRITE|PTEUNCACHED|PTEVALID;
(*pg)->modref = PG_MOD|PG_REF;
break;
-
- default:
- panic("fault");
}
if(s->flushme)
M port/ipdat.h => port/ipdat.h +3 -0
@@ 375,6 375,9 @@ struct Ipifc
int maxmtu; /* Maximum transfer unit */
int minmtu; /* Minumum tranfer unit */
int hsize; /* Media header size */
+ ulong chkerrs; /* checksum errors */
+ ulong tx;
+ ulong rx;
Lock;
};
M port/portdat.h => port/portdat.h +16 -10
@@ 36,8 36,7 @@ typedef struct RWlock RWlock;
typedef struct Segment Segment;
typedef struct Stream Stream;
typedef struct Waitq Waitq;
-
-typedef int Devgen(Chan*, Dirtab*, int, int, Dir*);
+typedef int Devgen(Chan*, Dirtab*, int, int, Dir*);
struct List
{
@@ 240,6 239,7 @@ struct IOQ
};
void *ptr;
};
+
struct KIOQ
{
QLock;
@@ 248,6 248,7 @@ struct KIOQ
int c;
int count;
};
+
extern IOQ lineq;
extern IOQ printq;
extern IOQ mouseq;
@@ 268,7 269,8 @@ struct Mhead
Mhead *hash; /* Hash chain */
};
-enum{
+enum
+{
NUser, /* note provided externally */
NExit, /* deliver note quietly */
NDebug, /* print debug message */
@@ 337,13 339,15 @@ struct Pte
};
/* Segment types */
-#define SG_TYPE 007 /* Mask type of segment */
-#define SG_TEXT 000
-#define SG_DATA 001
-#define SG_BSS 002
-#define SG_STACK 003
-#define SG_SHARED 004
-#define SG_PHYSICAL 005
+#define SG_TYPE 07 /* Mask type of segment */
+#define SG_TEXT 00
+#define SG_DATA 01
+#define SG_BSS 02
+#define SG_STACK 03
+#define SG_SHARED 04
+#define SG_PHYSICAL 05
+#define SG_SHDATA 06
+
/* Segment flags */
#define SG_RONLY 040 /* Segment is read only */
@@ 648,11 652,13 @@ struct Netprot
ulong mode;
char owner[NAMELEN];
};
+
struct Netinf
{
char *name;
void (*fill)(Chan*, char*, int);
};
+
struct Network
{
Lock;
M port/segment.c => port/segment.c +5 -2
@@ 148,6 148,7 @@ dupseg(Segment *s)
case SG_TEXT: /* New segment shares pte set */
case SG_SHARED:
case SG_PHYSICAL:
+ case SG_SHDATA:
incref(s);
return s;
@@ 369,7 370,8 @@ ibrk(ulong addr, int seg)
ns = u->p->seg[i];
if(ns == 0 || ns == s)
continue;
- if(newtop >= ns->base && newtop < ns->top) {
+ if(newtop >= ns->base)
+ if(newtop < ns->top) {
qunlock(&s->lk);
pprint("segments overlap\n");
error(Enovmem);
@@ 431,7 433,8 @@ segattach(Proc *p, ulong attr, char *name, ulong va, ulong len)
vmemchr(name, 0, ~0);
for(sno = 0; sno < NSEG; sno++)
- if(u->p->seg[sno] == 0 && sno != ESEG)
+ if(u->p->seg[sno] == 0)
+ if(sno != ESEG)
break;
if(sno == NSEG)
M port/stil.c => port/stil.c +2 -0
@@ 257,6 257,7 @@ ilrcvmsg(Ipconv *ipc, Block *bp)
dst = nhgetl(ih->src);
if(ilcksum && ptcl_csum(bp, IL_EHSIZE, illen) != 0) {
+ ipc->ipinterface->chkerrs++;
/* st = (ih->iltype < 0 || ih->iltype > Ilclose) ? "?" : iltype[ih->iltype];
print("il: cksum error, pkt(%s id %lud ack %lud %d.%d.%d.%d/%d->%d)\n",
st, nhgetl(ih->ilid), nhgetl(ih->ilack), fmtaddr(dst), sp, dp); /**/
@@ 712,6 713,7 @@ ilackproc(void *a)
ic->acktime -= Iltickms;
if(ic->acktime <= 0)
ilsendctl(s, 0, Ilack, ic->next, ic->recvd);
+
ic->querytime -= Iltickms;
if(ic->querytime <= 0){
ic->deathtime -= Querytime;
M port/stip.c => port/stip.c +19 -2
@@ 387,6 387,16 @@ ipforme(uchar *addr)
return 0;
}
+typedef struct Fragstat Fragstat;
+struct Fragstat
+{
+ ulong prev;
+ ulong prevall;
+ ulong succ;
+ ulong succall;
+};
+Fragstat fragstat;
+
Block *
ip_reassemble(int offset, Block *bp, Etherhdr *ip)
{
@@ 451,7 461,9 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip)
if(prev) {
ovlap = BLKFRAG(prev)->foff + BLKFRAG(prev)->flen - BLKFRAG(bp)->foff;
if(ovlap > 0) {
- if(ovlap > BLKFRAG(bp)->flen) {
+ fragstat.prev++;
+ if(ovlap >= BLKFRAG(bp)->flen) {
+ fragstat.prevall++;
freeb(bp);
qunlock(f);
return 0;
@@ 469,8 481,13 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip)
l = &bp->next;
end = BLKFRAG(bp)->foff + BLKFRAG(bp)->flen;
/* Take completely covered segements out */
- while(*l && (ovlap = (end - BLKFRAG(*l)->foff)) > 0) {
+ while(*l){
+ ovlap = end - BLKFRAG(*l)->foff;
+ if(ovlap <= 0)
+ break;
+ fragstat.succ++;
if(ovlap < BLKFRAG(*l)->flen) {
+ fragstat.succall++;
BLKFRAG(*l)->flen -= ovlap;
(*l)->rptr += ovlap;
break;
M port/swap.c => port/swap.c +1 -0
@@ 263,6 263,7 @@ pagepte(int type, Segment *s, Page **pg)
case SG_BSS:
case SG_STACK:
case SG_SHARED:
+ case SG_SHDATA:
lockpage(outp);
outp->ref++;
uncachepage(outp);
M port/sysproc.c => port/sysproc.c +4 -9
@@ 56,7 56,7 @@ rfork(ulong flag)
/* Save time: only copy u-> data and useful stack */
memmove((void*)upa, u, sizeof(User));
n = USERADDR+BY2PG - (ulong)&lastvar;
- n = (n+32) & ~(BY2WD-1); /* be safe & word align */
+ n = (n+32) & ~(BY2WD-1);
memmove((void*)(upa+BY2PG-n), (void*)(USERADDR+BY2PG-n), n);
((User *)upa)->p = p;
kunmap(k);
@@ 67,7 67,7 @@ rfork(ulong flag)
p->seg[i] = dupseg(u->p->seg[i]);
/* Refs */
- incref(u->dot); /* File descriptors etc. */
+ incref(u->dot); /* File descriptors etc. */
if(flag & Forkfd)
p->fgrp = dupfgrp(u->p->fgrp);
@@ 97,15 97,10 @@ rfork(ulong flag)
p->hang = u->p->hang;
p->procmode = u->p->procmode;
- /*
- * Sched
- */
if(setlabel(&p->sched)){
/*
- * use u->p instead of p, because we
- * don't trust the compiler, after a
- * gotolabel, to find the correct contents
- * of a local variable.
+ * use u->p instead of p, because we don't trust the compiler, after a
+ * gotolabel, to find the correct contents of a local variable.
*/
p = u->p;
p->state = Running;