Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2019 18:12:03 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r353852 - head/sys/dev/oce
Message-ID:  <201910211812.x9LIC3XM072418@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Mon Oct 21 18:12:02 2019
New Revision: 353852
URL: https://svnweb.freebsd.org/changeset/base/353852

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/oce/oce_hw.c

Modified: head/sys/dev/oce/oce_hw.c
==============================================================================
--- head/sys/dev/oce/oce_hw.c	Mon Oct 21 18:11:58 2019	(r353851)
+++ head/sys/dev/oce/oce_hw.c	Mon Oct 21 18:12:02 2019	(r353852)
@@ -544,7 +544,21 @@ oce_hw_intr_disable(POCE_SOFTC sc)
 }
 
 
+static u_int
+oce_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	struct mbx_set_common_iface_multicast *req = arg;
 
+	if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE)
+		return (0);
+
+	bcopy(LLADDR(sdl), &req->params.req.mac[req->params.req.num_mac++],
+	    ETH_ADDR_LEN);
+
+	return (1);
+}
+
+
 /**
  * @brief		Function for hardware update multicast filter
  * @param sc		software handle to the device
@@ -553,7 +567,6 @@ int
 oce_hw_update_multicast(POCE_SOFTC sc)
 {
 	struct ifnet    *ifp = sc->ifp;
-	struct ifmultiaddr *ifma;
 	struct mbx_set_common_iface_multicast *req = NULL;
 	OCE_DMA_MEM dma;
 	int rc = 0;
@@ -566,29 +579,15 @@ oce_hw_update_multicast(POCE_SOFTC sc)
 	req = OCE_DMAPTR(&dma, struct mbx_set_common_iface_multicast);
 	bzero(req, sizeof(struct mbx_set_common_iface_multicast));
 
-#if __FreeBSD_version > 800000
-	if_maddr_rlock(ifp);
-#endif
-	CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-		if (ifma->ifma_addr->sa_family != AF_LINK)
-			continue;
-
-		if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE) {
-			/*More multicast addresses than our hardware table
-			  So Enable multicast promiscus in our hardware to
-			  accept all multicat packets
-			*/
-			req->params.req.promiscuous = 1;
-			break;
-		}
-		bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-			&req->params.req.mac[req->params.req.num_mac],
-			ETH_ADDR_LEN);
-		req->params.req.num_mac = req->params.req.num_mac + 1;
+	if_foreach_llmaddr(ifp, oce_copy_maddr, req);
+	if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE) {
+		/*More multicast addresses than our hardware table
+		  So Enable multicast promiscus in our hardware to
+		  accept all multicat packets
+		*/
+		req->params.req.promiscuous = 1;
 	}
-#if __FreeBSD_version > 800000
-	if_maddr_runlock(ifp);
-#endif
+
 	req->params.req.if_id = sc->if_id;
 	rc = oce_update_multicast(sc, &dma);
 	oce_dma_free(sc, &dma);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211812.x9LIC3XM072418>