summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/ip.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-04-22 18:54:13 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-04-22 18:54:13 +0200
commit20b9326daddd52ffe534a968fb596af1674f53cc (patch)
treedd78be5dc993adf3af0c18e910ffb94414b0bb27 /sys/src/9/ip/ip.c
parentc80d94304d0b9946c822e073b637760a0894522a (diff)
devip: fix ipv6 icmp unreachable handling, fix retransmit, fix ifc locking, remove tentative check
Diffstat (limited to 'sys/src/9/ip/ip.c')
-rw-r--r--sys/src/9/ip/ip.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/sys/src/9/ip/ip.c b/sys/src/9/ip/ip.c
index 948125737..7166619dd 100644
--- a/sys/src/9/ip/ip.c
+++ b/sys/src/9/ip/ip.c
@@ -99,6 +99,7 @@ ip_init(Fs *f)
IP *ip;
ip = smalloc(sizeof(IP));
+ ip->stats[DefaultTTL] = MAXTTL;
initfrag(ip, 100);
f->ip = ip;
@@ -362,7 +363,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
if(notforme) {
Route *r;
Routehint rh;
- Ipifc *toifc;
+ Ipifc *nifc;
if(!ip->iprouting)
goto drop;
@@ -370,8 +371,8 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
/* don't forward to source's network */
rh.r = nil;
r = v4lookup(f, h->dst, h->src, &rh);
- if(r == nil || (toifc = r->ifc) == nil
- || (toifc == ifc && !ifc->reflect)){
+ if(r == nil || (nifc = r->ifc) == nil
+ || (nifc == ifc && !ifc->reflect)){
ip->stats[OutDiscards]++;
goto drop;
}
@@ -385,7 +386,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
}
/* reassemble if the interface expects it */
- if(toifc->reassemble){
+ if(nifc->reassemble){
frag = nhgets(h->frag);
if(frag & ~IP_DF) {
h->tos = 0;
@@ -441,8 +442,6 @@ ipstats(Fs *f, char *buf, int len)
int i;
ip = f->ip;
- ip->stats[DefaultTTL] = MAXTTL;
-
p = buf;
e = p+len;
for(i = 0; i < Nipstats; i++)
@@ -467,7 +466,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
/*
* block lists are too hard, pullupblock into a single block
*/
- if(bp->next){
+ if(bp->next != nil){
bp = pullupblock(bp, blocklen(bp));
ih = (Ip4hdr*)(bp->rp);
}
@@ -477,7 +476,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
/*
* find a reassembly queue for this fragment
*/
- for(f = ip->flisthead4; f; f = fnext){
+ for(f = ip->flisthead4; f != nil; f = fnext){
fnext = f->next; /* because ipfragfree4 changes the list */
if(f->src == src && f->dst == dst && f->id == id)
break;
@@ -536,7 +535,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
}
/* Check overlap of a previous fragment - trim away as necessary */
- if(prev) {
+ if(prev != nil) {
ovlap = BKFG(prev)->foff + BKFG(prev)->flen - BKFG(bp)->foff;
if(ovlap > 0) {
if(ovlap >= BKFG(bp)->flen) {
@@ -553,11 +552,11 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
*l = bp;
/* Check to see if succeeding segments overlap */
- if(bp->next) {
+ if(bp->next != nil) {
l = &bp->next;
fend = BKFG(bp)->foff + BKFG(bp)->flen;
/* Take completely covered segments out */
- while(*l) {
+ while(*l != nil) {
ovlap = fend - BKFG(*l)->foff;
if(ovlap <= 0)
break;
@@ -581,7 +580,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
* without IP_MF set, we're done.
*/
pktposn = 0;
- for(bl = f->blist; bl; bl = bl->next) {
+ for(bl = f->blist; bl != nil; bl = bl->next) {
if(BKFG(bl)->foff != pktposn)
break;
if((BLKIP(bl)->frag[0]&(IP_MF>>8)) == 0) {
@@ -592,7 +591,7 @@ ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
/* Pullup all the fragment headers and
* return a complete packet
*/
- for(bl = bl->next; bl; bl = bl->next) {
+ for(bl = bl->next; bl != nil; bl = bl->next) {
fragsize = BKFG(bl)->flen;
len += fragsize;
bl->rp += IP4HDR;
@@ -622,7 +621,7 @@ ipfragfree4(IP *ip, Fragment4 *frag)
{
Fragment4 *fl, **l;
- if(frag->blist)
+ if(frag->blist != nil)
freeblist(frag->blist);
frag->src = 0;
@@ -630,7 +629,7 @@ ipfragfree4(IP *ip, Fragment4 *frag)
frag->blist = nil;
l = &ip->flisthead4;
- for(fl = *l; fl; fl = fl->next) {
+ for(fl = *l; fl != nil; fl = fl->next) {
if(fl == frag) {
*l = frag->next;
break;
@@ -653,7 +652,7 @@ ipfragallo4(IP *ip)
while(ip->fragfree4 == nil) {
/* free last entry on fraglist */
- for(f = ip->flisthead4; f->next; f = f->next)
+ for(f = ip->flisthead4; f->next != nil; f = f->next)
;
ipfragfree4(ip, f);
}