git: 9front

Download patch

ref: 68aa53f5e7382891427be42677be4d7a3446d70e
parent: a926ba892817ba56887b7dc9ed7590e0d4566b54
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jun 6 15:00:21 EDT 2023

ip/dhcp6d: set source address to the receiving interface ip when multicast

to make sure the reply goes out the same interface
that it came in when it was multicast desination,
put the source ip of the receiving interface.

--- a/sys/src/cmd/ip/dhcp6d.c
+++ b/sys/src/cmd/ip/dhcp6d.c
@@ -315,6 +315,7 @@
 main(int argc, char *argv[])
 {
 	uchar ibuf[4096], obuf[4096];
+	Iplifc *lifc;
 	Req r[1];
 	int fd, n, i;
 
@@ -363,7 +364,8 @@
 			continue;
 		if((r->ifc = findifc(netmtpt, r->udp->ifcaddr)) == nil)
 			continue;
-		if(localonifc(r->ifc, r->udp->raddr) == nil)
+		lifc = localonifc(r->ifc, r->udp->raddr);
+		if(lifc == nil)
 			continue;
 
 		memmove(obuf, ibuf, Udphdrsize);
@@ -376,8 +378,8 @@
 		r->req.t = r->req.p[0];
 
 		if(debug)
-		fprint(2, "%I->%I(%s) typ=%d tra=%x\n",
-			r->udp->raddr, r->udp->laddr, r->ifc->dev,
+		fprint(2, "%I->%I(%I %s) typ=%d tra=%x\n",
+			r->udp->raddr, r->udp->laddr, lifc->ip, r->ifc->dev,
 			r->req.t, r->tra);
 
 		switch(r->req.t){
@@ -421,6 +423,9 @@
 
 		addoption(r, 3);
 		addoption(r, 6);
+
+		if(ISIPV6MCAST(((Udphdr*)obuf)->laddr))
+			ipmove(((Udphdr*)obuf)->laddr, lifc->ip);
 
 		write(fd, obuf, r->resp.p-obuf);
 		if(debug) fprint(2, "\n");
--