From 7dc3c20bb6e3a77b0ab567c13fb1d14ba3ff1fbd Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 8 Mar 2003 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2003-03-08 --- ip/arp.c | 8 ++++---- ip/devip.c | 4 ++++ ip/esp.c | 2 +- ip/gre.c | 2 +- ip/icmp.c | 8 ++++---- ip/icmp6.c | 14 +++++++------- ip/igmp.c | 2 +- ip/il.c | 8 ++++---- ip/ip.c | 20 +++++++++++--------- ip/ip.h | 10 +++++----- ip/ipifc.c | 6 +++--- ip/ipmux.c | 4 ++-- ip/iproute.c | 25 ++++++++++++++++++++++--- ip/ipv6.c | 12 ++++++------ ip/rudp.c | 2 +- ip/tcp.c | 20 ++++++++++---------- ip/udp.c | 9 +++++++-- pc/devarch.c | 2 +- 18 files changed, 94 insertions(+), 64 deletions(-) diff --git a/ip/arp.c b/ip/arp.c index 3cae5b14cee681376cf3d7f5acde27245d6b8951..1353f32137dec98d793043af16bd13b5c7760f94 100644 --- a/ip/arp.c +++ b/ip/arp.c @@ -308,12 +308,12 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh) switch(version){ case V4: - r = v4lookup(fs, ip); + r = v4lookup(fs, ip, nil); v4tov6(v6ip, ip); ip = v6ip; break; case V6: - r = v6lookup(fs, ip); + r = v6lookup(fs, ip, nil); break; default: panic("arpenter: version %d", version); @@ -441,9 +441,9 @@ arpwrite(Fs *fs, char *s, int len) case 3: parseip(ip, f[1]); if(isv4(ip)) - r = v4lookup(fs, ip+IPv4off); + r = v4lookup(fs, ip+IPv4off, nil); else - r = v6lookup(fs, ip); + r = v6lookup(fs, ip, nil); if(r == nil) error("Destination unreachable"); m = r->ifc->m; diff --git a/ip/devip.c b/ip/devip.c index 030ecbdaad3d8a1ac2279ceebf08a0a84a71ca36..04f7decb35eef42cd6d6d778e50fdccfa059524d 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -568,6 +568,8 @@ closeconv(Conv *cv) while((mp = cv->multi) != nil) ipifcremmulti(cv, mp->ma, mp->ia); + cv->r = nil; + cv->rgen = 0; cv->p->close(cv); cv->state = Idle; qunlock(cv); @@ -1290,6 +1292,8 @@ retry: c->state = Idle; ipmove(c->laddr, IPnoaddr); ipmove(c->raddr, IPnoaddr); + c->r = nil; + c->rgen = 0; c->lport = 0; c->rport = 0; c->restricted = 0; diff --git a/ip/esp.c b/ip/esp.c index d77191514d288cff16d23a787fdd8c8db4598d97..9c9f33f8e4ecdb6f008b67d50c5c5024e54be0be 100644 --- a/ip/esp.c +++ b/ip/esp.c @@ -300,7 +300,7 @@ espkick(void *x) qunlock(c); //print("esp: pass down: %uld\n", BLEN(bp)); - ipoput4(c->p->f, bp, 0, c->ttl, c->tos); + ipoput4(c->p->f, bp, 0, c->ttl, c->tos, c); } void diff --git a/ip/gre.c b/ip/gre.c index 641d351bd7a709faff9240b2514a700352eb99e1..cbaf6ae0b65e05c7b1232e25a934945630dfd6b9 100644 --- a/ip/gre.c +++ b/ip/gre.c @@ -158,7 +158,7 @@ grekick(void *x, Block *bp) ghp->frag[0] = 0; ghp->frag[1] = 0; - ipoput4(c->p->f, bp, 0, c->ttl, c->tos); + ipoput4(c->p->f, bp, 0, c->ttl, c->tos, nil); } static void diff --git a/ip/icmp.c b/ip/icmp.c index 7b3dc0adf28be0500169b7ae5d8e05df0263d15f..48fcfb864244f559017963e86b4ee96d39e44165 100644 --- a/ip/icmp.c +++ b/ip/icmp.c @@ -183,7 +183,7 @@ icmpkick(void *x, Block *bp) memset(p->cksum, 0, sizeof(p->cksum)); hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE)); ipriv->stats[OutMsgs]++; - ipoput4(c->p->f, bp, 0, c->ttl, c->tos); + ipoput4(c->p->f, bp, 0, c->ttl, c->tos, nil); } extern void @@ -209,7 +209,7 @@ icmpttlexceeded(Fs *f, uchar *ia, Block *bp) hnputs(np->seq, 0); memset(np->cksum, 0, sizeof(np->cksum)); hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE)); - ipoput4(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil); } @@ -248,7 +248,7 @@ icmpunreachable(Fs *f, Block *bp, int code, int seq) hnputs(np->seq, seq); memset(np->cksum, 0, sizeof(np->cksum)); hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE)); - ipoput4(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil); } extern void @@ -362,7 +362,7 @@ icmpiput(Proto *icmp, Ipifc*, Block *bp) bp = trimblock(bp, 0, iplen); r = mkechoreply(bp); ipriv->out[EchoReply]++; - ipoput4(icmp->f, r, 0, MAXTTL, DFLTTOS); + ipoput4(icmp->f, r, 0, MAXTTL, DFLTTOS, nil); break; case Unreachable: if(p->code > 5 || p->code < 0) diff --git a/ip/icmp6.c b/ip/icmp6.c index c0e0e90ce96bc38d81a4206bdabba3dc57907ca3..7ed0fe26f0cd66e2877a48f950b17fa9f895a8dd 100644 --- a/ip/icmp6.c +++ b/ip/icmp6.c @@ -270,7 +270,7 @@ icmpkick6(void *x, Block *bp) p->vcf[0] = 0x06 << 4; if(p->type <= Maxtype6) ipriv->out[p->type]++; - ipoput6(c->p->f, bp, 0, c->ttl, c->tos); + ipoput6(c->p->f, bp, 0, c->ttl, c->tos, nil); } char* @@ -382,7 +382,7 @@ icmpns(Fs *f, uchar* src, int suni, uchar* targ, int tuni, uchar* mac) np->vcf[0] = 0x06 << 4; ipriv->out[NbrSolicit]++; netlog(f, Logicmp, "sending neighbor solicitation %I\n", targ); - ipoput6(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil); } /* @@ -417,7 +417,7 @@ icmpna(Fs *f, uchar* src, uchar* dst, uchar* targ, uchar* mac, uchar flags) np->vcf[0] = 0x06 << 4; ipriv->out[NbrAdvert]++; netlog(f, Logicmp, "sending neighbor advertisement %I\n", src); - ipoput6(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil); } extern void @@ -464,7 +464,7 @@ icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free) if(free) ipiput6(f, ifc, nbp); else { - ipoput6(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil); return; } @@ -508,7 +508,7 @@ icmpttlexceeded6(Fs *f, Ipifc *ifc, Block *bp) np->ttl = HOP_LIMIT; np->vcf[0] = 0x06 << 4; ipriv->out[TimeExceedV6]++; - ipoput6(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil); } extern void @@ -547,7 +547,7 @@ icmppkttoobig6(Fs *f, Ipifc *ifc, Block *bp) np->ttl = HOP_LIMIT; np->vcf[0] = 0x06 << 4; ipriv->out[PacketTooBigV6]++; - ipoput6(f, nbp, 0, MAXTTL, DFLTTOS); + ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil); } /* @@ -745,7 +745,7 @@ icmpiput6(Proto *icmp, Ipifc *ipifc, Block *bp) case EchoRequestV6: r = mkechoreply6(bp); ipriv->out[EchoReply]++; - ipoput6(icmp->f, r, 0, MAXTTL, DFLTTOS); + ipoput6(icmp->f, r, 0, MAXTTL, DFLTTOS, nil); break; case UnreachableV6: diff --git a/ip/igmp.c b/ip/igmp.c index 49b4765a60ecad9fc8f2fb41dd3b60a0534133a0..19e6481865d533bf341c756458fc50fb27b15b4c 100644 --- a/ip/igmp.c +++ b/ip/igmp.c @@ -97,7 +97,7 @@ igmpsendreport(Media *m, byte *addr) hnputs(p->igmpcksum, ptclcsum(bp, IGMP_IPHDRSIZE, IGMP_HDRSIZE)); netlog(Logigmp, "igmpreport %I\n", p->group); stats.outreports++; - ipoput4(bp, 0, 1, DFLTTOS); /* TTL of 1 */ + ipoput4(bp, 0, 1, DFLTTOS, nil); /* TTL of 1 */ } static int diff --git a/ip/il.c b/ip/il.c index b3bc8a1f3c24fa2dbcc98e7081a62847a35e9e94..8ee59a10516dc5a6822572df01f43d743d5dc8da 100644 --- a/ip/il.c +++ b/ip/il.c @@ -408,7 +408,7 @@ ilkick(void *x, Block *bp) if(later(NOW, ic->timeout, nil)) ilsettimeout(ic); - ipoput4(f, bp, 0, c->ttl, c->tos); + ipoput4(f, bp, 0, c->ttl, c->tos, c); priv->stats[OutMsgs]++; } @@ -820,7 +820,7 @@ ilrexmit(Ilcb *ic) ilbackoff(ic); - ipoput4(c->p->f, nb, 0, ic->conv->ttl, ic->conv->tos); + ipoput4(c->p->f, nb, 0, c->ttl, c->tos, c); /* statistics */ ic->rxtot++; @@ -1027,7 +1027,7 @@ if(ipc->p==nil) iltype[ih->iltype], nhgetl(ih->ilid), nhgetl(ih->ilack), nhgets(ih->ilsrc), nhgets(ih->ildst)); - ipoput4(ipc->p->f, bp, 0, ttl, tos); + ipoput4(ipc->p->f, bp, 0, ttl, tos, ipc); } void @@ -1061,7 +1061,7 @@ ilreject(Fs *f, Ilhdr *inih) if(ilcksum) hnputs(ih->ilsum, ptclcsum(bp, IL_IPSIZE, IL_HDRSIZE)); - ipoput4(f, bp, 0, MAXTTL, DFLTTOS); + ipoput4(f, bp, 0, MAXTTL, DFLTTOS, nil); } void diff --git a/ip/ip.c b/ip/ip.c index 0917c2994256e7c2031236b19142a5c28d3231d5..24062946909f0c963942781201e8c5454ebc39b0 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -221,7 +221,7 @@ iprouting(Fs *f, int on) } int -ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos) +ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) { Ipifc *ifc; uchar *gate; @@ -259,7 +259,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos) goto free; } - r = v4lookup(f, eh->dst); + r = v4lookup(f, eh->dst, c); if(r == nil){ ip->stats[OutNoRoutes]++; netlog(f, Logip, "no interface %V\n", eh->dst); @@ -273,7 +273,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos) else if(r->type & (Rbcast|Rmulti)) { gate = eh->dst; - sr = v4lookup(f, eh->src); + sr = v4lookup(f, eh->src, nil); if(sr != nil && (sr->type & Runi)) ifc = sr->ifc; } @@ -415,7 +415,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) int notforme; uchar *dp, v6dst[IPaddrlen]; IP *ip; - Route *r, *sr; + Route *r; if(BLKIPVER(bp) != IP_VER4) { ipiput6(f, ifc, bp); @@ -476,15 +476,17 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) /* route */ if(notforme) { + Conv conv; + if(!ip->iprouting){ freeb(bp); return; } - /* don't forward to source's network */ - sr = v4lookup(f, h->src); - r = v4lookup(f, h->dst); - if(r == nil || sr == r){ + /* don't forward to source's network */ + conv.r = nil; + r = v4lookup(f, h->dst, &conv); + if(r != nil && r->ifc == ifc){ ip->stats[OutDiscards]++; freeblist(bp); return; @@ -516,7 +518,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) ip->stats[ForwDatagrams]++; tos = h->tos; hop = h->ttl; - ipoput4(f, bp, 1, hop - 1, tos); + ipoput4(f, bp, 1, hop - 1, tos, &conv); return; } diff --git a/ip/ip.h b/ip/ip.h index 7641c3638443b446126151d1b837d52e2a72a2d6..158b139969ced89a9bd97bbe0d03b5a854b5adb9 100644 --- a/ip/ip.h +++ b/ip/ip.h @@ -119,7 +119,7 @@ struct Conv void* ptcl; /* protocol specific stuff */ Route *r; /* last route used */ - ulong routegen; /* routetable generation for *r */ + ulong rgen; /* routetable generation for *r */ }; struct Medium @@ -488,8 +488,8 @@ extern void v4addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int extern void v6addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type); extern void v4delroute(Fs *f, uchar *a, uchar *mask, int dolock); extern void v6delroute(Fs *f, uchar *a, uchar *mask, int dolock); -extern Route* v4lookup(Fs *f, uchar *a); -extern Route* v6lookup(Fs *f, uchar *a); +extern Route* v4lookup(Fs *f, uchar *a, Conv *c); +extern Route* v6lookup(Fs *f, uchar *a, Conv *c); extern long routeread(Fs *f, char*, ulong, int); extern long routewrite(Fs *f, Chan*, char*, int); extern void routetype(int, char*); @@ -622,8 +622,8 @@ extern void icmpttlexceeded(Fs*, uchar*, Block*); extern ushort ipcsum(uchar*); extern void ipiput4(Fs*, Ipifc*, Block*); extern void ipiput6(Fs*, Ipifc*, Block*); -extern int ipoput4(Fs*, Block*, int, int, int); -extern int ipoput6(Fs*, Block*, int, int, int); +extern int ipoput4(Fs*, Block*, int, int, int, Conv*); +extern int ipoput6(Fs*, Block*, int, int, int, Conv*); extern int ipstats(Fs*, char*, int); extern ushort ptclbsum(uchar*, int); extern ushort ptclcsum(Block*, int, int); diff --git a/ip/ipifc.c b/ip/ipifc.c index f41caee90a7166318310984d54e1bc4f4503e6d2..003c719beab45473d851f520db7cc2bfa932d30b 100644 --- a/ip/ipifc.c +++ b/ip/ipifc.c @@ -1291,7 +1291,7 @@ findlocalip(Fs *f, uchar *local, uchar *remote) USED(atype); USED(atypel); qlock(f->ipifc); - r = v6lookup(f, remote); + r = v6lookup(f, remote, nil); version = (memcmp(remote, v4prefix, IPv4off) == 0) ? V4 : V6; if(r != nil){ @@ -1424,7 +1424,7 @@ ipproxyifc(Fs *f, Ipifc *ifc, uchar *ip) Iplifc *lifc; /* see if this is a direct connected pt to pt address */ - r = v6lookup(f, ip); + r = v6lookup(f, ip, nil); if(r == nil) return 0; if((r->type & (Rifc|Rptpt|Rproxy)) != (Rifc|Rptpt|Rproxy)) @@ -1648,7 +1648,7 @@ adddefroute6(Fs *f, uchar *gate, int force) { Route *r; - r = v6lookup(f, v6Unspecified); + r = v6lookup(f, v6Unspecified, nil); if(r!=nil) if(!(force) && (strcmp(r->tag,"ra")!=0)) // route entries generated return; // by all other means take diff --git a/ip/ipmux.c b/ip/ipmux.c index e93d9e3aaa2af6b0742ffbe895ccc3bb485a9b59..f7ee5f721b2ae283a482539b7fd880329b28d6c0 100644 --- a/ip/ipmux.c +++ b/ip/ipmux.c @@ -665,10 +665,10 @@ ipmuxkick(void *x) else { Ip4hdr *ih4 = (Ip4hdr*)(bp->rp); if((ih4->vihl)&0xF0 != 0x60) - ipoput4(c->p->f, bp, 0, ih4->ttl, ih4->tos); + ipoput4(c->p->f, bp, 0, ih4->ttl, ih4->tos, nil); else { ih6 = (struct Ip6hdr*)ih4; - ipoput6(c->p->f, bp, 0, ih6->ttl, 0); + ipoput6(c->p->f, bp, 0, ih6->ttl, 0, nil); } } } diff --git a/ip/iproute.c b/ip/iproute.c index 238a1e2741a959ab09889b252d8d2cffd112d3b5..051c3a3265264b8b21853f2546f9e486a3132524 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -15,6 +15,7 @@ static void calcd(Route*); Route* v4freelist; Route* v6freelist; RWlock routelock; +ulong v4routegeneration, v6routegeneration; static void freeroute(Route *r) @@ -316,6 +317,7 @@ v4addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type) } wunlock(&routelock); } + v4routegeneration++; ipifcaddroute(f, Rv4, a, mask, gate, type); } @@ -361,6 +363,7 @@ v6addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type) } wunlock(&routelock); } + v6routegeneration++; ipifcaddroute(f, 0, a, mask, gate, type); } @@ -429,6 +432,7 @@ v4delroute(Fs *f, uchar *a, uchar *mask, int dolock) if(dolock) wunlock(&routelock); } + v4routegeneration++; ipifcremroute(f, Rv4, a, mask); } @@ -472,17 +476,21 @@ v6delroute(Fs *f, uchar *a, uchar *mask, int dolock) if(dolock) wunlock(&routelock); } + v6routegeneration++; ipifcremroute(f, 0, a, mask); } Route* -v4lookup(Fs *f, uchar *a) +v4lookup(Fs *f, uchar *a, Conv *c) { Route *p, *q; ulong la; uchar gate[IPaddrlen]; + if(c != nil && c->r != nil && c->rgen == v4routegeneration) + return c->r; + la = nhgetl(a); q = nil; for(p=f->v4root[V4H(la)]; p;) @@ -506,12 +514,16 @@ v4lookup(Fs *f, uchar *a) return nil; q->ifcid = q->ifc->ifcid; } + if(c != nil){ + c->r = q; + c->rgen = v4routegeneration; + } return q; } Route* -v6lookup(Fs *f, uchar *a) +v6lookup(Fs *f, uchar *a, Conv *c) { Route *p, *q; ulong la[IPllen]; @@ -520,11 +532,14 @@ v6lookup(Fs *f, uchar *a) uchar gate[IPaddrlen]; if(memcmp(a, v4prefix, IPv4off) == 0){ - q = v4lookup(f, a+IPv4off); + q = v4lookup(f, a+IPv4off, c); if(q != nil) return q; } + if(c != nil && c->r != nil && c->rgen == v6routegeneration) + return c->r; + for(h = 0; h < IPllen; h++) la[h] = nhgetl(a+4*h); @@ -568,6 +583,10 @@ next: ; return nil; q->ifcid = q->ifc->ifcid; } + if(c != nil){ + c->r = q; + c->rgen = v6routegeneration; + } return q; } diff --git a/ip/ipv6.c b/ip/ipv6.c index ff48390119288f0d21dbd5e6fd80133334427d2c..fa20d618beafb2461a985b591643139efdc4a27a 100644 --- a/ip/ipv6.c +++ b/ip/ipv6.c @@ -132,7 +132,7 @@ struct IP }; int -ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos) +ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c) { int tentative; Ipifc *ifc; @@ -179,7 +179,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos) goto free; } - r = v6lookup(f, eh->dst); + r = v6lookup(f, eh->dst, c); if(r == nil){ // print("no route for %I, src %I free\n", eh->dst, eh->src); ip->stats[OutNoRoutes]++; @@ -194,7 +194,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos) else if(r->type & (Rbcast|Rmulti)) { gate = eh->dst; - sr = v6lookup(f, eh->src); + sr = v6lookup(f, eh->src, nil); if(sr != nil && (sr->type & Runi)) ifc = sr->ifc; } @@ -392,8 +392,8 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp) return; } /* don't forward to source's network */ - sr = v6lookup(f, h->src); - r = v6lookup(f, h->dst); + sr = v6lookup(f, h->src, nil); + r = v6lookup(f, h->dst, nil); if(r == nil || sr == r){ ip->stats[OutDiscards]++; @@ -420,7 +420,7 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp) h = (Ip6hdr *) (bp->rp); tos = IPV6CLASS(h); hop = h->ttl; - ipoput6(f, bp, 1, hop-1, tos); + ipoput6(f, bp, 1, hop-1, tos, nil); return; } diff --git a/ip/rudp.c b/ip/rudp.c index 53374e19c706f6b2f9a79d879330f78eabcd6360..cd01904aa6bb7b31fc2551524f573af4311a246f 100644 --- a/ip/rudp.c +++ b/ip/rudp.c @@ -322,7 +322,7 @@ doipoput(Conv *c, Fs *f, Block *bp, int x, int ttl, int tos) if(ucb->randdrop && nrand(100) < ucb->randdrop) freeblist(bp); else - ipoput4(f, bp, x, ttl, tos); + ipoput4(f, bp, x, ttl, tos, nil); } int diff --git a/ip/tcp.c b/ip/tcp.c index c25c3a46cad179abe15c21913ccf0d8a94411b7f..107b258b7412d638289f8d785661afed58c68f22 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1291,13 +1291,13 @@ sndrst(Proto *tcp, uchar *source, uchar *dest, ushort length, Tcp *seg, uchar ve hbp = htontcp4(seg, nil, &ph4, nil); if(hbp == nil) return; - ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS); + ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS, nil); break; case V6: hbp = htontcp6(seg, nil, &ph6, nil); if(hbp == nil) return; - ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS); + ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS, nil); break; default: panic("sndrst2: version %d", version); @@ -1332,12 +1332,12 @@ tcphangup(Conv *s) case V4: tcb->protohdr.tcp4hdr.vihl = IP_VER4; hbp = htontcp4(&seg, nil, &tcb->protohdr.tcp4hdr, tcb); - ipoput4(s->p->f, hbp, 0, s->ttl, s->tos); + ipoput4(s->p->f, hbp, 0, s->ttl, s->tos, s); break; case V6: tcb->protohdr.tcp6hdr.vcf[0] = IP_VER6; hbp = htontcp6(&seg, nil, &tcb->protohdr.tcp6hdr, tcb); - ipoput6(s->p->f, hbp, 0, s->ttl, s->tos); + ipoput6(s->p->f, hbp, 0, s->ttl, s->tos, s); break; default: panic("tcphangup: version %d", s->ipversion); @@ -1409,13 +1409,13 @@ sndsynack(Proto *tcp, Limbo *lp) hbp = htontcp4(&seg, nil, &ph4, nil); if(hbp == nil) return -1; - ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS); + ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS, nil); break; case V6: hbp = htontcp6(&seg, nil, &ph6, nil); if(hbp == nil) return -1; - ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS); + ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS, nil); break; default: panic("sndsnack: version %d", lp->version); @@ -2585,13 +2585,13 @@ tcpoutput(Conv *s) switch(version){ case V4: - if(ipoput4(f, hbp, 0, s->ttl, s->tos) < 0){ + if(ipoput4(f, hbp, 0, s->ttl, s->tos, s) < 0){ /* a negative return means no route */ localclose(s, "no route"); } break; case V6: - if(ipoput6(f, hbp, 0, s->ttl, s->tos) < 0){ + if(ipoput6(f, hbp, 0, s->ttl, s->tos, s) < 0){ /* a negative return means no route */ localclose(s, "no route"); } @@ -2648,7 +2648,7 @@ tcpsendka(Conv *s) freeblist(dbp); return; } - ipoput4(s->p->f, hbp, 0, s->ttl, s->tos); + ipoput4(s->p->f, hbp, 0, s->ttl, s->tos, s); } else { /* Build header, link data and compute cksum */ @@ -2658,7 +2658,7 @@ tcpsendka(Conv *s) freeblist(dbp); return; } - ipoput6(s->p->f, hbp, 0, s->ttl, s->tos); + ipoput6(s->p->f, hbp, 0, s->ttl, s->tos, s); } } diff --git a/ip/udp.c b/ip/udp.c index 85ca87b425debf573d5198d5a203c24045ec8ec1..656c02074659abdce23c21d097c4cdfdf85e9033 100644 --- a/ip/udp.c +++ b/ip/udp.c @@ -188,6 +188,7 @@ udpkick(void *x, Block *bp) Udppriv *upriv; Fs *f; int version; + Conv *rc; upriv = c->p->priv; f = c->p->f; @@ -269,12 +270,14 @@ udpkick(void *x, Block *bp) v6tov4(uh4->udpdst, raddr); hnputs(uh4->udpdport, rport); v6tov4(uh4->udpsrc, laddr); + rc = nil; } else { v6tov4(uh4->udpdst, c->raddr); hnputs(uh4->udpdport, c->rport); if(ipcmp(c->laddr, IPnoaddr) == 0) findlocalip(f, c->laddr, c->raddr); v6tov4(uh4->udpsrc, c->laddr); + rc = c; } hnputs(uh4->udpsport, c->lport); hnputs(uh4->udplen, ptcllen); @@ -283,7 +286,7 @@ udpkick(void *x, Block *bp) hnputs(uh4->udpcksum, ptclcsum(bp, UDP4_PHDR_OFF, dlen+UDP_UDPHDR_SZ+UDP4_PHDR_SZ)); uh4->vihl = IP_VER4; - ipoput4(f, bp, 0, c->ttl, c->tos); + ipoput4(f, bp, 0, c->ttl, c->tos, rc); break; case V6: @@ -302,12 +305,14 @@ udpkick(void *x, Block *bp) ipmove(uh6->udpdst, raddr); hnputs(uh6->udpdport, rport); ipmove(uh6->udpsrc, laddr); + rc = nil; } else { ipmove(uh6->udpdst, c->raddr); hnputs(uh6->udpdport, c->rport); if(ipcmp(c->laddr, IPnoaddr) == 0) findlocalip(f, c->laddr, c->raddr); ipmove(uh6->udpsrc, c->laddr); + rc = c; } hnputs(uh6->udpsport, c->lport); hnputs(uh6->udplen, ptcllen); @@ -319,7 +324,7 @@ udpkick(void *x, Block *bp) uh6->viclfl[0] = IP_VER6; hnputs(uh6->len, ptcllen); uh6->nextheader = IP_UDPPROTO; - ipoput6(f, bp, 0, c->ttl, c->tos); + ipoput6(f, bp, 0, c->ttl, c->tos, rc); break; default: diff --git a/pc/devarch.c b/pc/devarch.c index fba008061d3ce732fd153f3bf4f0c7fd158d9d4d..febf520e83e8608dfeef405b0255579b65bfb80e 100644 --- a/pc/devarch.c +++ b/pc/devarch.c @@ -110,9 +110,9 @@ ioinit(void) ioalloc(0x10000, 1, 0, "dummy"); /* * Someone needs to explain why this was here... + */ ioalloc(0x0fff, 1, 0, "dummy"); // i82557 is at 0x1000, the dummy // entry is needed for swappable devs. - */ if ((excluded = getconf("ioexclude")) != nil) { char *s;