All of lore.kernel.org
 help / color / mirror / Atom feed
* sk_buff structure
@ 2004-06-22 20:48 rahul b jain cs student
  2004-06-22 21:24 ` Jonathan Corbet
  0 siblings, 1 reply; 8+ messages in thread
From: rahul b jain cs student @ 2004-06-22 20:48 UTC (permalink / raw)
  To: linux-kernel

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: sk_buff structure
  2004-06-22 20:48 sk_buff structure rahul b jain cs student
@ 2004-06-22 21:24 ` Jonathan Corbet
  2004-06-22 23:03   ` rahul b jain cs student
  2004-06-23 18:45   ` Question about ip_rcv() function rahul b jain cs student
  0 siblings, 2 replies; 8+ messages in thread
From: Jonathan Corbet @ 2004-06-22 21:24 UTC (permalink / raw)
  To: rahul b jain cs student; +Cc: linux-kernel

> 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
corbet@lwn.net

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: sk_buff structure
  2004-06-22 21:24 ` Jonathan Corbet
@ 2004-06-22 23:03   ` rahul b jain cs student
  2004-06-23 18:45   ` Question about ip_rcv() function rahul b jain cs student
  1 sibling, 0 replies; 8+ messages in thread
From: rahul b jain cs student @ 2004-06-22 23:03 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-kernel

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
> corbet@lwn.net
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Question about ip_rcv() function
  2004-06-22 21:24 ` Jonathan Corbet
  2004-06-22 23:03   ` rahul b jain cs student
@ 2004-06-23 18:45   ` rahul b jain cs student
  2004-06-23 18:50     ` David S. Miller
  1 sibling, 1 reply; 8+ messages in thread
From: rahul b jain cs student @ 2004-06-23 18:45 UTC (permalink / raw)
  To: linux-kernel

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question about ip_rcv() function
  2004-06-23 18:45   ` Question about ip_rcv() function rahul b jain cs student
@ 2004-06-23 18:50     ` David S. Miller
  2004-06-23 20:22       ` rahul b jain cs student
  0 siblings, 1 reply; 8+ messages in thread
From: David S. Miller @ 2004-06-23 18:50 UTC (permalink / raw)
  To: rahul b jain cs student; +Cc: linux-kernel

On Wed, 23 Jun 2004 14:45:47 -0400 (EDT)
rahul b jain cs student <rbj2@oak.njit.edu> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question about ip_rcv() function
  2004-06-23 18:50     ` David S. Miller
@ 2004-06-23 20:22       ` rahul b jain cs student
  2004-06-23 20:32         ` David S. Miller
  0 siblings, 1 reply; 8+ messages in thread
From: rahul b jain cs student @ 2004-06-23 20:22 UTC (permalink / raw)
  To: linux-kernel

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 <rbj2@oak.njit.edu> 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.
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question about ip_rcv() function
  2004-06-23 20:22       ` rahul b jain cs student
@ 2004-06-23 20:32         ` David S. Miller
  2004-06-23 20:43           ` rahul b jain cs student
  0 siblings, 1 reply; 8+ messages in thread
From: David S. Miller @ 2004-06-23 20:32 UTC (permalink / raw)
  To: rahul b jain cs student; +Cc: linux-kernel

On Wed, 23 Jun 2004 16:22:53 -0400 (EDT)
rahul b jain cs student <rbj2@oak.njit.edu> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question about ip_rcv() function
  2004-06-23 20:32         ` David S. Miller
@ 2004-06-23 20:43           ` rahul b jain cs student
  0 siblings, 0 replies; 8+ messages in thread
From: rahul b jain cs student @ 2004-06-23 20:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: davem

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 <rbj2@oak.njit.edu> 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.
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-23 20:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-22 20:48 sk_buff structure rahul b jain cs student
2004-06-22 21:24 ` Jonathan Corbet
2004-06-22 23:03   ` rahul b jain cs student
2004-06-23 18:45   ` Question about ip_rcv() function rahul b jain cs student
2004-06-23 18:50     ` David S. Miller
2004-06-23 20:22       ` rahul b jain cs student
2004-06-23 20:32         ` David S. Miller
2004-06-23 20:43           ` rahul b jain cs student

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.