mapping address pointer to page structure

Dave Hylands dhylands at gmail.com
Thu Mar 31 18:12:14 EDT 2011


Hi,

On Wed, Mar 30, 2011 at 9:09 PM, swathi suresh
<swathi.suresh07 at gmail.com> wrote:
>
> On Wed, Mar 30, 2011 at 10:42 PM, sk.syed2 <sk.syed2 at gmail.com> wrote:
>>
>> > struct page *page = virt_to_page(skb->data);
>> > int offset = (unsigned long) skb->data - (unsigned long)
>> > page_address(page);
>> > skb_add_rx_frag(master_skb, skb_shinfo(master_skb)->nr_frags, page,
>> > offset,
>> > skb->len)
>> > .
>> > .
>> > is this the right way to do ?
>> This will work if skb->len < PAGE_SIZE, otherwise it means it spans
>> more than a page and you need to do skb_add_rx_frag for each PAGE_SIZE
>> data present. Refer to Understanding Linux network internals By
>> Christian Benvenuti p 488/489.
>
> Thanks Syed, skb->len is always smaller then PAGE_SIZE because i have set
> the mtu size as 1500 from my network driver.
> But am facing kernel panic, if i just the moment the driver call
> dev_queue_xmit, so i guess this may not  be right way to get
> the page.

It isn't sufficient for skb->len to just be less than PAGE_SIZE.
offset + skb->len also has to be less than PAGE_SIZE, otherwise your
data will cross into a different page.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com



More information about the Kernelnewbies mailing list