shithub: riscv

Download patch

ref: 780c5dfd1a0e26d6f6320284529d87ecc11650a7
parent: 874701d1934617a5992511b713c8a0fe08491dd9
author: cinap_lenrek <[email protected]>
date: Wed Apr 11 18:57:16 EDT 2018

ip/ipconfig: setup per local address default routes

--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -548,6 +548,7 @@
 recvrahost(uchar buf[], int pktlen)
 {
 	int m, n, optype;
+	uchar src[IPaddrlen];
 	Lladdropt *llao;
 	Mtuopt *mtuo;
 	Prefixopt *prfo;
@@ -616,6 +617,7 @@
 			conf.validlt = nhgetl(prfo->validlt);
 			conf.preflt =  nhgetl(prfo->preflt);
 			issueadd6(&conf);
+			
 			if(conf.routerlt == 0)
 				break;
 			if((prfo->lar & RFMASK) != 0)
@@ -622,7 +624,10 @@
 				ipmove(conf.gaddr, prfo->pref);
 			else
 				ipmove(conf.gaddr, ra->src);
-			adddefroute(conf.gaddr, conf.laddr, conf.v6pref, conf.mask);
+
+			memmove(src, conf.v6pref, 8);
+			memmove(src+8, conf.laddr+8, 8);
+			adddefroute(conf.gaddr, conf.laddr, src, conf.mask);
 			break;
 		}
 	}
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -737,6 +737,10 @@
 			smask = IPnoaddr;
 	}
 	addroute(dst, mask, gaddr, laddr, src, smask);
+
+	/* also add a source specific route */
+	if(ipcmp(src, IPnoaddr) != 0 && ipcmp(src, v4prefix) != 0)
+		addroute(dst, mask, gaddr, laddr, src, IPallbits);
 }