Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2019 18:06:53 +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: r353814 - head/sys/dev/fxp
Message-ID:  <201910211806.x9LI6rou065196@repo.freebsd.org>

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

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/fxp/if_fxp.c

Modified: head/sys/dev/fxp/if_fxp.c
==============================================================================
--- head/sys/dev/fxp/if_fxp.c	Mon Oct 21 18:06:31 2019	(r353813)
+++ head/sys/dev/fxp/if_fxp.c	Mon Oct 21 18:06:53 2019	(r353814)
@@ -245,7 +245,7 @@ static void		fxp_discard_rfabuf(struct fxp_softc *sc,
 			    struct fxp_rx *rxp);
 static int		fxp_new_rfabuf(struct fxp_softc *sc,
 			    struct fxp_rx *rxp);
-static int		fxp_mc_addrs(struct fxp_softc *sc);
+static void		fxp_mc_addrs(struct fxp_softc *sc);
 static void		fxp_mc_setup(struct fxp_softc *sc);
 static uint16_t		fxp_eeprom_getword(struct fxp_softc *sc, int offset,
 			    int autosize);
@@ -2976,27 +2976,37 @@ fxp_ioctl(if_t ifp, u_long command, caddr_t data)
 	return (error);
 }
 
+static u_int
+fxp_setup_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	struct fxp_softc *sc = arg;
+	struct fxp_cb_mcs *mcsp = sc->mcsp;
+
+	if (mcsp->mc_cnt < MAXMCADDR)
+		bcopy(LLADDR(sdl), mcsp->mc_addr[mcsp->mc_cnt * ETHER_ADDR_LEN],
+		    ETHER_ADDR_LEN);
+	mcsp->mc_cnt++;
+	return (1);
+}
+
 /*
  * Fill in the multicast address list and return number of entries.
  */
-static int
+static void
 fxp_mc_addrs(struct fxp_softc *sc)
 {
 	struct fxp_cb_mcs *mcsp = sc->mcsp;
 	if_t ifp = sc->ifp;
-	int nmcasts = 0;
 
 	if ((if_getflags(ifp) & IFF_ALLMULTI) == 0) {
-		if_maddr_rlock(ifp);
-		if_setupmultiaddr(ifp, mcsp->mc_addr, &nmcasts, MAXMCADDR);
-		if (nmcasts >= MAXMCADDR) {
+		mcsp->mc_cnt = 0;
+		if_foreach_llmaddr(sc->ifp, fxp_setup_maddr, sc);
+		if (mcsp->mc_cnt >= MAXMCADDR) {
 			if_setflagbits(ifp, IFF_ALLMULTI, 0);
-			nmcasts = 0;
+			mcsp->mc_cnt = 0;
 		}
-		if_maddr_runlock(ifp);
 	}
-	mcsp->mc_cnt = htole16(nmcasts * ETHER_ADDR_LEN);
-	return (nmcasts);
+	mcsp->mc_cnt = htole16(mcsp->mc_cnt * ETHER_ADDR_LEN);
 }
 
 /*



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