svn commit: r353511 - head/sys/dev/usb/net

Gleb Smirnoff glebius at FreeBSD.org
Mon Oct 14 20:30:07 UTC 2019


Author: glebius
Date: Mon Oct 14 20:30:06 2019
New Revision: 353511
URL: https://svnweb.freebsd.org/changeset/base/353511

Log:
  Convert to if_foreach_llmaddr() KPI.
  
  Reviewed by:	hselasky

Modified:
  head/sys/dev/usb/net/if_rue.c

Modified: head/sys/dev/usb/net/if_rue.c
==============================================================================
--- head/sys/dev/usb/net/if_rue.c	Mon Oct 14 20:29:50 2019	(r353510)
+++ head/sys/dev/usb/net/if_rue.c	Mon Oct 14 20:30:06 2019	(r353511)
@@ -473,6 +473,21 @@ rue_setpromisc(struct usb_ether *ue)
 		RUE_CLRBIT(sc, RUE_RCR, RUE_RCR_AAP);
 }
 
+static u_int
+rue_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	uint32_t *hashes = arg;
+	int h;
+
+	h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+	if (h < 32)
+		hashes[0] |= (1 << h);
+	else
+		hashes[1] |= (1 << (h - 32));
+
+	return (1);
+}
+
 /*
  * Program the 64-bit multicast hash filter.
  */
@@ -482,10 +497,8 @@ rue_setmulti(struct usb_ether *ue)
 	struct rue_softc *sc = uether_getsc(ue);
 	struct ifnet *ifp = uether_getifp(ue);
 	uint16_t rxcfg;
-	int h = 0;
 	uint32_t hashes[2] = { 0, 0 };
-	struct ifmultiaddr *ifma;
-	int mcnt = 0;
+	int mcnt;
 
 	RUE_LOCK_ASSERT(sc, MA_OWNED);
 
@@ -505,20 +518,7 @@ rue_setmulti(struct usb_ether *ue)
 	rue_csr_write_4(sc, RUE_MAR4, 0);
 
 	/* now program new ones */
-	if_maddr_rlock(ifp);
-	CK_STAILQ_FOREACH (ifma, &ifp->if_multiaddrs, ifma_link)
-	{
-		if (ifma->ifma_addr->sa_family != AF_LINK)
-			continue;
-		h = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-		    ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
-		if (h < 32)
-			hashes[0] |= (1 << h);
-		else
-			hashes[1] |= (1 << (h - 32));
-		mcnt++;
-	}
-	if_maddr_runlock(ifp);
+	mcnt = if_foreach_llmaddr(ifp, rue_hash_maddr, &hashes);
 
 	if (mcnt)
 		rxcfg |= RUE_RCR_AM;


More information about the svn-src-all mailing list