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

Gleb Smirnoff glebius at FreeBSD.org
Mon Oct 14 20:32:09 UTC 2019


Author: glebius
Date: Mon Oct 14 20:32:08 2019
New Revision: 353517
URL: https://svnweb.freebsd.org/changeset/base/353517

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

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

Modified: head/sys/dev/usb/net/if_axe.c
==============================================================================
--- head/sys/dev/usb/net/if_axe.c	Mon Oct 14 20:31:57 2019	(r353516)
+++ head/sys/dev/usb/net/if_axe.c	Mon Oct 14 20:32:08 2019	(r353517)
@@ -481,13 +481,23 @@ axe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *
 	AXE_UNLOCK(sc);
 }
 
+static u_int
+axe_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	uint8_t *hashtbl = arg;
+	uint32_t h;
+
+	h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+	hashtbl[h / 8] |= 1 << (h % 8);
+
+	return (1);
+}
+
 static void
 axe_setmulti(struct usb_ether *ue)
 {
 	struct axe_softc *sc = uether_getsc(ue);
 	struct ifnet *ifp = uether_getifp(ue);
-	struct ifmultiaddr *ifma;
-	uint32_t h = 0;
 	uint16_t rxmode;
 	uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
@@ -503,16 +513,7 @@ axe_setmulti(struct usb_ether *ue)
 	}
 	rxmode &= ~AXE_RXCMD_ALLMULTI;
 
-	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;
-		hashtbl[h / 8] |= 1 << (h % 8);
-	}
-	if_maddr_runlock(ifp);
+	if_foreach_llmaddr(ifp, axe_hash_maddr, &hashtbl);
 
 	axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *)&hashtbl);
 	axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);


More information about the svn-src-all mailing list