@@ 191,6 191,7 @@ void iladvise(Proto*, Block*, char*);
int ilnextqt(Ilcb*);
void ilcbinit(Ilcb*);
int later(ulong, ulong, char*);
+void ilreject(Fs*, Ilhdr*);
int ilcksum = 1;
static int initseq = 25001;
@@ 543,6 544,7 @@ iliput(Proto *il, uchar*, Block *bp)
st = "?";
else
st = iltype[ih->iltype];
+ ilreject(il->f, ih); /* no channel and not sync */
netlog(il->f, Logil, "il: no channel, pkt(%s id %lud ack %lud %I/%ud->%ud)\n",
st, nhgetl(ih->ilid), nhgetl(ih->ilack), raddr, sp, dp);
goto raise;
@@ 573,6 575,7 @@ iliput(Proto *il, uchar*, Block *bp)
s = gen;
else {
qunlock(il);
+ ilreject(il->f, ih); /* no listener */
goto raise;
}
@@ 646,7 649,7 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp)
break;
case Ilclose:
if(ack == ic->start)
- ilhangup(s, "remote close");
+ ilhangup(s, "connection rejected");
break;
}
freeblist(bp);
@@ 728,6 731,7 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp)
freeblist(bp);
if(ack < ic->start || ack > ic->next)
break;
+ ic->recvd = id;
ilsendctl(s, nil, Ilclose, ic->next, ic->recvd, 0);
ic->state = Ilclosing;
ilsettimeout(ic);
@@ 994,6 998,39 @@ ilsendctl(Conv *ipc, Ilhdr *inih, int type, ulong id, ulong ack, int ilspec)
}
void
+ilreject(Fs *f, Ilhdr *inih)
+{
+ Ilhdr *ih;
+ Block *bp;
+
+ bp = allocb(IL_IPSIZE+IL_HDRSIZE);
+ bp->wp += IL_IPSIZE+IL_HDRSIZE;
+
+ ih = (Ilhdr *)(bp->rp);
+
+ /* Ip fields */
+ ih->proto = IP_ILPROTO;
+ hnputs(ih->illen, IL_HDRSIZE);
+ ih->frag[0] = 0;
+ ih->frag[1] = 0;
+ hnputl(ih->dst, nhgetl(inih->src));
+ hnputl(ih->src, nhgetl(inih->dst));
+ hnputs(ih->ilsrc, nhgets(inih->ildst));
+ hnputs(ih->ildst, nhgets(inih->ilsrc));
+ hnputl(ih->ilid, nhgetl(inih->ilack));
+ hnputl(ih->ilack, nhgetl(inih->ilid));
+ ih->iltype = Ilclose;
+ ih->ilspec = 0;
+ ih->ilsum[0] = 0;
+ ih->ilsum[1] = 0;
+
+ if(ilcksum)
+ hnputs(ih->ilsum, ptclcsum(bp, IL_IPSIZE, IL_HDRSIZE));
+
+ ipoput(f, bp, 0, MAXTTL, DFLTTOS);
+}
+
+void
ilsettimeout(Ilcb *ic)
{
ulong pt;
@@ 182,10 182,9 @@ ipoput(Fs *f, Block *bp, int gating, int ttl, int tos)
if(!gating){
eh->vihl = IP_VER|IP_HLEN;
- eh->tos = 0;
+ eh->ttl = ttl;
+ eh->tos = tos;
}
- eh->ttl = ttl;
- eh->tos = tos;
if(!canrlock(ifc))
goto free;