shithub: riscv

Download patch

ref: 055f8370432d2c128ce8fd28b059320181d8f3ef
parent: 75c6ab45e02640959260fa98449180e9408141bc
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 22 20:31:42 EDT 2016

ip: simplify code as packblock() and concatblock() will never error

--- a/sys/src/9/ip/gre.c
+++ b/sys/src/9/ip/gre.c
@@ -647,17 +647,7 @@
 		return;
 	}
 
-	/*
-	 *  Can't delimit packet so pull it all into one block.
-	 */
-	if(qlen(c->rq) > GREqlen)
-		freeb(bp);
-	else{
-		bp = concatblock(bp);
-		if(bp == 0)
-			panic("greiput");
-		qpass(c->rq, bp);
-	}
+	qpass(c->rq, bp);
 }
 
 int
--- a/sys/src/9/ip/il.c
+++ b/sys/src/9/ip/il.c
@@ -923,17 +923,12 @@
 		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);
 }
--- a/sys/src/9/ip/ipmux.c
+++ b/sys/src/9/ip/ipmux.c
@@ -745,10 +745,7 @@
 		/* tack on interface address */
 		bp = padblock(bp, IPaddrlen);
 		ipmove(bp->rp, ifc->lifc->local);
-		bp = concatblock(bp);
-		if(bp != nil)
-			if(qpass(c->rq, bp) < 0)
-				print("Q");
+		qpass(c->rq, concatblock(bp));
 		return;
 	}
 
--- a/sys/src/9/ip/rudp.c
+++ b/sys/src/9/ip/rudp.c
@@ -574,17 +574,16 @@
 		}
 		break;
 	}
-	if(bp->next)
-		bp = concatblock(bp);
 
 	if(qfull(c->rq)) {
 		netlog(f, Logrudp, "rudp: qfull %I.%d -> %I.%d\n", raddr, rport,
 			laddr, lport);
 		freeblist(bp);
-	}
-	else
+	} else {
+		if(bp->next)
+			bp = concatblock(bp);
 		qpass(c->rq, bp);
-	
+	}
 	qunlock(ucb);
 }
 
--- a/sys/src/9/ip/tcp.c
+++ b/sys/src/9/ip/tcp.c
@@ -2437,10 +2437,7 @@
 				 * receive queue
 				 */
 				if(bp) {
-					bp = packblock(bp);
-					if(bp == nil)
-						panic("tcp packblock");
-					qpassnolim(s->rq, bp);
+					qpassnolim(s->rq, packblock(bp));
 					bp = nil;
 				}
 				tcb->rcv.nxt += length;
--- a/sys/src/9/ip/udp.c
+++ b/sys/src/9/ip/udp.c
@@ -495,18 +495,15 @@
 		break;
 	}
 
-	if(bp->next)
-		bp = concatblock(bp);
-
 	if(qfull(c->rq)){
-		qunlock(c);
 		netlog(f, Logudp, "udp: qfull %I.%d -> %I.%d\n", raddr, rport,
 		       laddr, lport);
 		freeblist(bp);
-		return;
+	} else {
+		if(bp->next)
+			bp = concatblock(bp);
+		qpass(c->rq, bp);
 	}
-
-	qpass(c->rq, bp);
 	qunlock(c);
 
 }