git: 9front

Download patch

ref: 81dfe1667724b490d6c959f23130ab247f888ac6
parent: b4943376dca886cda04f3cc2c955499a2bb13294
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 26 16:28:01 EDT 2025

devether: eliminate loopback, make it possible to talk to devices sharing our own mac address

Now that loop-back is handled fully by devip itself,
we do not need to consider the "tome" check in transmission
anymore.

This makes it possible to communicate with hosts that share
the same mac address as us (but use differen ip addresses),
which arises with some virtual-machine (ipvtap).

Also remove the same mac check in ethermedium for arp,
we consider this not an error anymore.

Hello sleepydog :)

--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -574,12 +574,6 @@
 				}
 				break;
 			}
-		} else {
-			if(memcmp(e->sha, ifc->mac, sizeof(e->sha)) == 0){
-				print("arpreq: %V also has ether addr %E\n",
-					e->spa, e->sha);
-				break;
-			}
 		}
 
 		/*
--- a/sys/src/9/port/devether.c
+++ b/sys/src/9/port/devether.c
@@ -174,15 +174,16 @@
 
 	pkt = (Etherpkt*)bp->rp;
 	if(!(multi = pkt->d[0] & 1)){
-		tome = memcmp(pkt->d, ether->ea, Eaddrlen) == 0;
-		if(!tome && from != nil && ether->prom == 0)
+		if(from != nil && ether->prom == 0)
 			return bp;
+		tome = (from == nil || (*from)->bridge) &&
+			memcmp(pkt->d, ether->ea, Eaddrlen) == 0;
 	} else {
-		tome = 0;
 		if(from == nil && ether->prom == 0
 		&& memcmp(pkt->d, ether->bcast, Eaddrlen) != 0
 		&& !activemulti(ether, pkt->d, Eaddrlen))
 			goto Drop;
+		tome = 0;
 	}
 
 	port = -1;
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -773,15 +773,16 @@
 		goto Drop;
 	pkt = (Etherpkt*)bp->rp;
 	if(!(multi = pkt->d[0] & 1)){
-		tome = memcmp(pkt->d, macaddr, Eaddrlen) == 0;
-		if(!tome && from != nil && nprom == 0)
+		if(from != nil && nprom == 0)
 			return bp;
+		tome = (from == nil || from->bridge) &&
+			memcmp(pkt->d, macaddr, Eaddrlen) == 0;
 	} else {
-		tome = 0;
 		if(from == nil && nprom == 0
 		&& memcmp(pkt->d, bcast, Eaddrlen) != 0
 		&& activemulti(pkt->d) < 0)
 			goto Drop;
+		tome = 0;
 	}
 
 	port = -1;
--