lkml.org 
[lkml]   [2007]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 22/25] xen: xen-netfront: use skb.cb for storing private data
    Netfront's use of nh.raw and h.raw for storing page+offset is a bit
    hinky, and it breaks with upcoming network stack updates which reduce
    these fields to sub-pointer sizes. Fortunately, skb offers the "cb"
    field specifically for stashing this kind of info, so use it.

    Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Chris Wright <chrisw@sous-sol.org>
    Cc: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>

    ---
    drivers/net/xen-netfront.c | 18 +++++++++++++-----
    1 file changed, 13 insertions(+), 5 deletions(-)

    ===================================================================
    --- a/drivers/net/xen-netfront.c
    +++ b/drivers/net/xen-netfront.c
    @@ -52,6 +52,13 @@
    #include <xen/page.h>
    #include <xen/grant_table.h>

    +struct netfront_cb {
    + struct page *page;
    + unsigned offset;
    +};
    +
    +#define NETFRONT_SKB_CB(skb) ((struct netfront_cb *)((skb)->cb))
    +
    /*
    * Mutually-exclusive module options to select receive data path:
    * rx_copy : Packets are copied by network backend into local memory
    @@ -944,10 +951,11 @@ static void handle_incoming_queue(struct
    struct sk_buff *skb;

    while ((skb = __skb_dequeue(rxq)) != NULL) {
    - struct page *page = (struct page *)skb->nh.raw;
    + struct page *page = NETFRONT_SKB_CB(skb)->page;
    void *vaddr = page_address(page);
    -
    - memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
    + unsigned offset = NETFRONT_SKB_CB(skb)->offset;
    +
    + memcpy(skb->data, vaddr + offset,
    skb_headlen(skb));

    if (page != skb_shinfo(skb)->frags[0].page)
    @@ -1251,8 +1259,8 @@ err:
    }
    }

    - skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
    - skb->h.raw = skb->nh.raw + rx->offset;
    + NETFRONT_SKB_CB(skb)->page = skb_shinfo(skb)->frags[0].page;
    + NETFRONT_SKB_CB(skb)->offset = rx->offset;

    len = rx->status;
    if (len > RX_COPY_THRESHOLD)
    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-04-24 01:15    [W:2.304 / U:0.556 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site