shithub: riscv

Download patch

ref: 9fd0f89856bfb42acc3343a98025edac6101d24c
parent: cf2f89c648d55fd28d29213763f276f523fb22c6
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Dec 3 11:31:34 EST 2022

devbridge: simplify ethermultiwrite()

--- a/sys/src/9/port/devbridge.c
+++ b/sys/src/9/port/devbridge.c
@@ -950,7 +950,7 @@
 static void
 ethermultiwrite(Bridge *b, Block *bp, int portid, ushort tag)
 {
-	Port *oport;
+	Port *p, *oport;
 	Etherpkt *ep;
 	int i, mcast;
 	ushort vid;
@@ -960,7 +960,7 @@
 	mcast = ep->d[0] & 1;		/* multicast bit of ethernet address */
 	oport = nil;
 	for(i=0; i<b->nport; i++) {
-		if(i == portid || b->port[i] == nil || !ismember(b->port[i], vid))
+		if(i == portid || (p = b->port[i]) == nil || !ismember(p, vid))
 			continue;
 		/*
 		 * we need to forward multicast packets for ipv6,
@@ -967,9 +967,9 @@
 		 * so always do it.
 		 */
 		if(mcast)
-			b->port[i]->outmulti++;
+			p->outmulti++;
 		else
-			b->port[i]->outunknown++;
+			p->outunknown++;
 
 		/* delay one so that the last write does not copy */
 		if(oport != nil) {
@@ -976,7 +976,7 @@
 			b->copy++;
 			etherwrite(oport, copyblock(bp, BLEN(bp)), tag);
 		}
-		oport = b->port[i];
+		oport = p;
 	}
 
 	/* last write free block */