shithub: riscv

Download patch

ref: c739f57ac2f136e67be63a4678d4171889057105
parent: 4eee8f13cf05eba3e26ca857275641a5362c89f2
author: cinap_lenrek <[email protected]>
date: Sat Jan 4 06:49:50 EST 2020

ip/ipconfig: keep on sending router solicitation after initial RA

avm fritzbox uses very long RA period so it effectively only
responds after a router solicitation. when there are multiple
fritzbox routers on the lan, then while configuring one prefix
of the first RA, the ip stack can drop the second router
advertisement and we would never get the second route.

packets can always get lost. so we just keep on sending router
solicitations (up to 3 times) to make sure we got all the RA's.

--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -805,6 +805,7 @@
 	procsetname("recvra6 on %s %I", conf.dev, conf.lladdr);
 	notify(catch);
 
+	recvracnt = 0;
 	sendrscnt = 0;
 	if(recvra6on(ifc) == IsHostRecv){
 		sendrs(fd, v6allroutersL);
@@ -811,7 +812,6 @@
 		sendrscnt = Maxv6rss;
 	}
 
-	recvracnt = Maxv6initras;
 	sleepfor = Minv6interradelay;
 
 	for (;;) {
@@ -820,7 +820,7 @@
 		sleepfor = alarm(0);
 
 		/* wait for alarm to expire */
-		if(recvracnt == 0 && sleepfor > 100)
+		if(recvracnt >= Maxv6initras && sleepfor > 100)
 			continue;
 
 		sleepfor = Maxv6radelay;
@@ -829,7 +829,7 @@
 		if(ifc == nil) {
 			warning("recvra6: can't read router params on %s, quitting on %s",
 				conf.mpoint, conf.dev);
-			if(sendrscnt >= 0)
+			if(recvracnt == 0)
 				rendezvous(recvra6, (void*)-1);
 			exits(nil);
 		}
@@ -836,7 +836,7 @@
 
 		if(recvra6on(ifc) == IsHostNoRecv || noconfig && sendrscnt < 0){
 			warning("recvra6: recvra off, quitting on %s", conf.dev);
-			if(sendrscnt >= 0)
+			if(recvracnt == 0)
 				rendezvous(recvra6, (void*)-1);
 			exits(nil);
 		}
@@ -846,12 +846,11 @@
 				sendrscnt--;
 				sendrs(fd, v6allroutersL);
 				sleepfor = V6rsintvl + nrand(100);
-			}
-			if(sendrscnt == 0) {
-				sendrscnt--;
+			} else if(recvracnt == 0) {
 				warning("recvra6: no router advs after %d sols on %s",
 					Maxv6rss, conf.dev);
 				rendezvous(recvra6, (void*)0);
+				recvracnt = 1;
 			}
 			continue;
 		}
@@ -866,14 +865,13 @@
 		}
 
 		/* got at least initial ra; no whining */
-		if(sendrscnt >= 0)
+		if(recvracnt == 0)
 			rendezvous(recvra6, (void*)1);
-		sendrscnt = -1;
 
-		if(recvracnt > 0)
-			recvracnt--;
+		if(recvracnt < Maxv6initras)
+			recvracnt++;
 		else
-			recvracnt = Maxv6initras;
+			recvracnt = 1;
 	}
 }