shithub: riscv

Download patch

ref: c35027e03deb38af50b6ac5ce26d7c808b7594d5
parent: 52b773d635aa7ffefac5f1e64ed97c3d67d34e5f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Aug 26 18:25:35 EDT 2018

ip/ipconfig: check for recvra 0 on timeout

--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -824,9 +824,11 @@
 		sleepfor = alarm(0);
 
 		/* wait for alarm to expire */
-		if(sendrscnt < 0 && sleepfor > 100)
+		if(recvracnt == 0 && sleepfor > 100)
 			continue;
 
+		sleepfor = Maxv6radelay;
+
 		ifc = readipifc(conf.mpoint, ifc, myifc);
 		if(ifc == nil) {
 			warning("recvra6: can't read router params on %s, quitting on %s",
@@ -836,6 +838,13 @@
 			exits(nil);
 		}
 
+		if(recvra6on(ifc) == IsHostNoRecv){
+			warning("recvra6: recvra off, quitting on %s", conf.dev);
+			if(sendrscnt >= 0)
+				rendezvous(recvra6, (void*)-1);
+			exits(nil);
+		}
+
 		if(n <= 0) {
 			if(sendrscnt > 0) {
 				sendrscnt--;
@@ -847,7 +856,6 @@
 				warning("recvra6: no router advs after %d sols on %s",
 					Maxv6rss, conf.dev);
 				rendezvous(recvra6, (void*)0);
-				sleepfor = 0;
 			}
 			continue;
 		}
@@ -859,11 +867,6 @@
 		case IsHostRecv:
 			recvrahost(buf, n);
 			break;
-		case IsHostNoRecv:
-			warning("recvra6: recvra off, quitting on %s", conf.dev);
-			if(sendrscnt >= 0)
-				rendezvous(recvra6, (void*)-1);
-			exits(nil);
 		}
 
 		/* got at least initial ra; no whining */
@@ -870,14 +873,11 @@
 		if(sendrscnt >= 0)
 			rendezvous(recvra6, (void*)1);
 		sendrscnt = -1;
-		sleepfor = 0;
 
 		if(recvracnt > 0)
 			recvracnt--;
-		else {
+		else
 			recvracnt = Maxv6initras;
-			sleepfor = Maxv6radelay;
-		}
 	}
 }