ia64/xen-unstable

changeset 14874:9cf4c575b509

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>
author kfraser@localhost.localdomain
date Tue Apr 17 13:21:22 2007 +0100 (2007-04-17)
parents 7b391c27f410
children 20dba1b883f2
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 17 12:21:33 2007 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 17 13:21:22 2007 +0100
     1.3 @@ -67,6 +67,13 @@
     1.4  #include <xen/platform-compat.h>
     1.5  #endif
     1.6  
     1.7 +struct netfront_cb {
     1.8 +	struct page *page;
     1.9 +	unsigned offset;
    1.10 +};
    1.11 +
    1.12 +#define NETFRONT_SKB_CB(skb)	((struct netfront_cb *)((skb)->cb))
    1.13 +
    1.14  /*
    1.15   * Mutually-exclusive module options to select receive data path:
    1.16   *  rx_copy : Packets are copied by network backend into local memory
    1.17 @@ -1354,8 +1361,8 @@ err:
    1.18  			}
    1.19  		}
    1.20  
    1.21 -		skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
    1.22 -		skb->h.raw = skb->nh.raw + rx->offset;
    1.23 +		NETFRONT_SKB_CB(skb)->page = skb_shinfo(skb)->frags[0].page;
    1.24 +		NETFRONT_SKB_CB(skb)->offset = rx->offset;
    1.25  
    1.26  		len = rx->status;
    1.27  		if (len > RX_COPY_THRESHOLD)
    1.28 @@ -1439,11 +1446,11 @@ err:
    1.29  		kfree_skb(skb);
    1.30  
    1.31  	while ((skb = __skb_dequeue(&rxq)) != NULL) {
    1.32 -		struct page *page = (struct page *)skb->nh.raw;
    1.33 +		struct page *page = NETFRONT_SKB_CB(skb)->page;
    1.34  		void *vaddr = page_address(page);
    1.35 +		unsigned offset = NETFRONT_SKB_CB(skb)->offset;
    1.36  
    1.37 -		memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
    1.38 -		       skb_headlen(skb));
    1.39 +		memcpy(skb->data, vaddr + offset, skb_headlen(skb));
    1.40  
    1.41  		if (page != skb_shinfo(skb)->frags[0].page)
    1.42  			__free_page(page);