[668] in linux-net channel archive
Re: 1.3.8 broken appletalk network code
daemon@ATHENA.MIT.EDU (Alan Cox)
Fri Jul 14 00:14:43 1995
From: iialan@iifeak.swan.ac.uk (Alan Cox)
To: jduersto@kendall.mdcc.edu (Jason Duerstock)
Date: Thu, 13 Jul 1995 16:34:18 +0100 (BST)
Cc: linux-net@vger.rutgers.edu, linux-net3@www.linux.org.uk
In-Reply-To: <Pine.LNX.3.91.950713110656.9975A-100000@kendall.mdcc.edu> from "Jason Duerstock" at Jul 13, 95 11:08:54 am
> Okay...hmmm...could you at least give me a brief explanation of the
> different skb_* functions and how they work so I could attempt to look
> into it myself? Feel free to post this message back to the mailing list
> if you do.
OK
This is a scribbled summary. If it helps someone fix appletalk and/or help
debug IPX, token ring etc then its good news. I ought to write a paper on it
one day I suppose.
The old skbuff was fixed length and the appletalk code receiver used
a pointer skb->h.raw to point into the packet and skb->len to indicate
the bytes left of interest. skb->data is always the start of the block.
What happens now is:
[Space][Data area][Space]
^
skb->data
When you allocate a buffer with alloc_skb(len) you get length bytes
of room at the end of the buffer and none to add to the front. The functions
available then are
skb_reserve(skb,n)
This moves the start of data forward n bytes. Thus you get n bytes
of space at the front and len-n at the end. This only works for empty skbuffs.
skb_put(skb,n)
Allocates data at the end of the buffer and returns a pointer to it.
If it doesnt fit you get an skb_put panic
skb_push(skb,n)
Allocates at the start, again if it doesnt fit it panics.
skb_pull(skb,n)
Throws away n bytes of the front of the packet (increasing the free
space at the start)
skb_trim(skb,n)
Shortens the packet to n bytes throwing away from the end.
What is supposed to occur in networking now is:
protocol layer allocates a buffer with enough space
It does an skb_reserve() to leave room for the device specific
headers and the datalink headers if used (IPX/Appletalk). It does skb_put()
calls and adds data after the space
Note: IP does a reserve to the nearest 16 byte boundary to improve
performance. This is just a performance tweak.
The datalink pushes its data and fills it in
The device pushes its data and fills it in.
Packet is sent
On receive:
Device sets skb->mac.raw to point to the hardware header start
Device moves on past header with skb_pull
Datalink extracts its header and moves on with skb_pull
Protocol xxx_rcv routine is called
This looks at the headers, adjusts the packet and queues it for
a user processs to read.