From owner-svn-src-all@freebsd.org Wed May 18 23:58:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68116B412A7; Wed, 18 May 2016 23:58:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 526901895; Wed, 18 May 2016 23:58:31 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id u4INwUHT047683 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 18 May 2016 16:58:31 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id u4INwUWE047682; Wed, 18 May 2016 16:58:30 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 18 May 2016 16:58:30 -0700 From: Gleb Smirnoff To: Matthew Macy 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> References: <201605180435.u4I4ZwYh025096@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201605180435.u4I4ZwYh025096@repo.freebsd.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2016 23:58:32 -0000 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.