Hi,
I am trying to modify the kernel networking code and have a question
regarding the sk_buff structure which is used to store the details of a
packet.
In this structure there are pointers called headroom, data, tailroom and
end. Does anyone know what these are used for. Or can anyone point me to a
good explanation for these fields.
I wanted to know how exactly they are populated ? Whether the headroom
contains the different headers ? What does the tailroom contain ?
Thanks,
Rahul.
> In this structure there are pointers called headroom, data, tailroom and
> end. Does anyone know what these are used for. Or can anyone point me to a
> good explanation for these fields.
There is a basic discussion in chapter 14 of Linux Device Drivers which
you can read online at http://www.xml.com/ldd/chapter/book/index.html.
jon
Jonathan Corbet
Executive editor, LWN.net
[email protected]
Thanks for the pointer. It was very helpful. Need to clarify a few more
questions though.
1. Does this mean that all the headers reside in skb->data - skb->head or
just the ethernet header ?
2. Or is it that the TCP and IP headers are considered part of data in
sk_buff and are stored in the skb->tail - skb->data section ?
I ask the second questions because I saw
skb->h.raw = skb->nh.raw = skb->data;
in netif_receive_skb() (/net/core/dev.c) function. With this statement it
would mean that there is no line of seperation between the two layers. Or
am I missing something here ?
Thanks,
Rahul.
On Tue, 22 Jun 2004, Jonathan Corbet wrote:
> > In this structure there are pointers called headroom, data, tailroom and
> > end. Does anyone know what these are used for. Or can anyone point me to a
> > good explanation for these fields.
>
> There is a basic discussion in chapter 14 of Linux Device Drivers which
> you can read online at http://www.xml.com/ldd/chapter/book/index.html.
>
> jon
>
> Jonathan Corbet
> Executive editor, LWN.net
> [email protected]
>
Hi,
can anyone explain what is the difference between the following two pieces
of code.
1. if (!pskb_may_pull(skb, sizeof(struct iphdr)))
goto inhdr_error;
iph = skb->nh.iph;
2. if (!pskb_may_pull(skb, iph->ihl*4))
goto inhdr_error;
iph = skb->nh.iph;
Also, does anyone know how the headers are stripped from the packet at the
receiving end. Does the function __pskb_pull_tail() strip of the header fields ?
Thanks,
Rahul.
On Wed, 23 Jun 2004 14:45:47 -0400 (EDT)
rahul b jain cs student <[email protected]> wrote:
> can anyone explain what is the difference between the following two pieces
> of code.
>
> 1. if (!pskb_may_pull(skb, sizeof(struct iphdr)))
> goto inhdr_error;
>
> iph = skb->nh.iph;
>
> 2. if (!pskb_may_pull(skb, iph->ihl*4))
> goto inhdr_error;
>
> iph = skb->nh.iph;
We can't dereference any of the iphdr fields (such as iph->ihl) until
we know that at least "sizeof(struct iphdr)" bytes are there first.
Thanks for your response.
I just want to know if my understanding of how the sk_buff structure is
correct.
When data arrives at the TCP layer it is pointed to by the data pointer
and the TCP header goes in the skb->data-skb->head area. When this packet
is passed to the IP layer, skb->tail-skb->data section will now contain
the TCP header + TCP data and now the IP header will be put in the new
skb->data-skb->head area.
Please let me know if this understanding is correct.
I also wanted to know does psk_may_pull() only check for correct header
length or does it (thought some func calls) strip off the IP header ?
Thanks,
Rahul.
On Wed, 23 Jun 2004, David S. Miller wrote:
> On Wed, 23 Jun 2004 14:45:47 -0400 (EDT)
> rahul b jain cs student <[email protected]> wrote:
>
> > can anyone explain what is the difference between the following two pieces
> > of code.
> >
> > 1. if (!pskb_may_pull(skb, sizeof(struct iphdr)))
> > goto inhdr_error;
> >
> > iph = skb->nh.iph;
> >
> > 2. if (!pskb_may_pull(skb, iph->ihl*4))
> > goto inhdr_error;
> >
> > iph = skb->nh.iph;
>
> We can't dereference any of the iphdr fields (such as iph->ihl) until
> we know that at least "sizeof(struct iphdr)" bytes are there first.
>
On Wed, 23 Jun 2004 16:22:53 -0400 (EDT)
rahul b jain cs student <[email protected]> wrote:
> Thanks for your response.
Thanks for not putting me on the CC: list when replying.
If you want
people specifically to continue the thread discussion with
you, you put them on the CC: list so that they know you are
addressing them.
Sorry, but I was not aware of this. I would really appreciate if you could
answer my questions. Thanks. :)
On Wed, 23 Jun 2004, David S. Miller wrote:
> On Wed, 23 Jun 2004 16:22:53 -0400 (EDT)
> rahul b jain cs student <[email protected]> wrote:
>
> > Thanks for your response.
>
> Thanks for not putting me on the CC: list when replying.
>
> If you want
> people specifically to continue the thread discussion with
> you, you put them on the CC: list so that they know you are
> addressing them.
>