On Thu, 23 Sep 2004 17:40:24 +0200
Pablo Neira <pablo@xxxxxxxxxxx> wrote:
> Initially we could allocate a skb with size NLMSG_GOODSIZE, then after
> all the information has been added, we could use a function (skb_*)
> which allocates a new buffer headroom, memcpy the old skb headroom and
> release it, so we trim the useless part of the headroom. This make us
> waste some extra jiffies with memcpy's but we could save same space in
> the queue. Does such skb_* function exist?
No such function exists.
Such a function would need to modify skb->truesize and that is
very dangerous. People using such a routine would need to be
_extremely_ careful since if the skb being worked on is on
a socket queue, changing skb->truesize is going to mess up
socket buffer accounting later when the skb gets freed
and the socket buffer space liberated.
That doesn't apply to what you're trying to do here, of course.
Simpler would be:
1) For each netlink socket, allocate a page, much like TCP sockets
do.
2) Construct the netlink response in this page sized buffer,
keeping track of how much of the page is actually used.
3) At the end, allocate the skb with the necessary length,
copy into the skb from the page buffer.
4) Since the RTNL semaphore is held during the length of these
operations, the per-socket page needs no locking.
|