lkml.org 
[lkml]   [2007]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/8] lguest: trivial guest network driver
On Mon, Feb 12, 2007 at 02:52:01PM +1100, Rusty Russell wrote:
>
> +static void skb_to_dma(const struct sk_buff *skb, unsigned int len,
> + struct lguest_dma *dma)
> +{
> + unsigned int i, seg;
> +
> + for (i = seg = 0; i < len; seg++, i += rest_of_page(skb->data + i)) {
> + dma->addr[seg] = virt_to_phys(skb->data + i);
> + dma->len[seg] = min((unsigned)(len - i),
> + rest_of_page(skb->data + i));
> + }
> + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, seg++) {
> + const skb_frag_t *f = &skb_shinfo(skb)->frags[i];
> + /* Should not happen with MTU less than 64k - 2 * PAGE_SIZE. */
> + if (seg == LGUEST_MAX_DMA_SECTIONS) {
> + printk("Woah dude! Megapacket!\n");
> + break;
> + }
> + dma->addr[seg] = page_to_phys(f->page) + f->page_offset;
> + dma->len[seg] = f->size;
> + }

The length field from the skb covers the fragmented parts as well.
So you don't want to use it as the boundary for the loop over the
skb header data. As it is, if the skb has fragments, the first
loop will try to read them off the header.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
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-02-12 16:59    [W:0.084 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site