History log of /haiku/src/add-ons/kernel/network/stack/datalink.cpp
Revision Date Author Comments
# 98166ebe 15-Feb-2024 Augustin Cavalier <waddlesplash@gmail.com>

network: Do not apply ethernet headers for loopback devices.

This reverts large portions of e2b57695fc3ec43cad099ab3dd93bdd99e052761
and all of 4e9653027d9094f4d57fd294d46ce6eb461b697f, and adjusts
the "tunnel" and "loopback_frame" handlers appropriately.

Initially, this logic was added so that libpcap continued working;
however, it seems that we can change some of the Haiku-specific code
in libpcap and have it continue to operate without requiring such
ethernet headers to be appended.

Fixes #18801.

Change-Id: Ie06908affde894ad1516fbc27e06298309a4e082
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7403
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 819c5108 28-Dec-2023 Augustin Cavalier <waddlesplash@gmail.com>

network: Update device statistics (mostly) in the stack.

We bypass device logic in datalink_send_routed_data() in the case
of RTF_LOCAL, so if we don't update the stats there, they'll never
get updated. Furthermore, there's places packets can be dropped
inside the device reader thread. So, we might as well consolidate
the stats-updating logic and get it out of drivers.

(The only remaining case where drivers need to update stats is when
they drop a packet in receive(), as the stack can't tell when an error
from receive() is due to a dropped packet or not.)

Fixes a potential leak on packet drops in the device reader thread,
and fixes loopback statistics for TCP/UDP/etc.


# 4e965302 18-May-2023 Jérôme Duval <jerome.duval@gmail.com>

net_stack: for local delivery, also capture packets when enabled

the packet capture expects frames: prepend an ethernet header for the capture.

Change-Id: I3d09da2a5a6924a545cc4fbc9dd1577bd3248226
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6452
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e2b57695 18-May-2023 Jérôme Duval <jerome.duval@gmail.com>

loopback_frame: apply an ethernet header for packet capture

* the packet capture expects frames, so loopback_frame should actually apply framing and deframing
for loopback packets.
* datalink: set the address for host routes
* device_interfaces: call the deframing if any in device_enqueue_buffer()
tested with ping 127.0.0.1 and ping6 ::1, while removing the local flag on both routes.

Change-Id: I2085735bdac3bb85908189a2e1acb2540818c7bd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6451
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 44fa45df 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

net/if: Drop ifmediareq and just use the regular ifreq for SIOCGIFMEDIA.

This was introduced into the main API in 2010 (d72ede75fb252c24c8a5fcc39395f9ae1c202322),
but was actually only fully used for the past month (c2a9a890f3ac7795602d11c0edaa20ac2db48202)
when SIOCGIFMEDIA was supported for all *BSD drivers and not just WiFi.
Most userland consumers of this structure did not use it correctly,
as was the case in #17770, and only worked because in the fallback case
the network stack just treated it as if it were an ifreq.

Nothing actually used the ifm_count/ifm_ulist (though tentative APIs
were exposed for it) as noted by previous commits; and the fact that
Haiku's IFM_* declarations are so spartan makes most of the returned
values unintelligible to userland without using FreeBSD compat headers.

If, in the future, we decide to implement ifmedia listing and selection
properly, that should likely be done with separate ioctls instead of
having multi-function ones like this.

This is technically an ABI break, but in practice it should not matter:
ifmediareq::ifm_current aligns with ifreq::ifr_media, so the things
that used this structure like our in-tree code did will continue to work.
Until this past May, the only other field that was usually set was
ifm_active, but in the absence of setting ifm_status all non-Haiku
consumers should ignore it completely.

The only consumer of this ioctl that I know of out of the tree,
wpa_supplicant, still works after these changes.


# 83ac9b72 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

network/stack: Do not invoke SIOCGIFMEDIA but just return the already-fetched media.

This functionally disables most of the functionality of the BSD-style
SIOCGIFMEDIA, but it was never used in userland (because if it had,
it would have triggered SMAP violations in the compatibility layer.)

SIOCGIFMEDIA returns BSD-style media values, which mostly overlap
with Haiku ones but have a few differences still. These are taken care
of in the compat layer by ETHER_GET_LINK_STATE, which is where this
media value comes from, but are not by SIOCGIFMEDIA which just passes
back whatever the drivers do.

Fixes #17770, at least for ethernet drivers.


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


# 071d7d3e 28-Oct-2020 Jérôme Duval <jerome.duval@gmail.com>

network/stack: assume zero length ioctl requests are valid

posix ioctl calls don't provide a request length. Theorically these length checks
could be removed altogether.

Change-Id: Ie53f10dc8d050dd3bdf2e5a792ed79f139a24d29
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3364
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


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

* Only return the first address of the family if there was no address specified
in the request.


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


# b756a582 07-Dec-2010 Axel Dörfler <axeld@pinc-software.de>

* Getting the device media now actually works as intended.


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


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

* We now use a FreeBSD compatible ifmediareq structure for SIOCIFMEDIA, and
SIOCSIFMEDIA.
* Made sure that the two media ioctls are actually forwarded to the driver.
* Added NetworkDevice.cpp to the build.


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


# 89bf19cc 27-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Made an uint32 out of net_socket::bound_to_device.


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


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

* Getting an address leaked a reference. This fixes that interfaces could not
really be deleted (a reference of them was kept in memory).


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


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

* Spotted a few reference counting bugs that were probably responsible for
#6446, although I could not reproduce the exact problem.
* net_datalink::is_local_[link_]address() now releases a previous reference if
the _interfaceAddress arguments does not point to NULL.
* When a buffer is received from a device, it's interface_address should be NULL
already.


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


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

* Applied the B_SOCKET_SET_ALIAS address retrieval logic to B_SOCKET_GET_ALIAS
as well (of course, no address is created automatically here).


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


# 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


# 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


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

* Renamed net_datalink_module::send_data() to send_routed_data(), and
send_datagram() to send_data().
* Renamed DatagramSocket::SocketEnqueue() to EnqueueClone(), SocketDequeue()
to Dequeue().
* Ordered the methods in ProtocolUtilities.h according to their declaration.


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


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

* Added a dedicated lock for the device monitors. This fixes a locking issue in
interface_protocol_send_data() which accessed the monitors unlocked.
* Changed SIOCCPACKETCAP to check if the device name matches the one used with
SIOCSPACKETCAP.


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


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

* Made datalink and interface protocol module functions static.
* Got rid of datalink.h.
* Only allow sending/receiving of packets through AF_LINK for root (not that
sending would be implemented yet).


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


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

* Added new socket ioctls to strace, and the datalink debug output.
* Added a few more types to strace's network ioctls.


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


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

* Applied next work in progress patch by Atis that takes into account most of
my comments so far. Thanks!


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


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

* Made the stack send out interface change notifications where needed (at least
hopefully :-)).
* Improved interface change notification to include the flags that changed.


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


# 751ce9e2 03-Dec-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed the interface fallback from the datalink module's is_local_address().
* Instead, added a new function is_local_link_address() which returns the
interface with the matching link level address, and can additionally test
for unconfigured interfaces.
* Merged the two versions of fill_sockaddr_in() together in ipv4.cpp.
* ipv4 now uses the new is_local_link_address() function to figure out whether
the received packet should be processed or not. This should fix a few DHCP
issues with multiple and configured interfaces as recently explained on the
mailing list.


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


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

* Cleanup.


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


# 60dc5f61 12-Oct-2008 Oliver Tappe <zooey@hirschkaefer.de>

* fixed receiving of IP-level broadcasts - fixing the rest of
#2065

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


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

* datalink_send_datagram() can be called with a NULL protocol which I missed
with the last commit.


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


# 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


# b5a5aebc 28-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a set_to_defaults() function to the address module: it can be used
to retrieve the default settings for the netmask/broadcast depending on the
specified address/netmask.
* interface_protocol_control() now uses this to reset the broadcast/netmask
to their default values on SIOCSIFADDR resp. the former only on
SIOCSIFNETMASK.
* This fixes bug #1861.


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


# 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


# 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


# 8c40c83f 04-May-2007 Axel Dörfler <axeld@pinc-software.de>

Renamed net_device::{add|rem}_multi() to {add|remove}_multicast for consistency and clarity.


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


# 95403830 30-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added add_multi/rem_multi to net_devices. Glued the interface protocol multicast handling with net_device via add_multi/rem_multi.


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


# 8aa4c7e3 01-May-2007 Hugo Santos <hugosantos@nowhere.fake>

prepared the ipv4 multicast code for full multicast support.


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


# 1a41adbc 01-May-2007 Hugo Santos <hugosantos@nowhere.fake>

added join_multicast/leave_multicast to datalink protocols, preparing for full multicast support.


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


# 1408d1f0 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced datalink's send_datagram to perform route and source address selection and dispatch the datagram to appropriate domain/protocol.


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


# 6c501a40 14-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support RFC 3678's Protocol-Independent setsockopt()s for IPv4 multicast.


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


# 46527f68 14-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

initial steps towards IPv4 Multicast Filter Delta API (RFC 3678)


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


# 6c353509 11-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved address selection logic to a new 'get_buffer_route'.

- IPv4 now assumes the addresses it is supplied in send_routed_data are already the appropriate ones.
- made the Data(), operator* and operator-> methods in NetBufferFieldReader const so we can use them in the same expression as the constructor.
- fixed an issue with UDP where the wrong source address could be used in the calculating the checksum.
- changed ipv4_print_address to use the more common 0.0.0.0 format.


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


# 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


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

updated some locking related comments.


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


# f03d1212 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

handle all cases of SIOCSIFFLAGS in the same place


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


# ca2aa963 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

don't overwrite the flags we set when the interface goes up or down, instead just update the flags in the same place.


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


# 2d55afcd 31-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

Support getting route information for a specific destination
using SIOCGETRT. Patch by Hugo Santos.


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


# de8a7c26 08-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Introduced a reader_thread member to the private net_device_interface.
* When shutting down an interface, we now wait until its reader thread is gone, too;
this is necessary in case the kernel unloads the networking stack before the reader
thread had a chance to exit.
* Added some debug output to net_socket in case you ask for unknown options.


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


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

Calmed down the networking stack a lot - since it basically works, there is no
reason to slow it down with debug output that much; this will also help investigating
some issues where you just aren't interested in most of the output.


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


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

We also need to put the outgoing packets into the device monitor.


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


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

* ARP no longer tries to resolve the target address in case of a link-level broadcast
(indicated by MSG_BCAST).
* ARP should now be able to resolve addresses with an unconfigured interface as well.
* datalink_is_local_address() now uses interfaces without an address as a fallback
in case no more specific interface could be found.


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


# 26cbcedb 06-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


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


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

* Only return the first address of the family if there was no address specified
in the request.


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


# b756a58254a25f542e24eeefc775a25a74417e7b 07-Dec-2010 Axel Dörfler <axeld@pinc-software.de>

* Getting the device media now actually works as intended.


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


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

* We now use a FreeBSD compatible ifmediareq structure for SIOCIFMEDIA, and
SIOCSIFMEDIA.
* Made sure that the two media ioctls are actually forwarded to the driver.
* Added NetworkDevice.cpp to the build.


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


# 89bf19ccde93f9bcf3f965abdcdcac26f519d9b9 27-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Made an uint32 out of net_socket::bound_to_device.


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


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

* Getting an address leaked a reference. This fixes that interfaces could not
really be deleted (a reference of them was kept in memory).


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


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

* Spotted a few reference counting bugs that were probably responsible for
#6446, although I could not reproduce the exact problem.
* net_datalink::is_local_[link_]address() now releases a previous reference if
the _interfaceAddress arguments does not point to NULL.
* When a buffer is received from a device, it's interface_address should be NULL
already.


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


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

* Applied the B_SOCKET_SET_ALIAS address retrieval logic to B_SOCKET_GET_ALIAS
as well (of course, no address is created automatically here).


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


# 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


# 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


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

* Renamed net_datalink_module::send_data() to send_routed_data(), and
send_datagram() to send_data().
* Renamed DatagramSocket::SocketEnqueue() to EnqueueClone(), SocketDequeue()
to Dequeue().
* Ordered the methods in ProtocolUtilities.h according to their declaration.


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


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

* Added a dedicated lock for the device monitors. This fixes a locking issue in
interface_protocol_send_data() which accessed the monitors unlocked.
* Changed SIOCCPACKETCAP to check if the device name matches the one used with
SIOCSPACKETCAP.


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


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

* Made datalink and interface protocol module functions static.
* Got rid of datalink.h.
* Only allow sending/receiving of packets through AF_LINK for root (not that
sending would be implemented yet).


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


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

* Added new socket ioctls to strace, and the datalink debug output.
* Added a few more types to strace's network ioctls.


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


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

* Applied next work in progress patch by Atis that takes into account most of
my comments so far. Thanks!


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


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

* Made the stack send out interface change notifications where needed (at least
hopefully :-)).
* Improved interface change notification to include the flags that changed.


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


# 751ce9e228a278970a492fead1ecedbfab453d2c 03-Dec-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed the interface fallback from the datalink module's is_local_address().
* Instead, added a new function is_local_link_address() which returns the
interface with the matching link level address, and can additionally test
for unconfigured interfaces.
* Merged the two versions of fill_sockaddr_in() together in ipv4.cpp.
* ipv4 now uses the new is_local_link_address() function to figure out whether
the received packet should be processed or not. This should fix a few DHCP
issues with multiple and configured interfaces as recently explained on the
mailing list.


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


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

* Cleanup.


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


# 60dc5f61094f087256cd30e51d84b6c213959b65 12-Oct-2008 Oliver Tappe <zooey@hirschkaefer.de>

* fixed receiving of IP-level broadcasts - fixing the rest of
#2065

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


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

* datalink_send_datagram() can be called with a NULL protocol which I missed
with the last commit.


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


# 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


# b5a5aebc909a141cd5baf1f1a44c72724dd3204e 28-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a set_to_defaults() function to the address module: it can be used
to retrieve the default settings for the netmask/broadcast depending on the
specified address/netmask.
* interface_protocol_control() now uses this to reset the broadcast/netmask
to their default values on SIOCSIFADDR resp. the former only on
SIOCSIFNETMASK.
* This fixes bug #1861.


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


# 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


# 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


# 8c40c83fa1119fb98fc828613f576fe4bb3f73d7 04-May-2007 Axel Dörfler <axeld@pinc-software.de>

Renamed net_device::{add|rem}_multi() to {add|remove}_multicast for consistency and clarity.


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


# 954038303d18f37b13632cf69949ab2f4ea7506a 30-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added add_multi/rem_multi to net_devices. Glued the interface protocol multicast handling with net_device via add_multi/rem_multi.


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


# 8aa4c7e3701d51a64961dd68d2ff74ee4d3374b2 01-May-2007 Hugo Santos <hugosantos@nowhere.fake>

prepared the ipv4 multicast code for full multicast support.


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


# 1a41adbcd2b383e885aedc6e7d76fe12ab818633 01-May-2007 Hugo Santos <hugosantos@nowhere.fake>

added join_multicast/leave_multicast to datalink protocols, preparing for full multicast support.


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


# 1408d1f0ce8555b9b94037e6f1c9c530afe753b6 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced datalink's send_datagram to perform route and source address selection and dispatch the datagram to appropriate domain/protocol.


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


# 6c501a4085f9f397f2865e80df1242404c8f7066 14-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support RFC 3678's Protocol-Independent setsockopt()s for IPv4 multicast.


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


# 46527f6806b3d52282de36566581fd567d839839 14-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

initial steps towards IPv4 Multicast Filter Delta API (RFC 3678)


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


# 6c35350908905903b5c150154b0da9698ca8943a 11-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

moved address selection logic to a new 'get_buffer_route'.

- IPv4 now assumes the addresses it is supplied in send_routed_data are already the appropriate ones.
- made the Data(), operator* and operator-> methods in NetBufferFieldReader const so we can use them in the same expression as the constructor.
- fixed an issue with UDP where the wrong source address could be used in the calculating the checksum.
- changed ipv4_print_address to use the more common 0.0.0.0 format.


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


# 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


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

updated some locking related comments.


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


# f03d12124193de0041ec0e27edd36a30c92721e6 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

handle all cases of SIOCSIFFLAGS in the same place


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


# ca2aa96377bfa3351a2ffc18981ab843ea1421f9 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

don't overwrite the flags we set when the interface goes up or down, instead just update the flags in the same place.


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


# 2d55afcdf7379a36f3eb63515ef347139949565d 31-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

Support getting route information for a specific destination
using SIOCGETRT. Patch by Hugo Santos.


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


# de8a7c2680a0c9a7bf106f376fb9e5bc0935604e 08-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Introduced a reader_thread member to the private net_device_interface.
* When shutting down an interface, we now wait until its reader thread is gone, too;
this is necessary in case the kernel unloads the networking stack before the reader
thread had a chance to exit.
* Added some debug output to net_socket in case you ask for unknown options.


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


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

Calmed down the networking stack a lot - since it basically works, there is no
reason to slow it down with debug output that much; this will also help investigating
some issues where you just aren't interested in most of the output.


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


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

We also need to put the outgoing packets into the device monitor.


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


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

* ARP no longer tries to resolve the target address in case of a link-level broadcast
(indicated by MSG_BCAST).
* ARP should now be able to resolve addresses with an unconfigured interface as well.
* datalink_is_local_address() now uses interfaces without an address as a fallback
in case no more specific interface could be found.


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


# 26cbcedb9c3094526f3e4551027a23785c618daf 06-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


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