History log of /haiku/src/add-ons/kernel/network/datalink_protocols/loopback_frame/loopback_frame.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>


# 71522c93 18-Nov-2023 François Revol <revol@free.fr>

net: Rename IFT_TUN to IFT_TUNNEL as on BSD

We already use their value, let's use the name too.

Change-Id: I5afbd69923ae3b5e702dfb935a709c3069de5365
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7146
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: François Revol <revol@free.fr>


# b6c24e6b 24-Nov-2023 Augustin Cavalier <waddlesplash@gmail.com>

network: Overhaul TUN/TAP subsystem.

* Rename the "tun" network device to "tunnel". FreeBSD calls theirs
"tuntap" but speaks of both TUN and TAP devices as interfaces for
tunnels. The other BSDs seem to do likewise.

* Fold the "tun" driver into the "tunnel" network device. The
network device now publishes entries in devfs when interfaces
are created, and unpublishes them when interfaces are destroyed.

This removes the need for the driver and device to communicate
through a file descriptor, and thus allows the receive queue
to be totally eliminated, massively simplifying that logic.

* Use standard net-stack FIFOs instead of TCP BufferQueue, which is
specialized to TCP's needs in far too many ways. Thanks to the
previous commit adding support for interrupting semaphore waits,
we can use the FIFO wait mechanisms, too.

* Restructure the TAP logic, and generate MAC addresses more like
Linux does.

* Actually set type = IFT_TUN, and use the "loopback" frame handler
instead of the "ethernet" frame handler. This allows significant
cleanup of the header handling logic.

* In TUN mode, reject packets that don't look like IP packets.

* Delete "tunconfig"; it was mostly stubs and is now unnecessary.

TUN mode tested and confirmed as working by kallisti5 with OpenVPN.
TAP mode partially tested, but not yet confirmed as working.

Fixes #18673.

Change-Id: Ibd803139474e8db556a4f567901da15ee4083621
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7143
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 47b66bb6 30-May-2023 Jérôme Duval <jerome.duval@gmail.com>

loopback_frame: when the interface address isn't set, use the destination

fix #18429

Change-Id: Ifd0a15e052bbde9eb3d8875249e03152e6292994
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6482
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>


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

* Removed the call to net_stack_module::register_domain_device_handler(), as
it's not needed for locally received buffers. This fixes a doubled
initialization for a single device when there is more than a single domain
involved. Reported by Atis.
* Fixed missing call to unregister_device_deframer() in case there was not
enough memory to allocate the loopback_frame_protocol object.


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


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

* Introduced a datalink layer (2) independent way of specifying the packet
type one wants to receive. Changed ipv6_datagram to use that (but note that
it currently does not compile).
* Header cleanup.


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


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

call the callbacks with ->next (...)


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


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

* Moved the TCPConnection class into its own file.
* Added some missing result checks, mostly for allocations.
* Fixed a wrong precendence with the ?: operator
* Some minor cleanup.
* Renamed sBufferModule to gBufferModule - the header expects it to be a global,
so it should be named like one.


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


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

Implemented loopback device - currently crashes the kernel pretty fast, though.


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


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

* Removed the call to net_stack_module::register_domain_device_handler(), as
it's not needed for locally received buffers. This fixes a doubled
initialization for a single device when there is more than a single domain
involved. Reported by Atis.
* Fixed missing call to unregister_device_deframer() in case there was not
enough memory to allocate the loopback_frame_protocol object.


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


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

* Introduced a datalink layer (2) independent way of specifying the packet
type one wants to receive. Changed ipv6_datagram to use that (but note that
it currently does not compile).
* Header cleanup.


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


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

call the callbacks with ->next (...)


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


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

* Moved the TCPConnection class into its own file.
* Added some missing result checks, mostly for allocations.
* Fixed a wrong precendence with the ?: operator
* Some minor cleanup.
* Renamed sBufferModule to gBufferModule - the header expects it to be a global,
so it should be named like one.


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


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

Implemented loopback device - currently crashes the kernel pretty fast, though.


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