On Thu, 27 Sep 2007 13:01:26 -0400
Jeff Dike <[EMAIL PROTECTED]> wrote:

> +static int update_drop_skb(int max)
> +{
> +     struct sk_buff *new;
> +     int err = 0;
> +
> +     spin_lock(&drop_lock);
> +
> +     if (max <= drop_max)
> +             goto out;
> +
> +     err = -ENOMEM;
> +     new = dev_alloc_skb(max);
> +     if (new == NULL)
> +             goto out;
> +
> +     skb_put(new, max);
> +
> +     kfree_skb(drop_skb);
> +     drop_skb = new;
> +     drop_max = max;
> +     err = 0;
> +out:
> +     spin_unlock(&drop_lock);
> +
> +     return err;
> +}
> +
>  static int uml_net_rx(struct net_device *dev)
>  {
>       struct uml_net_private *lp = dev->priv;
> @@ -43,6 +82,9 @@ static int uml_net_rx(struct net_device 
>       /* If we can't allocate memory, try again next round. */
>       skb = dev_alloc_skb(lp->max_packet);
>       if (skb == NULL) {
> +             drop_skb->dev = dev;
> +             /* Read a packet into drop_skb and don't do anything with it. */
> +             (*lp->read)(lp->fd, drop_skb, lp);
>               lp->stats.rx_dropped++;
>               return 0;

Still wanna know why it is safe for uml_net_rx to be playing with
drop_skb when update_drop_skb() could be concurrently reallocating
and freeing it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to