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>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-04-17 13:21:22 +01:00
1 parent a247b8c7db
commit e30b0f0e5e
1 file changed
+12 -5
@@ -67,6 +67,13 @@
#include <xen/platform-compat.h>
#endif
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
@@ -1354,8 +1361,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)
@@ -1439,11 +1446,11 @@ err:
kfree_skb(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);
unsigned offset = NETFRONT_SKB_CB(skb)->offset;
memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
skb_headlen(skb));
memcpy(skb->data, vaddr + offset, skb_headlen(skb));
if (page != skb_shinfo(skb)->frags[0].page)
__free_page(page);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.