M ip/arp.c => ip/arp.c +4 -4
@@ 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;
M ip/devip.c => ip/devip.c +4 -0
@@ 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;
M ip/esp.c => ip/esp.c +1 -1
@@ 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
M ip/gre.c => ip/gre.c +1 -1
@@ 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
M ip/icmp.c => ip/icmp.c +4 -4
@@ 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)
M ip/icmp6.c => ip/icmp6.c +7 -7
@@ 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:
M ip/igmp.c => ip/igmp.c +1 -1
@@ 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
M ip/il.c => ip/il.c +4 -4
@@ 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
M ip/ip.c => ip/ip.c +11 -9
@@ 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;
}
M ip/ip.h => ip/ip.h +5 -5
@@ 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);
M ip/ipifc.c => ip/ipifc.c +3 -3
@@ 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
M ip/ipmux.c => ip/ipmux.c +2 -2
@@ 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);
}
}
}
M ip/iproute.c => ip/iproute.c +22 -3
@@ 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;
}
M ip/ipv6.c => ip/ipv6.c +6 -6
@@ 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;
}
M ip/rudp.c => ip/rudp.c +1 -1
@@ 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
M ip/tcp.c => ip/tcp.c +10 -10
@@ 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);
}
}
M ip/udp.c => ip/udp.c +7 -2
@@ 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:
M pc/devarch.c => pc/devarch.c +1 -1
@@ 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;