shithub: riscv

Download patch

ref: 440ccbc06007422f04943378260f250f9efa5331
parent: c89dad0b9258f32ee3365400d5d4f4920aaa3f77
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jul 22 11:14:31 EDT 2023

devether: revert devether changes for ethermultilink, this breaks loopback

--- a/sys/src/9/port/devbridge.c
+++ b/sys/src/9/port/devbridge.c
@@ -69,13 +69,11 @@
 
 enum {
 	Tether,
-	Tethermac,
 	Ttun,
 };
 
 static char *typstr[] = {
 	"ether",
-	"ethermac",
 	"tunnel",
 };
 
@@ -651,7 +649,6 @@
 	default:
 		error(usage);
 	case Tether:
-	case Tethermac:
 		if(argc > 4)
 			vlan = argv[4];
 		break;
@@ -685,7 +682,6 @@
 	default:
 		panic("portbind: unknown port type: %d", type);
 	case Tether:
-	case Tethermac:
 		snprint(path, sizeof(path), "%s/clone", dev);
 		ctl = namec(path, Aopen, ORDWR, 0);
 		if(waserror()) {
@@ -703,14 +699,10 @@
 		devtab[ctl->type]->write(ctl, buf, strlen(buf), 0);
 		snprint(buf, sizeof(buf), "nonblocking");
 		devtab[ctl->type]->write(ctl, buf, strlen(buf), 0);
-
 		snprint(buf, sizeof(buf), "promiscuous");
 		devtab[ctl->type]->write(ctl, buf, strlen(buf), 0);
-
-		if(port->type != Tethermac){
-			snprint(buf, sizeof(buf), "bridge");
-			devtab[ctl->type]->write(ctl, buf, strlen(buf), 0);
-		}
+		snprint(buf, sizeof(buf), "bridge");
+		devtab[ctl->type]->write(ctl, buf, strlen(buf), 0);
 
 		/* open data port */
 		port->data[0] = namec(path, Aopen, ORDWR, 0);
--- a/sys/src/9/port/devether.c
+++ b/sys/src/9/port/devether.c
@@ -204,8 +204,6 @@
 	dispose = tome || from == nil || port > 0;
 
 	for(fp = ether->f; fp < &ether->f[Ntypes]; fp++){
-		if(fp == from)
-			continue;
 		if((f = *fp) == nil)
 			continue;
 		if(f->type != type && f->type >= 0)
@@ -213,7 +211,7 @@
 		if(!tome && !multi && !f->prom)
 			continue;
 		if(f->bridge){
-			if(tome)
+			if(tome || fp == from)
 				continue;
 			if(port >= 0 && port != 1+(fp - ether->f))
 				continue;
@@ -256,7 +254,7 @@
 static void
 etheroq(Ether* ether, Block* bp, Netfile **from)
 {
-	if((*from)->prom == 0)
+	if((*from)->bridge == 0)
 		memmove(((Etherpkt*)bp->rp)->s, ether->ea, Eaddrlen);
 
 	bp = ethermux(ether, bp, from);
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -785,7 +785,7 @@
 	dispose = tome || from == nil || port > 0;
 
 	for(c = conn; c < &conn[nconn]; c++){
-		if(!c->used || c == from)
+		if(!c->used)
 			continue;
 		if(c->type != type && c->type >= 0)
 			continue;
@@ -792,7 +792,7 @@
 		if(!tome && !multi && !c->prom)
 			continue;
 		if(c->bridge){
-			if(tome)
+			if(tome || c == from)
 				continue;
 			if(port >= 0 && port != 1+(c - conn))
 				continue;
@@ -828,7 +828,7 @@
 static void
 etheroq(Block *bp, Conn *from)
 {
-	if(!from->prom)
+	if(!from->bridge)
 		memmove(((Etherpkt*)bp->rp)->s, macaddr, Eaddrlen);
 	bp = ethermux(bp, from);
 	if(bp == nil)