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 at gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt