svn commit: r353514 - head/sys/dev/usb/net
Gleb Smirnoff
glebius at FreeBSD.org
Mon Oct 14 20:31:29 UTC 2019
Author: glebius
Date: Mon Oct 14 20:31:28 2019
New Revision: 353514
URL: https://svnweb.freebsd.org/changeset/base/353514
Log:
Convert to if_foreach_llmaddr() KPI.
Reviewed by: hselasky
Modified:
head/sys/dev/usb/net/if_kue.c
Modified: head/sys/dev/usb/net/if_kue.c
==============================================================================
--- head/sys/dev/usb/net/if_kue.c Mon Oct 14 20:30:44 2019 (r353513)
+++ head/sys/dev/usb/net/if_kue.c Mon Oct 14 20:31:28 2019 (r353514)
@@ -357,13 +357,25 @@ kue_setpromisc(struct usb_ether *ue)
kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->sc_rxfilt);
}
+static u_int
+kue_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+ struct kue_softc *sc = arg;
+
+ if (cnt >= KUE_MCFILTCNT(sc))
+ return (1);
+
+ memcpy(KUE_MCFILT(sc, cnt), LLADDR(sdl), ETHER_ADDR_LEN);
+
+ return (1);
+}
+
static void
kue_setmulti(struct usb_ether *ue)
{
struct kue_softc *sc = uether_getsc(ue);
struct ifnet *ifp = uether_getifp(ue);
- struct ifmultiaddr *ifma;
- int i = 0;
+ int i;
KUE_LOCK_ASSERT(sc, MA_OWNED);
@@ -376,25 +388,9 @@ kue_setmulti(struct usb_ether *ue)
sc->sc_rxfilt &= ~KUE_RXFILT_ALLMULTI;
- if_maddr_rlock(ifp);
- CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link)
- {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- /*
- * If there are too many addresses for the
- * internal filter, switch over to allmulti mode.
- */
- if (i == KUE_MCFILTCNT(sc))
- break;
- memcpy(KUE_MCFILT(sc, i),
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- ETHER_ADDR_LEN);
- i++;
- }
- if_maddr_runlock(ifp);
+ i = if_foreach_llmaddr(ifp, kue_copy_maddr, sc);
- if (i == KUE_MCFILTCNT(sc))
+ if (i >= KUE_MCFILTCNT(sc))
sc->sc_rxfilt |= KUE_RXFILT_ALLMULTI;
else {
sc->sc_rxfilt |= KUE_RXFILT_MULTICAST;
More information about the svn-src-all
mailing list