History log of /haiku/src/add-ons/kernel/network/stack/interfaces.cpp
Revision Date Author Comments
# 41faeb1d 27-May-2022 Augustin Cavalier <waddlesplash@gmail.com>

net_interface & datalink: Fix MTU handling.

The device is what actually controls the MTU, and it has its own
field for this, so having a second one just meant the MTU never
got updated after startup.

Remove the "mtu" field from the interface, use the "device->mtu" directly,
and then actually invoke device->module->set_mtu when updating.


# 488f8888 10-Mar-2022 Augustin Cavalier <waddlesplash@gmail.com>

network stack: Fix deadlock in get_interface functions.

If these methods are called while the interface in question
is receiving data via a receive thread, we can hit a deadlock
where a receive thread is holding the receive lock and then
tries to call get_interface_address_for_link (due, e.g., to ipv4
checking is_local_link_address), which tries to acquire the interfaces
lock, while at the same time we are trying to acquire the receive lock
due to CreateDomainDatalinkIfNeeded invoking a module's datalink_init
which calls register_device_handler, so we deadlock. (Whew!)

As far as I can tell, we do not need to set Busy() here despite unlocking
the interfaces lock, as the Interface acquires its own lock in
CreateDomainDatalinkIfNeeded.

Observed in VMware when the DHCP client spins for a long time,
and the deadlock occurs upon opening Network preferences.


# 2828ed2f 10-Mar-2022 Augustin Cavalier <waddlesplash@gmail.com>

network stack: Add missing ASSERT_LOCKED_RECURSIVE.


# 8844a67e 10-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

More trivial syntax and logic cleanup.

Spotted by Clang. No functional change intended.


# 9923dd5c 16-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

network stack: move put_device_interface() at the end of the Interface destructor.

Fixes #10919.

Removing an interface triggers this sequence:

datalink_control() calls interface->ReleaseReference() which causes the
Interface destructor to be called. The Interface destructor calls
put_device_interface(fDeviceInterface) which destroys the
net_device_interface, then calls put_domain_datalink_protocols(this, datalink->domain)
in a loop. put_domain_datalink_protocols() tries to access the deleted
net_device_interface, hence the KDL.

Change-Id: I2326bcd6d1fd80a69e5fdfa6629563b38ecdbbac
Reviewed-on: https://review.haiku-os.org/469
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 135a1958 06-Jan-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

InterfaceAddress: The real fix.


# ab1adabf 06-Jan-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

Revert "Follow-up fix for #12152 from axeld suggestions"

This reverts commit 6f5971cf52bcab0f9cfcc203bdc8b62e3c9d8fec.

* Sorry there was a misunderstanding in the Ticket and IRC.


# 6f5971cf 05-Jan-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

Follow-up fix for #12152 from axeld suggestions


# 466081d0 13-Jun-2015 Phil Costin <philcostin@hotmail.com>

When realloc(address, size) returns NULL, address must be freed manually.

Signed-off-by: Dario Casalinuovo <b.vitruvio@gmail.com>


# 7ed2a443 24-Aug-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fix naming


# ff8c8dfc 12-Aug-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Improve patch in ticket #9377
Instead of locking the interface lock, set it busy and then unlock the
interface list lock.


# 2d6b0e96 16-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

Revert "Missing NULL check in network stack."

This reverts commit dd0ea64b5607e6310c582f62c4275dab7510c4f6.


# dd0ea64b 14-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

Missing NULL check in network stack.

This would trigger a KDL, it's better to just fail the syscall call.


# 8cf4ba89 06-Feb-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Add a TODO comment


# 8a6337d0 04-Feb-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Converted the "net_interfaces" mutex into a recursive locker, and
acquire it in Interface::SetDown().


# 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.


# 3f2a0963 22-Feb-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

All debugger commands we've added, remove we must.
Closes #7251.


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


# 5ebd9548 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* Fixed ignoring the netmask when computing the broadcast. Renamed a few
variables to make the function a bit clearer, hopefully.
* Fixed the wrong order of releasing the reference, and removing the object
from the hash table -- thanks Rene!
* Added a bit of documentation to InterfaceAddress::Prepare().


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


# b0766602 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* RemoveAddresses() needs to remove the addresses from the hash table as well.
This fixes random memory access on interface removal.
* Optimized IndexOfAddress() for NULL addresses.


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


# 4ae58630 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* Allow duplicates in the sAddressTable hash table; while it makes no sense to
have duplicates there, it should certainly not panic.
* Do not add unspecified addresses to the hash table.
* The result of adding the initial address of an interface was ignored; now, the
interface is correctly destructed, if necessary.


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


# e78fea43 10-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Added a bit more debug output.


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


# ec4fb0f4 01-Oct-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug in get_interface() that would return the first interface
without acquiring a reference to it, and thus led to bug #6565.
* Added a commented out function that dumps all current reference counts.


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


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

* Initialized the domain_datalink's first_{protocol|info} members. This fixes
the crashing bug reported by Atis when trying to add an interface which fails
(the bug causing this has already been fixed with the previous commit).


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


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

* Added ability to be able to dump a net_interface by name.


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


# 8dcde8b1 13-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* B_SOCKET_SET_ALIAS handling was leaking references.


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


# 095f97a6 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed memory leaks pointed out by Stephan, thanks!
* Automatic whitespace cleanup.


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


# 2c12b8a3 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Also report the address index back to the userland.


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


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

* Also create a new address for B_SOCKET_SET_ALIAS if the index is -1 - this
now has an almost equivalent logic to the old setters like SIOCSIFADDR.


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


# 910ffb32 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* If the network mask, and broadcast are not specified with a B_SOCKET_SET_ALIAS
they will no longer be unset - instead they are set with defaults.
* If B_SOCKET_SET_ALIAS gets an index of -1, it will now try to find the local
address, and if that fails, will just use the first address there is.


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


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

* datalink_control() also need to accept structures smaller than ifreq as long
as the interface name can be specified.


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


# 1ebd87f4 10-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* As Atis pointed out, the SIOCSIFNETMASK here didn't make any sense, must have
been a copy&paste error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38001 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


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

* Made the work-around that Atis added to ifconfig and the net_server
in order to be able to use SIOCSIFADDR (and friends) on a net yet added
family superfluous; we now add a new address when needed on the fly.


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


# 1f9c8c45 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed the _SIZEOF_ADDR_IFREQ() macro such that it can be used how we are
using it - hopefully, that is actually correct (it's adopted from FreeBSD).
* Fixed bug that cut off the sockaddr_dl reported by the system, so that DHCP
wouldn't work anymore (and ifconfig wouldn't show the actual MAC address
anymore).
* Changed the listing code to actually pad to ifreq size, and leave the length
of the sockaddr untouched.


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


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

* Interface::_ChangeAddress() got the address check for equality wrong,
effectively rejecting any try to set an address.
* It now copies the new address as well in order to make sure that its
sa_len field is set correctly.
* Improved debug output.


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


# 6b1e1488 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Only actually call change_address() of the net_datalink_protocols if the
address actually changed.


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


# 715fed44 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Make sure the SIOCGIFCONF never returns an address with an address length
smaller than sizeof(sockaddr). This fixes a compatibility issue with other
platforms - portable software often assumes that the amount of bytes to
add to an ifreq structure is the larger amount between sizeof(ifreq), and
basically what the _SIZEOF_ADDR_IFREQ() macro returns, instead of always
relying on that macro.
* Renamed UserBuffer::Copy() to Push, ConsumedAmount() to BytesConsumed(),
added Pad() method.


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


# 7aa2819c 03-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Enabled removing the interface on device removal again.
* Made the return type of remove_interface() void, as it cannot fail.


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


# 2b1c0755 03-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Renamed the proprietary SIOC_* ioctls to B_SOCKET_* - no reason to pollute
global name space, and have ugly identifiers for nothing :-)
* Added a flags field to struct ifaliasreq. Added flags to mark an alias that
is currently being configured, or has been automatically configured.
Those flags aren't used yet, but they will replace IFF_CONFIGURING and
friends.
* Implemented deleting addresses only from interfaces via ifconfig.
* Added more command aliases for delete to ifconfig ("del", and "delete", for
more consistency with route).
* Fixed control_routes() to only release a reference to an address if it
actually got one before.
* If an interface address is deleted, its routes are now removed as well.
* InterfaceAddress now holds a reference to its interface as planned.
* Implemented removing interfaces. Works quite nicely.
* When downing an interface, all of its routes are now removed. When upping
it again, at least the default routes are added.
* datalink.cpp's get_interface_name_or_index() leaked a reference to the
interface found.
* SIOCAIFADDR would also leak a reference when new addresses were added.


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


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

* Work in progress of extending the AF_LINK protocol to be able to send and
receive raw packets (only without the ethernet framing).


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


# 9d771afb 29-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Added Haiku specific socket ioctls to configure the interface aliases:
SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_REMOVE, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET,
and SIOC_IF_ALIAS_COUNT.
* Implemented all of those new ioctls, though they are yet untested.
* Added ifreq::ifr_data, and removed the hack in the FreeBSD compat if.h
header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37806 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


# 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


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

* Locking order dictates that this lock is an inner lock, and shouldn't
be used everywhere.
* This also fixes a panic when deleting interfaces (an already deleted
lock was unlocked).


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


# 26153d0f 03-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* The net_domain's lock is now a recursive lock.
* Fixed all route locking problems, of which there were numerous
({add|remove}_route(), and list_routes() did not lock at all). Added
lock assertions in functions that don't do the locking themselves.
* A route will now be removed from the list in remove_route(), not in
put_route_internal(). Before, a route could easily be removed twice, causing
remove_route() to release references it did not own. This fixes bug #2706.


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


# 3c13a5f5 16-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* Renamed net_device_interface::rx_lock to receive_lock.
* Cleanup, improved comments, removed useless ones.


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


# d68ffded 27-Dec-2008 Axel Dörfler <axeld@pinc-software.de>

* More or less completed the network notification module - it does not remove
old invalid user listeners yet, though (ie. if a team dies).
* Implemented userland network monitor functions.
* Added a few notifications to the network stack, even though this part isn't
complete yet (especially notify_interface_changed()).
* Added optional debug output to the notifications module.
* Added the module to the image, it basically works now (tested).


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


# 27e0dea9 11-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Actually implemented the SO_BINDTODEVICE socket option I added some time ago.
* This makes it possible to select a specific device, even if no interface
has been configured for it yet. To make it work, each interface now has a
private direct route which will be returned if a socket is bound to a device.
* This will be used for example in DHCP to make it work when more than one
adapter is attached.


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


# ea93f584 10-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* put_device_interface() accessed "device" which was already freed to get
the module name, possibly causing a crash when you delete an interface.


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


# 2b07b8e0 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# b0f5179a 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed recursive_lock to use a mutex instead of a semaphore.
* Adjusted code using recursive locks respectively. The initialization
cannot fail anymore, and it is possible to use recursive locks in the
early boot process (even uninitialized, if in BSS), which simplifies
things a little.


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


# df50f7a9 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way the socket functions work:
- The net_stack driver is no longer used. Instead we have a kernel
module which is directly used by syscall implementations in the
kernel. I.e. we no longer tunnel those functions through ioctls, but
have normal syscalls.
- Removed the superfluous net starter module.
- Implemented the FDTYPE_SOCKET type file_descriptors, that is sockets
are no longer vnode based.
- Adjusted libnetwork (the socket function implementations)
accordingly.
- Adjusted netstat accordingly.
* Socket module:
- Implemented socketpair().
- Added "kernel" parameter to the control hook. Quite a few more hooks
would actually need the parameter, but I didn't change those yet,
since that would probably also require changes to the protocol
module interface.


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


# 0d8939ae 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

There is absolutely no need that the interface packet consumer runs at a
priority that high.


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


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

net_device_interface: remove redundant fields


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


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

loop: no longer requires a reader thread, it delivers directly to the device's receive queue


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21215 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


# 8a819b17 19-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

retrieve the incoming interface on the domain_receive_adapter(). This should fix potential issues with packets addressed to the IP broadcast address, such as in with some DHCP implementations.


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


# 9261b129 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

packet capture sockets are now properly notified when the device is going down.

- modified LinkProtocol::ReadData() a bit so it can safely react to external changes such as the device being monitored going down.
- fixed an issue in invalidate_routes() where in some cases the default route was being kept.
- fixed another issue related with the fifo implementation, the notifier semaphore was being created with count of 1, instead of 0.


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


# 64734690 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

whenever an interface is deleted, call put_domain_datalink_protocols() so all readers are unregistered.

- Unfortunely this requires RX lock to become a recursive lock.


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


# 89de6664 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

notify all monitors when a device is being removed.


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


# e53357d5 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

Prepared net_device_monitor to accept device removal events.

- Introduced public net_device_monitor.
- Changed the link protocol to maintain a lock per instance instead of inside the FIFO. Now all of the link instance data is protected.
- Adapted the link protocol to use net_device_monitor.
- Introduced a private Fifo class which doesn't maintain it's own lock.
- Maybe we should add something like a public net_protocol_implementation which maintains a fifo and a benaphore? With the fifo using the structure's lock instead of maintaining it's own.


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


# ae074c5d 07-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved IFF_LINK handling to the device module (ethernet in this case). Now domain interfaces only keep specific flags such as IFF_UP and the configuration flags. IFF_LINK, IFF_BROADCAST etc are maintained exclusively by the device.


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


# fb300cfd 07-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced net_device_interface level locking.


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


# 20b534cd 06-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

a bit more work towards proper locking including a fix to a refcount bug

- fixed a issue in add_interface_to_domain where the device interface's refcount was always incremented since that function was getting the device interface handle and not returning it unconditionlly
- if the ethernet device goes down, and the fd is close()ed, return B_FILE_ERROR instead of calling into the driver again


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


# c64fecca 06-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

started some work to properly handle device_removed() and setting interfaces down in general.

- remove all routes that use interfaces going down.
- when a device is going down, remove associated domain interfaces.
- interfaces weren't getting a properly referenced device interface, fixed.
- down call down_device_interface when deleting a interface, instead set it down and let the upcounts do its job.


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


# 9206bb37 04-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* Changed ETHER_GET_LINK_STATE ethernet driver interface, added ETHER_SET_LINK_STATE_SEM.
* The device interface list now uses class DoublyLinkedList instead of struct list.
* Implemented SIOC[SG]IFMEDIA for setting (not supported by any device yet), and
retrieving the device media information.
* Fixed a locking bug in list_domain_interfaces().
* Added new stack function device_link_changed() that should be called in case the
link state (media) changed.
* The ethernet device module now spawns a thread and will periodically check the media
state of all ethernet devices that support this (if any).
* Minor cleanup.


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


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

use UserBuffer in list_{device,domain}_interfaces


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


# 9c4477d3 01-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

SIOCGIFCONF will now also report the size of the written buffer in ifconf.ifc_len
to cover the case the list of interfaces changed since SIOCGIFCOUNT was called.
Patch by Hugo Santos.


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


# 1a38ebd2 20-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

No longer crashes when deleting "certain" interfaces (couldn't reproduce the
crash in Qemu for some reason).


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


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

When removing an interface, we must make sure it's not still up (ie. we need to
bring it down in that case). This fixes the problem that you couldn't bring an
ethernet interface up again, after you deleted it once.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19524 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


# 7ed2a4437610d5a342d3d2a9950311cbc5e89a9e 24-Aug-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fix naming


# ff8c8dfc1754572d9185e04721c86b2ec701e068 12-Aug-2015 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Improve patch in ticket #9377
Instead of locking the interface lock, set it busy and then unlock the
interface list lock.


# 2d6b0e967b8641a9ebbb73035f430dca6954c28b 16-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

Revert "Missing NULL check in network stack."

This reverts commit dd0ea64b5607e6310c582f62c4275dab7510c4f6.


# dd0ea64b5607e6310c582f62c4275dab7510c4f6 14-Jun-2015 Adrien Destugues <pulkomandy@gmail.com>

Missing NULL check in network stack.

This would trigger a KDL, it's better to just fail the syscall call.


# 8cf4ba89b647baa3f243c132c0b210f8312d8cc9 06-Feb-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Add a TODO comment


# 8a6337d0f894976df77421ac6f98df8a76bff1d5 04-Feb-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Converted the "net_interfaces" mutex into a recursive locker, and
acquire it in Interface::SetDown().


# 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.


# 3f2a0963f6fcc54e247e5254aeb9c7693fc4c7ab 22-Feb-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

All debugger commands we've added, remove we must.
Closes #7251.


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


# 5ebd9548718dabeaff19b0641d8017e913b92fc4 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* Fixed ignoring the netmask when computing the broadcast. Renamed a few
variables to make the function a bit clearer, hopefully.
* Fixed the wrong order of releasing the reference, and removing the object
from the hash table -- thanks Rene!
* Added a bit of documentation to InterfaceAddress::Prepare().


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


# b0766602db4993cd9747711af9f67a83e288af3f 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* RemoveAddresses() needs to remove the addresses from the hash table as well.
This fixes random memory access on interface removal.
* Optimized IndexOfAddress() for NULL addresses.


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


# 4ae58630381888d7a2d632b796bda54998a6376a 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* Allow duplicates in the sAddressTable hash table; while it makes no sense to
have duplicates there, it should certainly not panic.
* Do not add unspecified addresses to the hash table.
* The result of adding the initial address of an interface was ignored; now, the
interface is correctly destructed, if necessary.


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


# e78fea43f50d8a07bbce1d406401c9a66e69afc2 10-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Added a bit more debug output.


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


# ec4fb0f4f0dc7bdafc43dcee0d011b7614eab0d3 01-Oct-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug in get_interface() that would return the first interface
without acquiring a reference to it, and thus led to bug #6565.
* Added a commented out function that dumps all current reference counts.


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


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

* Initialized the domain_datalink's first_{protocol|info} members. This fixes
the crashing bug reported by Atis when trying to add an interface which fails
(the bug causing this has already been fixed with the previous commit).


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


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

* Added ability to be able to dump a net_interface by name.


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


# 8dcde8b12874429cc7f0f21fdb1d9339b6574cc7 13-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* B_SOCKET_SET_ALIAS handling was leaking references.


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


# 095f97a6b6437675e53a2bcedc74a14aae9bf31b 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed memory leaks pointed out by Stephan, thanks!
* Automatic whitespace cleanup.


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


# 2c12b8a3344347fbd5ee7df7cccbad20650a546f 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Also report the address index back to the userland.


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


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

* Also create a new address for B_SOCKET_SET_ALIAS if the index is -1 - this
now has an almost equivalent logic to the old setters like SIOCSIFADDR.


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


# 910ffb32fee4d6e04cd47f915a0e4e5292e05e0e 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* If the network mask, and broadcast are not specified with a B_SOCKET_SET_ALIAS
they will no longer be unset - instead they are set with defaults.
* If B_SOCKET_SET_ALIAS gets an index of -1, it will now try to find the local
address, and if that fails, will just use the first address there is.


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


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

* datalink_control() also need to accept structures smaller than ifreq as long
as the interface name can be specified.


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


# 1ebd87f4e794c94e05ddd045e09e1014d42b333d 10-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* As Atis pointed out, the SIOCSIFNETMASK here didn't make any sense, must have
been a copy&paste error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38001 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


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

* Made the work-around that Atis added to ifconfig and the net_server
in order to be able to use SIOCSIFADDR (and friends) on a net yet added
family superfluous; we now add a new address when needed on the fly.


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


# 1f9c8c4576524824cf035824a9cac69ac8371aee 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed the _SIZEOF_ADDR_IFREQ() macro such that it can be used how we are
using it - hopefully, that is actually correct (it's adopted from FreeBSD).
* Fixed bug that cut off the sockaddr_dl reported by the system, so that DHCP
wouldn't work anymore (and ifconfig wouldn't show the actual MAC address
anymore).
* Changed the listing code to actually pad to ifreq size, and leave the length
of the sockaddr untouched.


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


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

* Interface::_ChangeAddress() got the address check for equality wrong,
effectively rejecting any try to set an address.
* It now copies the new address as well in order to make sure that its
sa_len field is set correctly.
* Improved debug output.


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


# 6b1e148824d6b64230d6b41868a890c1a86ef3e3 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Only actually call change_address() of the net_datalink_protocols if the
address actually changed.


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


# 715fed4479b4711a1c0e44b5f1411509ce34f725 05-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Make sure the SIOCGIFCONF never returns an address with an address length
smaller than sizeof(sockaddr). This fixes a compatibility issue with other
platforms - portable software often assumes that the amount of bytes to
add to an ifreq structure is the larger amount between sizeof(ifreq), and
basically what the _SIZEOF_ADDR_IFREQ() macro returns, instead of always
relying on that macro.
* Renamed UserBuffer::Copy() to Push, ConsumedAmount() to BytesConsumed(),
added Pad() method.


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


# 7aa2819c12dc59c791f84ea19839528cf10bb9f2 03-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Enabled removing the interface on device removal again.
* Made the return type of remove_interface() void, as it cannot fail.


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


# 2b1c0755dd452db665050fdbbe06549e7e8c9c38 03-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Renamed the proprietary SIOC_* ioctls to B_SOCKET_* - no reason to pollute
global name space, and have ugly identifiers for nothing :-)
* Added a flags field to struct ifaliasreq. Added flags to mark an alias that
is currently being configured, or has been automatically configured.
Those flags aren't used yet, but they will replace IFF_CONFIGURING and
friends.
* Implemented deleting addresses only from interfaces via ifconfig.
* Added more command aliases for delete to ifconfig ("del", and "delete", for
more consistency with route).
* Fixed control_routes() to only release a reference to an address if it
actually got one before.
* If an interface address is deleted, its routes are now removed as well.
* InterfaceAddress now holds a reference to its interface as planned.
* Implemented removing interfaces. Works quite nicely.
* When downing an interface, all of its routes are now removed. When upping
it again, at least the default routes are added.
* datalink.cpp's get_interface_name_or_index() leaked a reference to the
interface found.
* SIOCAIFADDR would also leak a reference when new addresses were added.


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


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

* Work in progress of extending the AF_LINK protocol to be able to send and
receive raw packets (only without the ethernet framing).


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


# 9d771afb3903b3d3d205cfa108eaebb14d89f7fb 29-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Added Haiku specific socket ioctls to configure the interface aliases:
SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_REMOVE, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET,
and SIOC_IF_ALIAS_COUNT.
* Implemented all of those new ioctls, though they are yet untested.
* Added ifreq::ifr_data, and removed the hack in the FreeBSD compat if.h
header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37806 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


# 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


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

* Locking order dictates that this lock is an inner lock, and shouldn't
be used everywhere.
* This also fixes a panic when deleting interfaces (an already deleted
lock was unlocked).


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


# 26153d0f67e36b509dade3b8aed43ba7b753578b 03-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* The net_domain's lock is now a recursive lock.
* Fixed all route locking problems, of which there were numerous
({add|remove}_route(), and list_routes() did not lock at all). Added
lock assertions in functions that don't do the locking themselves.
* A route will now be removed from the list in remove_route(), not in
put_route_internal(). Before, a route could easily be removed twice, causing
remove_route() to release references it did not own. This fixes bug #2706.


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


# 3c13a5f5b39d02367da1ef1d6bb3740ccb2340a1 16-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* Renamed net_device_interface::rx_lock to receive_lock.
* Cleanup, improved comments, removed useless ones.


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


# d68ffdedc04d63f83d407b194a54de3095cacc06 27-Dec-2008 Axel Dörfler <axeld@pinc-software.de>

* More or less completed the network notification module - it does not remove
old invalid user listeners yet, though (ie. if a team dies).
* Implemented userland network monitor functions.
* Added a few notifications to the network stack, even though this part isn't
complete yet (especially notify_interface_changed()).
* Added optional debug output to the notifications module.
* Added the module to the image, it basically works now (tested).


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


# 27e0dea9f0bbc7db87e04d09fa707f8790575918 11-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Actually implemented the SO_BINDTODEVICE socket option I added some time ago.
* This makes it possible to select a specific device, even if no interface
has been configured for it yet. To make it work, each interface now has a
private direct route which will be returned if a socket is bound to a device.
* This will be used for example in DHCP to make it work when more than one
adapter is attached.


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


# ea93f584ad64b3bc9effa318a882dac27e1c935a 10-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* put_device_interface() accessed "device" which was already freed to get
the module name, possibly causing a crash when you delete an interface.


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


# 2b07b8e0f1a7f1e76f31db24a21a42cbb01d7b9c 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# b0f5179aa51eb680cdeea656a8b11fdbc6b56d63 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed recursive_lock to use a mutex instead of a semaphore.
* Adjusted code using recursive locks respectively. The initialization
cannot fail anymore, and it is possible to use recursive locks in the
early boot process (even uninitialized, if in BSS), which simplifies
things a little.


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


# df50f7a9b4b0bbe77413d722875b0a346c61d527 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way the socket functions work:
- The net_stack driver is no longer used. Instead we have a kernel
module which is directly used by syscall implementations in the
kernel. I.e. we no longer tunnel those functions through ioctls, but
have normal syscalls.
- Removed the superfluous net starter module.
- Implemented the FDTYPE_SOCKET type file_descriptors, that is sockets
are no longer vnode based.
- Adjusted libnetwork (the socket function implementations)
accordingly.
- Adjusted netstat accordingly.
* Socket module:
- Implemented socketpair().
- Added "kernel" parameter to the control hook. Quite a few more hooks
would actually need the parameter, but I didn't change those yet,
since that would probably also require changes to the protocol
module interface.


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


# 0d8939aea7e4907395d67f5ddfea85b2d19571c3 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

There is absolutely no need that the interface packet consumer runs at a
priority that high.


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


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

net_device_interface: remove redundant fields


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


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

loop: no longer requires a reader thread, it delivers directly to the device's receive queue


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21215 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


# 8a819b17e4ebb40461954432b6b8cfb29946b32f 19-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

retrieve the incoming interface on the domain_receive_adapter(). This should fix potential issues with packets addressed to the IP broadcast address, such as in with some DHCP implementations.


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


# 9261b129886d285ddb488b27b608efb25c733e88 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

packet capture sockets are now properly notified when the device is going down.

- modified LinkProtocol::ReadData() a bit so it can safely react to external changes such as the device being monitored going down.
- fixed an issue in invalidate_routes() where in some cases the default route was being kept.
- fixed another issue related with the fifo implementation, the notifier semaphore was being created with count of 1, instead of 0.


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


# 6473469039f43c38a2cdfec2aeea2989582a3557 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

whenever an interface is deleted, call put_domain_datalink_protocols() so all readers are unregistered.

- Unfortunely this requires RX lock to become a recursive lock.


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


# 89de666412687a315f4d5228da8d09dbadde2c54 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

notify all monitors when a device is being removed.


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


# e53357d57adc145e4c36a3dc35cecde8bea07297 08-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

Prepared net_device_monitor to accept device removal events.

- Introduced public net_device_monitor.
- Changed the link protocol to maintain a lock per instance instead of inside the FIFO. Now all of the link instance data is protected.
- Adapted the link protocol to use net_device_monitor.
- Introduced a private Fifo class which doesn't maintain it's own lock.
- Maybe we should add something like a public net_protocol_implementation which maintains a fifo and a benaphore? With the fifo using the structure's lock instead of maintaining it's own.


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


# ae074c5d153df2435d7ee61df2d104827c48f384 07-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved IFF_LINK handling to the device module (ethernet in this case). Now domain interfaces only keep specific flags such as IFF_UP and the configuration flags. IFF_LINK, IFF_BROADCAST etc are maintained exclusively by the device.


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


# fb300cfd25fe641020485e7b21a0be2580b6479d 07-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced net_device_interface level locking.


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


# 20b534cd5f128d0561161aa0243bd1102378ab65 06-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

a bit more work towards proper locking including a fix to a refcount bug

- fixed a issue in add_interface_to_domain where the device interface's refcount was always incremented since that function was getting the device interface handle and not returning it unconditionlly
- if the ethernet device goes down, and the fd is close()ed, return B_FILE_ERROR instead of calling into the driver again


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


# c64fecca780b8dcf6ce2cb5994977a79e14ce936 06-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

started some work to properly handle device_removed() and setting interfaces down in general.

- remove all routes that use interfaces going down.
- when a device is going down, remove associated domain interfaces.
- interfaces weren't getting a properly referenced device interface, fixed.
- down call down_device_interface when deleting a interface, instead set it down and let the upcounts do its job.


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


# 9206bb37797df1a6448d3f1c336e954b4ddb790d 04-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* Changed ETHER_GET_LINK_STATE ethernet driver interface, added ETHER_SET_LINK_STATE_SEM.
* The device interface list now uses class DoublyLinkedList instead of struct list.
* Implemented SIOC[SG]IFMEDIA for setting (not supported by any device yet), and
retrieving the device media information.
* Fixed a locking bug in list_domain_interfaces().
* Added new stack function device_link_changed() that should be called in case the
link state (media) changed.
* The ethernet device module now spawns a thread and will periodically check the media
state of all ethernet devices that support this (if any).
* Minor cleanup.


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


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

use UserBuffer in list_{device,domain}_interfaces


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


# 9c4477d3bf7ba915564c31106c177cde3998ed26 01-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

SIOCGIFCONF will now also report the size of the written buffer in ifconf.ifc_len
to cover the case the list of interfaces changed since SIOCGIFCOUNT was called.
Patch by Hugo Santos.


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


# 1a38ebd28bd67aec8a7ba0cda2aac0db8c840761 20-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

No longer crashes when deleting "certain" interfaces (couldn't reproduce the
crash in Qemu for some reason).


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


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

When removing an interface, we must make sure it's not still up (ie. we need to
bring it down in that case). This fixes the problem that you couldn't bring an
ethernet interface up again, after you deleted it once.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19524 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