Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Oct 2019 20:18:36 +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: r353502 - head/sys/dev/mxge
Message-ID:  <201910142018.x9EKIaFu064517@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Mon Oct 14 20:18:36 2019
New Revision: 353502
URL: https://svnweb.freebsd.org/changeset/base/353502

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

Modified:
  head/sys/dev/mxge/if_mxge.c

Modified: head/sys/dev/mxge/if_mxge.c
==============================================================================
--- head/sys/dev/mxge/if_mxge.c	Mon Oct 14 19:17:00 2019	(r353501)
+++ head/sys/dev/mxge/if_mxge.c	Mon Oct 14 20:18:36 2019	(r353502)
@@ -1091,12 +1091,35 @@ mxge_change_promisc(mxge_softc_t *sc, int promisc)
 	}
 }
 
+struct mxge_add_maddr_ctx {
+	mxge_softc_t *sc;
+	int error;
+};
+
+static u_int
+mxge_add_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	struct mxge_add_maddr_ctx *ctx = arg;
+	mxge_cmd_t cmd;
+
+	if (ctx->error != 0)
+		return (0);
+	bcopy(LLADDR(sdl), &cmd.data0, 4);
+	bcopy(LLADDR(sdl) + 4, &cmd.data1, 2);
+	cmd.data0 = htonl(cmd.data0);
+	cmd.data1 = htonl(cmd.data1);
+
+	ctx->error = mxge_send_cmd(ctx->sc, MXGEFW_JOIN_MULTICAST_GROUP, &cmd);
+
+	return (1);
+}
+
 static void
 mxge_set_multicast_list(mxge_softc_t *sc)
 {
-	mxge_cmd_t cmd;
-	struct ifmultiaddr *ifma;
+	struct mxge_add_maddr_ctx ctx;
 	struct ifnet *ifp = sc->ifp;
+	mxge_cmd_t cmd;
 	int err;
 
 	/* This firmware is known to not support multicast */
@@ -1129,28 +1152,16 @@ mxge_set_multicast_list(mxge_softc_t *sc)
 	}
 
 	/* Walk the multicast list, and add each address */
-
-	if_maddr_rlock(ifp);
-	CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-		if (ifma->ifma_addr->sa_family != AF_LINK)
-			continue;
-		bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-		      &cmd.data0, 4);
-		bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr) + 4,
-		      &cmd.data1, 2);
-		cmd.data0 = htonl(cmd.data0);
-		cmd.data1 = htonl(cmd.data1);
-		err = mxge_send_cmd(sc, MXGEFW_JOIN_MULTICAST_GROUP, &cmd);
-		if (err != 0) {
-			device_printf(sc->dev, "Failed "
-			       "MXGEFW_JOIN_MULTICAST_GROUP, error status:"
-			       "%d\t", err);
-			/* abort, leaving multicast filtering off */
-			if_maddr_runlock(ifp);
-			return;
-		}
+	ctx.sc = sc;
+	ctx.error = 0;
+	if_foreach_llmaddr(ifp, mxge_add_maddr, &ctx);
+	if (ctx.error != 0) {
+		device_printf(sc->dev, "Failed MXGEFW_JOIN_MULTICAST_GROUP, "
+		    "error status:" "%d\t", ctx.error);
+		/* abort, leaving multicast filtering off */
+		return;
 	}
-	if_maddr_runlock(ifp);
+
 	/* Enable multicast filtering */
 	err = mxge_send_cmd(sc, MXGEFW_DISABLE_ALLMULTI, &cmd);
 	if (err != 0) {



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