Re: [PATCH 5/8] lguest: trivial guest network driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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~} <[email protected]>
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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux