svn commit: r300113 - in head/sys: conf kern net sys

K. Macy kmacy at freebsd.org
Thu May 19 00:16:22 UTC 2016


Those are new. Please just patch iflib to use them and let's move on.
-M

On Wed, May 18, 2016 at 4:58 PM, Gleb Smirnoff <glebius at freebsd.org> wrote:
>   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.


More information about the svn-src-all mailing list