lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <97949e3e1003181454p362bf73dl2420f33cf72764bb@mail.gmail.com>
Date:	Thu, 18 Mar 2010 14:54:44 -0700
From:	Laurent Chavey <chavey@...gle.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	David Miller <davem@...emloft.net>, netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH] net: dev_getfirstbyhwtype() optimization

reviewed_by: Laurent Chavey <chavey@...gle.com>


On Thu, Mar 18, 2010 at 2:27 PM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> Use RCU to avoid RTNL use in dev_getfirstbyhwtype()
>
> Signed-off-by: Eric Dumazet <eric.dumazet@...il.com>
> ---
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 17b1686..0f2e9fc 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -772,14 +772,17 @@ EXPORT_SYMBOL(__dev_getfirstbyhwtype);
>
>  struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
>  {
> -       struct net_device *dev;
> +       struct net_device *dev, *ret = NULL;
>
> -       rtnl_lock();
> -       dev = __dev_getfirstbyhwtype(net, type);
> -       if (dev)
> -               dev_hold(dev);
> -       rtnl_unlock();
> -       return dev;
> +       rcu_read_lock();
> +       for_each_netdev_rcu(net, dev)
> +               if (dev->type == type) {
> +                       dev_hold(dev);
> +                       ret = dev;
> +                       break;
> +               }
> +       rcu_read_unlock();
> +       return ret;
>  }
>  EXPORT_SYMBOL(dev_getfirstbyhwtype);
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ