]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/ip/il.c
devip: pick less surprising interface address in header for incoming UDP packets
[plan9front.git] / sys / src / 9 / ip / il.c
index 89ec60bd05684df6464a88c421b3470bd729be73..1ee07e86384eb3acd2fca48a495aae80351198d6 100644 (file)
@@ -208,7 +208,7 @@ struct Ilpriv
 
 
 void   ilrcvmsg(Conv*, Block*);
-void   ilsendctl(Conv*, Ilhdr*, int, ulong, ulong, int);
+int    ilsendctl(Conv*, Ilhdr*, int, ulong, ulong, int);
 void   ilackq(Ilcb*, Block*);
 void   ilprocess(Conv*, Ilhdr*, Block*);
 void   ilpullup(Conv*);
@@ -923,17 +923,12 @@ ilpullup(Conv *s)
                bp->list = nil;
                dlen = nhgets(oh->illen)-IL_HDRSIZE;
                bp = trimblock(bp, IL_IPSIZE+IL_HDRSIZE, dlen);
+                       
                /*
                 * Upper levels don't know about multiple-block
                 * messages so copy all into one (yick).
                 */
-               bp = concatblock(bp);
-               if(bp == 0)
-                       panic("ilpullup");
-               bp = packblock(bp);
-               if(bp == 0)
-                       panic("ilpullup2");
-               qpass(s->rq, bp);
+               qpass(s->rq, packblock(concatblock(bp)));
        }
        qunlock(&ic->outo);
 }
@@ -989,7 +984,7 @@ iloutoforder(Conv *s, Ilhdr *h, Block *bp)
        qunlock(&ic->outo);
 }
 
-void
+int
 ilsendctl(Conv *ipc, Ilhdr *inih, int type, ulong id, ulong ack, int ilspec)
 {
        Ilhdr *ih;
@@ -1048,7 +1043,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, ipc);
+       return ipoput4(ipc->p->f, bp, 0, ttl, tos, ipc);
 }
 
 void
@@ -1288,7 +1283,8 @@ ilstart(Conv *c, int type, int fasttimeout)
        case IL_CONNECT:
                ic->state = Ilsyncer;
                iphtadd(&ipriv->ht, c);
-               ilsendctl(c, nil, Ilsync, ic->start, ic->recvd, 0);
+               if(ilsendctl(c, nil, Ilsync, ic->start, ic->recvd, 0) < 0)
+                       ilhangup(c, "no route");
                break;
        }