History log of /haiku/src/add-ons/kernel/network/stack/net_buffer.cpp
Revision Date Author Comments
# 981d0862 11-May-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

net_buffer: fix build with tracing enabled

Change-Id: Ifc26defe30946f928bbff360ea70f33eb1352745
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5304
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 578fabde 19-Jul-2016 Axel Dörfler <axeld@pinc-software.de>

net_buffer: Fixed clang warning.

* This closes ticket #12825.


# 077c84eb 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 6d796a84 10-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed up network stack and drivers for x86_64.

* Various compilation fixes.
* Fixes to the FreeBSD compatibility layer (from comparing the x86-
specific bits with the equivalent amd64 sources in FreeBSD).
* Compile all the Ethernet drivers except for sis900 and wb840, these
require a bit more work to fix (will file a ticket soon). Tested
ipro1000 and rtl81xx, no issues.


# df2895e0 15-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Automatic whitespace cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38119 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af124a1 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* We need to acquire references to the interface_address when copying/cloning
the buffer, and we also need to release it when freeing it.
* Adapted patch by Atis: append_cloned_data() now preserves the stored header;
this is kind of bad, because it will not notice if the original header is
removed, but this could probably just be documented this way.
* Also print the reference count of the interface addresses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37993 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 61729d93 28-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d98980a4 23-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* dump_buffer() now also prints the stored header, if any, and a bit more data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37709 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74a4c33f 21-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Implemented a way to preserve header data while passing along a buffer to the
upper layers: you use the store_header() function to mark the header you want
to preserve. All subsequent remove_header() calls won't claim the actual
data, but only move the node start around.
* This header can then be restored by restore_header(). However, a call to
prepend_data() will destroy the stored header. Also, if remove_header() cuts
off a whole node, restoring the header won't succeed anymore.
* Discarded the no longer needed net_buffer::network_header field.
* Also discarded the hoplimit field which temporarily breaks the IPv6 build
until Atis reworks it.
* IPv4 now also dumps the IP header in the send path if debug output is enabled.
* icmp_error_reply() might be called so early that the net_buffer's addresses
do not point to the reply address; this is now detected, and the addresses are
taken out of the IP header in that case.
* Improved dumping the net_buffer to also include its address, and flags.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37688 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1978fb81 20-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* First part of ICMP support: this is based on the work by Ivo Vachkov (GSoC
2007), and Yin Qiu (GSoC 2008). And even though I needed to rewrite pretty
much all of it because of the countless bugs and problems it had, it still
shares the same architectural problems of introducing a domain dependent
error mechanism to the upper layers, and needing the
net_buffer::network_header hack. This I will rework later.
* net_buffer's append_size(), and prepend_size() will now gracefully handle
buffers without a data node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37647 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d1485fa 19-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

Work in progress commit by Atis Elsts (I'm posting his ChangeLog comments
directly here), I made only a few style changes:
* introduced 'has_broadcast_address' field in
struct net_address_module_info
- REVIEW: the name, and the status of this field for UNIX and L2CAP
families
* ipv6 address family support
* ipv6 address printing
* ipv6 protocol support
* ipv6 multicast support
- TODO: add and remove multicast routes in a more proper way
- TODO: support MLD
* ipv6 datalink protocol support
* icmpv6 protocol support (EchoRequest and EchoResponse messages)
* ipv6 neigbor discovery protocol support
(Advertisement and Solicitation messages)
- TODO: only the very basic support is present,
the protocol state machine is by no means completed
- TODO: replying to Solicitation does not work too good ATM
(visible, when pinging Haiku from outside)
* added Jenkin's hash algorith
* minor changes in existing IPv4 code - cleanup function
ipv4_get_loopback_address(), written by myself
* add tests: raw, udp, tcp/udp, mullicast sender
* add 'hoplimit' field in struct net_buffer
- TODO: this is just a hack, more generic approach would be better.
* add 'receive_data' function pointer in
struct net_datalink_protocol_module_info
- TODO: this is also more like a hack, to support information
passing from ICMPv6 to IPv6_datagram level.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37604 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 791b1302 25-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible NULL pointer access in case the list is empty.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f52b12e5 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Added a peak value (the maximum number of allocated objects) to the net_buffer
stats.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35602 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a3ec278a 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Made some internal lists use DoublyLinkedLists instead of struct list.
* Added a few KDL commands to improve your debugging experience.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35469 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e54d40e8 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

There's no reason for allocating with CACHE_DONT_SLEEP. The only thing that
would get us is that the allocations could fail when they wouldn't need to.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86c794e5 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7108ab1f 14-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* copy_meta_data() also copied the size of the buffer, which wasn't such a good
idea. Splitting large buffers no longer causes KDL.
* merge_buffer() now maintains the size of the source buffer while removing its
nodes.
* The paranoia checks run through again now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35073 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41e2ba14 13-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* Added missing check after an allocation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35054 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f4ee0103 05-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced ENABLE_DEBUGGER_COMMANDS with ENABLE_STATS.
* Added new ENABLE_DEBUGGER_COMMANDS that enables the new "net_buffer" KDL
command to dump a net buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33893 a95241bf-73f2-0310-859d-f6bbb57e9c96


# baddb694 12-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

Check for user buffers and properly use user_memcpy() in that case. Fixes #4770.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8daaadc 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31008 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 09173f80 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied a patch by Lukasz that already collected dust on my HD - sorry
Lukasz!
* It makes split_buffer() more efficient by avoiding making a copy of the
original buffer.
* Minor cleanup, and coding style changes by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31007 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30937053 02-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29870 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49e00d1f 02-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the container management for ancillary data from the net_buffer
module to the stack module. There's a dedicated struct
ancillary_data_container, now. One can just set the container on a
net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25292 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4e6b38af 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Following Axel's suggestions:
* Added data_node::flags field and currently only flag
DATA_NODE_READ_ONLY, indicating that the node is read-only (i.e.
a clone). If set, the node won't have any header or tail space. Not
being able to write to it is not yet enforced, though.
* Moved data_node::tail_space to data_header.
* Removed data_node:used_header_space/own_header_space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25275 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b69689a 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed free_data_header_space(). It would increase the header space
although it put the freed space in the free list. Alternating
invocations of alloc_...() and free_...() would thus increase the
header space unboundedly.
* Unified the way a data_header and data_node access the header space.
Originally data_header::data_space and data_node::header_space had to
be kept in sync, which some functions failed to do. Introduced a
header_space structure, which is located in data_header and referenced
by data_node, so that accessing it either way does always keep both
structures in sync.
* Removed the special handling for the data node created with a buffer.
Since remove_{header,trailer}() and trim() could remove it without
knowing, the last reference to the first data header would be freed
prematurely, causing operations on freed memory, and in the end a
second free which screwed the object cache's free list. This crashed
Haiku e.g. when running OpenSSH's "forwarding" test. Now the first
created node is just a node like any other. It's allocated in the data
header, too.
* Changed the mechanism how data nodes are allocated. Now they will
always be allocated on a header associated with the buffer for which
they are created. This fixes a race condition when freeing them. They
would otherwise modify the free list of a header which might be
accessed by another thread at the same time (added a TODO explaining
how the old code could possibly be fixed). Also squashed several
TODOs related to running out of header space when allocating a node.
If the buffer runs out of header space, it will simply allocate a new
header, now.
* Dealt with some TODOs regarding reverting the buffer to its previous
state when running out of memory after allocating a few nodes.
* Added several TODOs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25256 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6fc462c 27-Apr-2008 Rene Gollent <anevilyak@gmail.com>

T2 needs to be defined if net_buffer tracing is disabled entirely.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25222 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c96512da 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added tracing for net buffer data header references at tracing level 2.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25217 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c88b9c8 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added kernel tracing for the interesting net buffer operations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97c0a2b3 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Paranoia checks were accidentally globally enabled by default. Object
* cache paranoia was always enabled.
* Changed from paranoia on/off to levels. Adjusted the macros to take a
level argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d5ea6e6 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added some paranoia debug code. We track only the buffer size ATM, and
check that is remains the sum of its data node used sizes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25195 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0a15cca 23-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* When appending/prepending data to a buffer we kept the initial
reference to a newly created header. It would thus not be deleted when
the new node (which also has a reference) was removed again.
* Added debugger command "net_buffer_stats" which prints the allocation
counts of net buffers and data headers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62d7da1f 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for attaching ancillary data to a net_buffer. It's a naive
implementation ATM, since it malloc()s the required memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24940 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d2df0394 06-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* init_first_data_node() did not always set tail_space correctly, leading to
potential data corruption. This fixes bug #1388.
* get_node_at_offset() would return a node too early in the list if the offset
fell on a node boundary - didn't cause any actual harm, though.
* append_size(): renamed variable tailSpace to previousTailSpace to make
it clearer.
* Improved debug output for duplicate_buffer() and clone_buffer().
* Debug output is now prepended by the thread ID.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 157da1cd 22-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* net_buffer is a module, so it shouldn't have its initializers called
indirectly by the stack - they are now again usable separately as well.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1deb55e 23-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_interface_private: added receive queue and splited device reading from packet processing. Delivering to self no longer is executed in the sender's context, which had some problems with TCP's locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21214 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3d38faf 22-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer: prevent modules from messing with metadata too much


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21211 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 79a0d252 22-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer: preparing for better metadata management


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21210 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11b5020f 28-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

rewrote the object cache (slab) implementation a bit, preparing for further integration.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20887 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d6551d6 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

removed some of the slab's initial heavy debugging. we now merge the links into the slab itself resulting in zero overhead per buffer with MergedLink strategy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20841 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6fb3d39 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

more slab fixes, also introduced a new strategy optimized for medium sized buffers (64 >= x < 512) with lengths other than power of 2 (has an overhead of 2 words per buffer).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd89ad0e 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added locking to slab's Cache<>. Now we react to system's low memory conditions freeing up empty slabs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 457b03ec 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer is the first user of the new slab allocator, let's see how it goes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20834 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87001e05 11-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some NetBufferUtility revamp.

- introduced base NetBufferFieldReader which deals with obtaining a continuguous field to deal with.
- renamed Detach() to Sync() to better express the fact that we may be writing to the buffer.
- Fixed IPv4's and ICMP's checksum calculation as it assumed the underlying header was contiguous.
- ICMP is now able to reply to ICMP Echo Requests which were split across data nodes.
- in split_buffer(), make sure we were able to trim() the new buffer before damaging the original one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20657 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bc85ccf5 11-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* init_data_node() is now called init_first_data_node(), and also sets
data_header::first_node to that node. It will also remove some of the
burden of the callers with regard to setting its members correctly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20651 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c96882b 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

update buffer size when prepending buffers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 914c48ca 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

eat header space in each iteration in prepend_size().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20641 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f73dd74e 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

even more TCP fixage.

- don't try to remove spawned sockets from Endpoints hashtable.
- return B_WOULD_BLOCK (EAGAIN) when we time out in acquire_sem().
- use B_RELEASE_IF_WAITING_ONLY in the TCP WaitList.
- fixed a off by one issue in ReadData() which could result in more than needed iterations (and waiting).
- implemented prepending new buffers to a net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a5d84831 05-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

small cleanup, use get_node_at_offset().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20591 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb711bad 01-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some cleanups by introducing get_node_at_offset


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10f5cebe 01-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Added temporary possibility to dump a net_buffer via the buffer module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c0d50aae 18-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed several problems:
* sockaddr_storage::ss_len is max 255, but the structure itself is shorter; we must
not copy ss_len bytes without checking the length first (duplicate & clone were affected).
* count_iovecs() & get_iovecs() both did not work with empty buffers that don't
have any nodes at all (unlikely case, but should be supported).
* the net_buffer::offset union field was not copied in clone & duplicate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d344e18b 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Calmed down net_buffer and IPv4 a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19429 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c31e5df0 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

count_iovecs() and get_iovecs() now only take nodes into account that contain data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19426 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdd2dcca 01-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

* Forgot to set the data_node::located in clone_buffer().
* No need to set data_node::header in the loop - this is already done in add_data_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19408 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ad667cb 01-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

* After my recent change, append_size() did not work correctly anymore, if
the initial buffer wasn't empty.
* Enlarged the minimum header size a bit (one more data_node).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19406 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dbe78a0 28-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Discarded the use of data_header::size in the last commit, but forgot to actually
remove it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49961c14 28-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed a stupid bug in append_size() - it rounded the size-per-data_header value,
so that the buffer could be smaller than the one requested.
* Rewrote data_node management in the header; now, every data_node knows where it's
placed, and can be actually discarded as needed.
* Rewrote free space management in the header: there is now a free chunk list, so
that all memory can be reused (it's currently only used for data_nodes anyway).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc8c0ec9 26-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Small optimization for set_timer(): now only removes the timer from the list
if it won't be added anymore.
* Small fix for set_timer(): now set the timer->due field back to 0 when a
timer is removed - this prevented a timer from being correctly readded later
(possible crash)!
* net_buffer's append_cloned_data() now does some more checks to prevent unnecessary
work and detect wrong arguments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 224e38e3 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Added function to append cloned data from another buffer (to be used by TCP).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 604d21a6 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Added an offset/sequence field to the net_buffer - this can and will be used
by the TCP implementation for its reorder and retransmit queues.
* The ipv4_fragment is no longer needed, as we can use the above field there
as well - this saves one extra allocation per received fragment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19369 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e95d2f4 14-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a bunch of bugs in the net_buffer implementation; it didn't crash before,
but it also didn't create valid buffers in a number of cases:
* remove_header() did not work correctly if more than one node had to be
removed or came after the first node to be kept.
* prepend_size() did not update the offset of the following nodes.
* write_data() and read_data() both did not update the data pointer, and thus
always copied the same data to every node.
* merge_buffer() inserted the nodes in the wrong order when prepending a buffer.
* added a dump_buffer() function and lots of additional debug output (currently
commented out)
* simplified split_buffer() a bit more.
* implemented remove_trailer().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19068 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 08d85bd2 14-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Reverted back to r18850 - since we won't keep that version anyway (due to the
slab allocator we'll have one day), I don't feel like digging in an fixing its
bugs.
IOW local pings won't crash the kernel anymore, are no longer detected as
duplicates, and loopback does work now as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19066 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d07a4ae 29-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

Our heap doesn't like big allocations, use areas instead - this fixes bug #875.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02cc779b 28-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

Moved datastore implementation into net_buffer.cpp - there is no reason to clobber the kernel with it.
This also fixes the issue of exporting a C++ API from the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18974 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0054baf8 27-Sep-2006 Andrew Galante <agalante@nowhere.fake>

A few bugfixes to prepend_size and append_size so they don't create unnecessary empty nodes. Minor cleanup to ipv4.cpp.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18951 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86780a1f 20-Sep-2006 Andrew Galante <agalante@nowhere.fake>

Revamp of the net_buffer code, using a datastore. I removed the data_header struct, but this means having to malloc() all the data_node objects - There may be a speed benefit in storing these in a datastore as well. As a consequence, most of the buffer functions are much simpler, if recursive at times. I don't see this as a big problem, as most buffers will only utilize a few data_nodes at a time.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18897 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4462d8b4 14-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

implemented split_buffer()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18850 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c22d69bf 08-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

* Completed the previous commit and merger of the team/network/new_stack branch.
* Removed ppp_up and pppcontrol from the image for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18457 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 077c84eb27b25430428d356f3d13afabc0cc0d13 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 6d796a84bd484ccc4fb072a29c663b660180ae51 10-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed up network stack and drivers for x86_64.

* Various compilation fixes.
* Fixes to the FreeBSD compatibility layer (from comparing the x86-
specific bits with the equivalent amd64 sources in FreeBSD).
* Compile all the Ethernet drivers except for sis900 and wb840, these
require a bit more work to fix (will file a ticket soon). Tested
ipro1000 and rtl81xx, no issues.


# df2895e0f8e4cae88bafdf2c9f99ae3154d1fe15 15-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Automatic whitespace cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38119 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af124a15aa8cf0ddb428b8e4c83e4f12af1074c 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* We need to acquire references to the interface_address when copying/cloning
the buffer, and we also need to release it when freeing it.
* Adapted patch by Atis: append_cloned_data() now preserves the stored header;
this is kind of bad, because it will not notice if the original header is
removed, but this could probably just be documented this way.
* Also print the reference count of the interface addresses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37993 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 61729d9323a555b9025ef6ebeb85dc1627f8acf7 28-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d98980a446729ba173470ab637170120fbc20e78 23-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* dump_buffer() now also prints the stored header, if any, and a bit more data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37709 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74a4c33fdacc43ae6e4eb3bbd647a711eed4d2de 21-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Implemented a way to preserve header data while passing along a buffer to the
upper layers: you use the store_header() function to mark the header you want
to preserve. All subsequent remove_header() calls won't claim the actual
data, but only move the node start around.
* This header can then be restored by restore_header(). However, a call to
prepend_data() will destroy the stored header. Also, if remove_header() cuts
off a whole node, restoring the header won't succeed anymore.
* Discarded the no longer needed net_buffer::network_header field.
* Also discarded the hoplimit field which temporarily breaks the IPv6 build
until Atis reworks it.
* IPv4 now also dumps the IP header in the send path if debug output is enabled.
* icmp_error_reply() might be called so early that the net_buffer's addresses
do not point to the reply address; this is now detected, and the addresses are
taken out of the IP header in that case.
* Improved dumping the net_buffer to also include its address, and flags.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37688 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1978fb81ee336190191a317ad0fb413e8044f2fd 20-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* First part of ICMP support: this is based on the work by Ivo Vachkov (GSoC
2007), and Yin Qiu (GSoC 2008). And even though I needed to rewrite pretty
much all of it because of the countless bugs and problems it had, it still
shares the same architectural problems of introducing a domain dependent
error mechanism to the upper layers, and needing the
net_buffer::network_header hack. This I will rework later.
* net_buffer's append_size(), and prepend_size() will now gracefully handle
buffers without a data node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37647 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d1485fa06b26cb13b0417e3cdafd5b45520a567 19-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

Work in progress commit by Atis Elsts (I'm posting his ChangeLog comments
directly here), I made only a few style changes:
* introduced 'has_broadcast_address' field in
struct net_address_module_info
- REVIEW: the name, and the status of this field for UNIX and L2CAP
families
* ipv6 address family support
* ipv6 address printing
* ipv6 protocol support
* ipv6 multicast support
- TODO: add and remove multicast routes in a more proper way
- TODO: support MLD
* ipv6 datalink protocol support
* icmpv6 protocol support (EchoRequest and EchoResponse messages)
* ipv6 neigbor discovery protocol support
(Advertisement and Solicitation messages)
- TODO: only the very basic support is present,
the protocol state machine is by no means completed
- TODO: replying to Solicitation does not work too good ATM
(visible, when pinging Haiku from outside)
* added Jenkin's hash algorith
* minor changes in existing IPv4 code - cleanup function
ipv4_get_loopback_address(), written by myself
* add tests: raw, udp, tcp/udp, mullicast sender
* add 'hoplimit' field in struct net_buffer
- TODO: this is just a hack, more generic approach would be better.
* add 'receive_data' function pointer in
struct net_datalink_protocol_module_info
- TODO: this is also more like a hack, to support information
passing from ICMPv6 to IPv6_datagram level.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37604 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 791b130291d8355382a57330e6a807ff5e69a6f2 25-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible NULL pointer access in case the list is empty.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f52b12e51a271e68781e68aa0cdb285a6a0bb387 24-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Added a peak value (the maximum number of allocated objects) to the net_buffer
stats.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35602 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a3ec278addf578e09deac1159bba3f1a8a72b336 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Made some internal lists use DoublyLinkedLists instead of struct list.
* Added a few KDL commands to improve your debugging experience.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35469 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e54d40e8262d89229615ea91e4832352811faec7 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

There's no reason for allocating with CACHE_DONT_SLEEP. The only thing that
would get us is that the allocations could fail when they wouldn't need to.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86c794e5c10f1b2d99d672d424a8637639c703dd 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7108ab1ff9fe5758a12842c2c8dc8f541c57ffbf 14-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* copy_meta_data() also copied the size of the buffer, which wasn't such a good
idea. Splitting large buffers no longer causes KDL.
* merge_buffer() now maintains the size of the source buffer while removing its
nodes.
* The paranoia checks run through again now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35073 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41e2ba14376ef6d6be89f7914f42c4c2c263bd54 13-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* Added missing check after an allocation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35054 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f4ee0103a2c3e41b0a9a18d0d57832511fe33fd4 05-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced ENABLE_DEBUGGER_COMMANDS with ENABLE_STATS.
* Added new ENABLE_DEBUGGER_COMMANDS that enables the new "net_buffer" KDL
command to dump a net buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33893 a95241bf-73f2-0310-859d-f6bbb57e9c96


# baddb6942c90c717d4b00e2b6bb20db96eab9de1 12-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

Check for user buffers and properly use user_memcpy() in that case. Fixes #4770.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8daaadc80332ab53b26e837c6a70fbdc1bc694b 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31008 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 09173f80890cbee8489b47c62f88c776393715b2 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied a patch by Lukasz that already collected dust on my HD - sorry
Lukasz!
* It makes split_buffer() more efficient by avoiding making a copy of the
original buffer.
* Minor cleanup, and coding style changes by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31007 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3093705388f63d2d4718100720168e4f9ac2a298 02-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29870 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49e00d1f99fa525355674427039e360eb96c574b 02-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the container management for ancillary data from the net_buffer
module to the stack module. There's a dedicated struct
ancillary_data_container, now. One can just set the container on a
net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25292 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4e6b38af6c26ea68086efbfb87310875f73fb75c 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Following Axel's suggestions:
* Added data_node::flags field and currently only flag
DATA_NODE_READ_ONLY, indicating that the node is read-only (i.e.
a clone). If set, the node won't have any header or tail space. Not
being able to write to it is not yet enforced, though.
* Moved data_node::tail_space to data_header.
* Removed data_node:used_header_space/own_header_space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25275 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b69689a18b34d6a98fcad876d6871e87d3fafa1 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed free_data_header_space(). It would increase the header space
although it put the freed space in the free list. Alternating
invocations of alloc_...() and free_...() would thus increase the
header space unboundedly.
* Unified the way a data_header and data_node access the header space.
Originally data_header::data_space and data_node::header_space had to
be kept in sync, which some functions failed to do. Introduced a
header_space structure, which is located in data_header and referenced
by data_node, so that accessing it either way does always keep both
structures in sync.
* Removed the special handling for the data node created with a buffer.
Since remove_{header,trailer}() and trim() could remove it without
knowing, the last reference to the first data header would be freed
prematurely, causing operations on freed memory, and in the end a
second free which screwed the object cache's free list. This crashed
Haiku e.g. when running OpenSSH's "forwarding" test. Now the first
created node is just a node like any other. It's allocated in the data
header, too.
* Changed the mechanism how data nodes are allocated. Now they will
always be allocated on a header associated with the buffer for which
they are created. This fixes a race condition when freeing them. They
would otherwise modify the free list of a header which might be
accessed by another thread at the same time (added a TODO explaining
how the old code could possibly be fixed). Also squashed several
TODOs related to running out of header space when allocating a node.
If the buffer runs out of header space, it will simply allocate a new
header, now.
* Dealt with some TODOs regarding reverting the buffer to its previous
state when running out of memory after allocating a few nodes.
* Added several TODOs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25256 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6fc462cb316c6cc8b6de25d3a434d7b1ccaae39 27-Apr-2008 Rene Gollent <anevilyak@gmail.com>

T2 needs to be defined if net_buffer tracing is disabled entirely.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25222 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c96512dab1e230d208a1253792d298152a2fd392 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added tracing for net buffer data header references at tracing level 2.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25217 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c88b9c82a96f00b3c3f555e6b72ef7b06760496 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added kernel tracing for the interesting net buffer operations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97c0a2b3f1f9c3782c833b1d3201a4472259afac 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Paranoia checks were accidentally globally enabled by default. Object
* cache paranoia was always enabled.
* Changed from paranoia on/off to levels. Adjusted the macros to take a
level argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d5ea6e6cf3357733288d9500e46c7d7bad241e3 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added some paranoia debug code. We track only the buffer size ATM, and
check that is remains the sum of its data node used sizes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25195 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0a15ccac2572ed7e4a06ea6c47c6c0538fa60ec 23-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* When appending/prepending data to a buffer we kept the initial
reference to a newly created header. It would thus not be deleted when
the new node (which also has a reference) was removed again.
* Added debugger command "net_buffer_stats" which prints the allocation
counts of net buffers and data headers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62d7da1f45ae0926865a398a2d86e78dcaa1b125 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for attaching ancillary data to a net_buffer. It's a naive
implementation ATM, since it malloc()s the required memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24940 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d2df03947e7f3022a812fc937cea0b739d1926a2 06-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* init_first_data_node() did not always set tail_space correctly, leading to
potential data corruption. This fixes bug #1388.
* get_node_at_offset() would return a node too early in the list if the offset
fell on a node boundary - didn't cause any actual harm, though.
* append_size(): renamed variable tailSpace to previousTailSpace to make
it clearer.
* Improved debug output for duplicate_buffer() and clone_buffer().
* Debug output is now prepended by the thread ID.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 157da1cd6e329a107d5a1fddd644cdab280a779e 22-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* net_buffer is a module, so it shouldn't have its initializers called
indirectly by the stack - they are now again usable separately as well.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a1deb55ef50ae33e7533745d8a37891ddd6c885b 23-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_interface_private: added receive queue and splited device reading from packet processing. Delivering to self no longer is executed in the sender's context, which had some problems with TCP's locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21214 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3d38faf41129aba9702e63231c20503a15631c9 22-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer: prevent modules from messing with metadata too much


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21211 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 79a0d25245275ef5f65afd610279dc9befffd65e 22-May-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer: preparing for better metadata management


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21210 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11b5020f2fa2dcc510704cf3fb8dc9c3d3ea1f71 28-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

rewrote the object cache (slab) implementation a bit, preparing for further integration.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20887 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d6551d69fba2bf63472185322b85f96fbc68b54 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

removed some of the slab's initial heavy debugging. we now merge the links into the slab itself resulting in zero overhead per buffer with MergedLink strategy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20841 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6fb3d3947b167b0b79b4c6932c481fde9d79c5c 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

more slab fixes, also introduced a new strategy optimized for medium sized buffers (64 >= x < 512) with lengths other than power of 2 (has an overhead of 2 words per buffer).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd89ad0e7e1cd4d1499084bc781e8a19ae78deae 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added locking to slab's Cache<>. Now we react to system's low memory conditions freeing up empty slabs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 457b03ecb40c3317bd31df1f2ef4ff01b38007e8 26-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

net_buffer is the first user of the new slab allocator, let's see how it goes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20834 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87001e059c8012ef40c462709833b5ae4212fb4a 11-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some NetBufferUtility revamp.

- introduced base NetBufferFieldReader which deals with obtaining a continuguous field to deal with.
- renamed Detach() to Sync() to better express the fact that we may be writing to the buffer.
- Fixed IPv4's and ICMP's checksum calculation as it assumed the underlying header was contiguous.
- ICMP is now able to reply to ICMP Echo Requests which were split across data nodes.
- in split_buffer(), make sure we were able to trim() the new buffer before damaging the original one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20657 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bc85ccf5f33f0e0db2080ed9798c791880ab610a 11-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* init_data_node() is now called init_first_data_node(), and also sets
data_header::first_node to that node. It will also remove some of the
burden of the callers with regard to setting its members correctly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20651 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c96882baaaab13eb523a237c958851f13055185 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

update buffer size when prepending buffers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 914c48cad71e3fd5483d978b5b61fdd5772509f8 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

eat header space in each iteration in prepend_size().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20641 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f73dd74eb9660085e4db4c9f7597885bb04c1569 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

even more TCP fixage.

- don't try to remove spawned sockets from Endpoints hashtable.
- return B_WOULD_BLOCK (EAGAIN) when we time out in acquire_sem().
- use B_RELEASE_IF_WAITING_ONLY in the TCP WaitList.
- fixed a off by one issue in ReadData() which could result in more than needed iterations (and waiting).
- implemented prepending new buffers to a net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a5d8483183b46642649a637d999f4798fa9bfd20 05-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

small cleanup, use get_node_at_offset().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20591 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb711badc173de6d5f8a4aee324a2b9e0b3e596c 01-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some cleanups by introducing get_node_at_offset


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10f5cebea35bf9ec47fb6b23f1d852fbab358ee0 01-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Added temporary possibility to dump a net_buffer via the buffer module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c0d50aaedb4fcf1f0fd8934a08b6b93d05066a92 18-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed several problems:
* sockaddr_storage::ss_len is max 255, but the structure itself is shorter; we must
not copy ss_len bytes without checking the length first (duplicate & clone were affected).
* count_iovecs() & get_iovecs() both did not work with empty buffers that don't
have any nodes at all (unlikely case, but should be supported).
* the net_buffer::offset union field was not copied in clone & duplicate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d344e18b94d78908443fa24b5f1d2b0d7f4b0aef 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Calmed down net_buffer and IPv4 a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19429 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c31e5df06c83afd794432bb184accbd50772798e 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

count_iovecs() and get_iovecs() now only take nodes into account that contain data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19426 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdd2dcca7fe3a90231b52bde9de9db255ea87f06 01-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

* Forgot to set the data_node::located in clone_buffer().
* No need to set data_node::header in the loop - this is already done in add_data_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19408 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ad667cb0b87d251fff7bc2f8f9361e225b232e2 01-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

* After my recent change, append_size() did not work correctly anymore, if
the initial buffer wasn't empty.
* Enlarged the minimum header size a bit (one more data_node).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19406 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dbe78a0cd5fa035275331f0e2ffec6ea6e31d99 28-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Discarded the use of data_header::size in the last commit, but forgot to actually
remove it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49961c1489e9e55ca347549c6480d502be14f11c 28-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed a stupid bug in append_size() - it rounded the size-per-data_header value,
so that the buffer could be smaller than the one requested.
* Rewrote data_node management in the header; now, every data_node knows where it's
placed, and can be actually discarded as needed.
* Rewrote free space management in the header: there is now a free chunk list, so
that all memory can be reused (it's currently only used for data_nodes anyway).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc8c0ec9463706e2af4bf10d23aa53460210454f 26-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Small optimization for set_timer(): now only removes the timer from the list
if it won't be added anymore.
* Small fix for set_timer(): now set the timer->due field back to 0 when a
timer is removed - this prevented a timer from being correctly readded later
(possible crash)!
* net_buffer's append_cloned_data() now does some more checks to prevent unnecessary
work and detect wrong arguments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 224e38e30234344c0f5b3e58d584933f0d339492 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Added function to append cloned data from another buffer (to be used by TCP).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 604d21a600981253df7ba54b0f2b3ebd7107e979 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Added an offset/sequence field to the net_buffer - this can and will be used
by the TCP implementation for its reorder and retransmit queues.
* The ipv4_fragment is no longer needed, as we can use the above field there
as well - this saves one extra allocation per received fragment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19369 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e95d2f4258388a562998cfae01d169d10bb7189 14-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a bunch of bugs in the net_buffer implementation; it didn't crash before,
but it also didn't create valid buffers in a number of cases:
* remove_header() did not work correctly if more than one node had to be
removed or came after the first node to be kept.
* prepend_size() did not update the offset of the following nodes.
* write_data() and read_data() both did not update the data pointer, and thus
always copied the same data to every node.
* merge_buffer() inserted the nodes in the wrong order when prepending a buffer.
* added a dump_buffer() function and lots of additional debug output (currently
commented out)
* simplified split_buffer() a bit more.
* implemented remove_trailer().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19068 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 08d85bd29827b672ac8b4166944c67b3750f792c 14-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Reverted back to r18850 - since we won't keep that version anyway (due to the
slab allocator we'll have one day), I don't feel like digging in an fixing its
bugs.
IOW local pings won't crash the kernel anymore, are no longer detected as
duplicates, and loopback does work now as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19066 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d07a4ae752da8201137d1bfd108a012e7c3f557 29-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

Our heap doesn't like big allocations, use areas instead - this fixes bug #875.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02cc779b7d39e7fd45cc2e6ec6bec0329ec31c20 28-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

Moved datastore implementation into net_buffer.cpp - there is no reason to clobber the kernel with it.
This also fixes the issue of exporting a C++ API from the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18974 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0054baf8c918a5e560d606633d1ed81e921c1b81 27-Sep-2006 Andrew Galante <agalante@nowhere.fake>

A few bugfixes to prepend_size and append_size so they don't create unnecessary empty nodes. Minor cleanup to ipv4.cpp.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18951 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86780a1f7f2a33d0074e724a152e69fa97e510d5 20-Sep-2006 Andrew Galante <agalante@nowhere.fake>

Revamp of the net_buffer code, using a datastore. I removed the data_header struct, but this means having to malloc() all the data_node objects - There may be a speed benefit in storing these in a datastore as well. As a consequence, most of the buffer functions are much simpler, if recursive at times. I don't see this as a big problem, as most buffers will only utilize a few data_nodes at a time.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18897 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4462d8b41b261d75142fb024e58a7afe565b82b2 14-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

implemented split_buffer()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18850 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c22d69bf1f5f60f7ebddd79108a53c8f97f300fe 08-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

* Completed the previous commit and merger of the team/network/new_stack branch.
* Removed ppp_up and pppcontrol from the image for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18457 a95241bf-73f2-0310-859d-f6bbb57e9c96