code: plan9front

Download patch

ref: 5f42bde60275e9a0c3d317ee1e052e1aefdcdb19
parent: acefccf01e5e21456d7ce4eba7257770c944a461
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 12 18:26:12 EST 2022

devip: Fix transfoward() iphash collision

We falsely confused locally listening connections
as existing translation entires. Fix it.

--- a/sys/src/9/ip/ipaux.c
+++ b/sys/src/9/ip/ipaux.c
@@ -426,10 +426,14 @@
 
 	/* Translation already exists? */
 	iph = iphtlook(ht, sa, sp, da, dp);
-	if(iph != nil) {
-		if(iph->trans != 1)
+	if(iph != nil){
+		if(iph->trans == 1)
+			return transupdate(p, iphforward(iph));
+		if(iph->match == IPmatchexact){
+			netlog(p->f, Logtrans, "trans: backwards collision: %s!%I!%d -> %I!%d\n",
+				p->name, sa, sp, da, dp);
 			return nil;
-		return transupdate(p, iphforward(iph));
+		}
 	}
 
 	/* Bad source address? */