git: 9front

Download patch

ref: 5395e1e554505d508f69d036d255bf45e22474f2
parent: 02c6d8ed7eb46656684b089adff555db326fddff
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? */
--