[patch 28/32] xen: xen-netfront: use skb.cb for storing private data

From: Jeremy Fitzhardinge
Date: Sun Apr 29 2007 - 13:37:46 EST


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@xxxxxxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: Chris Wright <chrisw@xxxxxxxxxxxx>
Cc: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/