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]
Date:   Tue, 2 May 2017 12:16:13 -0400
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Miroslav Lichvar <mlichvar@...hat.com>
Cc:     Network Development <netdev@...r.kernel.org>,
        Richard Cochran <richardcochran@...il.com>,
        Willem de Bruijn <willemb@...gle.com>,
        Soheil Hassas Yeganeh <soheil@...gle.com>,
        "Keller, Jacob E" <jacob.e.keller@...el.com>,
        Denny Page <dennypage@...com>, Jiri Benc <jbenc@...hat.com>
Subject: Re: [PATCH v2 net-next 3/7] net: add function to retrieve original
 skb device using NAPI ID

On Tue, May 2, 2017 at 6:10 AM, Miroslav Lichvar <mlichvar@...hat.com> wrote:
> Since commit b68581778cd0 ("net: Make skb->skb_iif always track
> skb->dev") skbs don't have the original index of the interface which
> received the packet. This information is now needed for a new control
> message related to hardware timestamping.
>
> Instead of adding a new field to skb, we can find the device by the NAPI
> ID if it is available, i.e. CONFIG_NET_RX_BUSY_POLL is enabled and the
> driver is using NAPI. Add dev_get_by_napi_id() and also skb_napi_id() to
> hide the CONFIG_NET_RX_BUSY_POLL ifdef.
>
> CC: Richard Cochran <richardcochran@...il.com>
> CC: Willem de Bruijn <willemb@...gle.com>
> Suggested-by: Willem de Bruijn <willemb@...gle.com>
> Signed-off-by: Miroslav Lichvar <mlichvar@...hat.com>

>  /**
> + *     dev_get_by_napi_id - find a device by napi_id
> + *     @napi_id: ID of the NAPI struct
> + *
> + *     Search for an interface by NAPI ID. Returns %NULL if the device
> + *     is not found or a pointer to the device. The device has not had
> + *     its reference counter increased so the caller must be careful
> + *     about locking. The caller must hold RCU lock.

Instead of a comment, can check with

  WARN_ON_ONCE(!rcu_read_lock_held());

> + */
> +
> +struct net_device *dev_get_by_napi_id(unsigned int napi_id)
> +{
> +       struct napi_struct *napi;
> +
> +       if (napi_id < MIN_NAPI_ID)
> +               return NULL;
> +
> +       napi = napi_by_id(napi_id);
> +       if (napi)
> +               return napi->dev;
> +
> +       return NULL;

make return NULL the branch expected not taken.

  return napi ? napi->dev : NULL;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ