Date: Wed, 18 May 2016 16:58:30 -0700 From: Gleb Smirnoff <glebius@FreeBSD.org> To: Matthew Macy <kmacy@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300113 - in head/sys: conf kern net sys Message-ID: <20160518235830.GQ1015@FreeBSD.org> In-Reply-To: <201605180435.u4I4ZwYh025096@repo.freebsd.org> References: <201605180435.u4I4ZwYh025096@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi! On Wed, May 18, 2016 at 04:35:58AM +0000, Scott Long wrote: S> ============================================================================== S> --- head/sys/net/if.c Wed May 18 04:04:14 2016 (r300112) S> +++ head/sys/net/if.c Wed May 18 04:35:58 2016 (r300113) S> @@ -3900,6 +3900,19 @@ if_multiaddr_count(if_t ifp, int max) S> return (count); S> } S> S> +int S> +if_multi_apply(struct ifnet *ifp, int (*filter)(void *, struct ifmultiaddr *, int), void *arg) S> +{ S> + struct ifmultiaddr *ifma; S> + int cnt = 0; S> + S> + if_maddr_rlock(ifp); S> + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) S> + cnt += filter(arg, ifma, cnt); S> + if_maddr_runlock(ifp); S> + return (cnt); S> +} S> + S> struct mbuf * S> if_dequeue(if_t ifp) S> { In my projects/ifnet a similar functions exist: /* * Traversing through interface address lists. */ typedef void ifaddr_cb_t(void *, struct sockaddr *, struct sockaddr *, struct sockaddr *); typedef void ifmaddr_cb_t(void *, struct sockaddr *); void if_foreach_addr(if_t, ifaddr_cb_t, void *); void if_foreach_maddr(if_t, ifmaddr_cb_t, void *); /* * Methods for drivers to access interface unicast and multicast * addresses. Driver do not know 'struct ifaddr' neither 'struct ifmultiaddr'. */ void if_foreach_addr(if_t ifp, ifaddr_cb_t cb, void *cb_arg) { struct ifaddr *ifa; IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) (*cb)(cb_arg, ifa->ifa_addr, ifa->ifa_dstaddr, ifa->ifa_netmask); IF_ADDR_RUNLOCK(ifp); } void if_foreach_maddr(if_t ifp, ifmaddr_cb_t cb, void *cb_arg) { struct ifmultiaddr *ifma; IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) (*cb)(cb_arg, ifma->ifma_addr); IF_ADDR_RUNLOCK(ifp); } Do you mind if I adopt head to them instead of if_multi_apply()? -- Totus tuus, Glebius.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160518235830.GQ1015>