]> git.meshlink.io Git - meshlink/log
meshlink
3 years agoDebugging for getifaddrs(). debug/getifaddrs
Guus Sliepen [Thu, 28 Jan 2021 21:26:00 +0000 (22:26 +0100)]
Debugging for getifaddrs().

This logs which interfaces and addresses are returned by getifaddrs() that
are usable for MeshLink. It also adds the /scan command to the chat example
to force rescanning the network interfaces.

3 years agoFix a NULL pointer dereference when unable to bind to NETLINK_ROUTE socket.
Guus Sliepen [Thu, 28 Jan 2021 21:23:38 +0000 (22:23 +0100)]
Fix a NULL pointer dereference when unable to bind to NETLINK_ROUTE socket.

3 years agoAdd meshlink_hint_network_change().
Guus Sliepen [Tue, 26 Jan 2021 21:55:21 +0000 (22:55 +0100)]
Add meshlink_hint_network_change().

This is intended to be used when there is no way for MeshLink to get
notifications of local network changes. It forces MeshLink to scan all
network interfaces for changes in up/down status and new/removed addresses,
and will immediately check if all connections to other nodes are still
alive.

3 years agoHandle network change detection on macOS and iOS.
Guus Sliepen [Sun, 18 Oct 2020 20:50:50 +0000 (22:50 +0200)]
Handle network change detection on macOS and iOS.

Apple has no usable PFROUTE sockets anymore, instead network change
detection should be done via SystemConfiguration callbacks. However,
actually parsing the messages is very annoying in C, so we only use it to
get notified of changes, we use getifaddrs() to get the actual list of
network interfaces and addresses.

The only issue is that interface up/down state changes do not result in a
notification, only interface and address addition/removal.

3 years agoImproved mDNS compliance.
Guus Sliepen [Tue, 18 Aug 2020 22:35:31 +0000 (00:35 +0200)]
Improved mDNS compliance.

Split the mDNS packets into separate request and response packets, and only
send responses when we receive a valid request.

It's now possible to find local MeshLink nodes using tools like dns-sd and
avahi-browse, if told to explicitly search for the _appname._tcp service.

3 years agoSet SO_REUSEPORT on the multicast sockets.
Guus Sliepen [Thu, 13 Aug 2020 21:29:06 +0000 (23:29 +0200)]
Set SO_REUSEPORT on the multicast sockets.

On Linux this doesn't make any difference, but on macOS this is required
if any other process has already opened an mDNS multicast socket locally,
otherwise bind() will fail.

3 years agoAdd local discovery support for macOS.
Guus Sliepen [Thu, 13 Aug 2020 20:48:06 +0000 (22:48 +0200)]
Add local discovery support for macOS.

This implements the pfroute counterpart to Linux's netlink interface.
Pfroute doesn't allow easy querying the current interfaces and addresses,
so we use getifaddrs() for that.

3 years agoFix outgoing connection attempts after local discovery.
Guus Sliepen [Mon, 13 Jul 2020 20:31:46 +0000 (22:31 +0200)]
Fix outgoing connection attempts after local discovery.

We were trying the wrong port due to a forgotten byteswap. Also, if no
address was known at all for a node, there might be an outgoing structure
for it that would never be retried.

3 years agoRemove debug messages.
Guus Sliepen [Sun, 12 Jul 2020 21:01:06 +0000 (23:01 +0200)]
Remove debug messages.

3 years agoWhen receiving an mDNS request, send a unicast response back.
Guus Sliepen [Sun, 12 Jul 2020 20:45:37 +0000 (22:45 +0200)]
When receiving an mDNS request, send a unicast response back.

3 years agoGroup discovery related variables together.
Guus Sliepen [Sun, 12 Jul 2020 19:45:10 +0000 (21:45 +0200)]
Group discovery related variables together.

3 years agoResend mDNS packets on all known addresses if meshlink_reset_timers() is called.
Guus Sliepen [Sun, 12 Jul 2020 19:36:53 +0000 (21:36 +0200)]
Resend mDNS packets on all known addresses if meshlink_reset_timers() is called.

3 years agoEnsure we compile discovery.c unconditionally.
Guus Sliepen [Sun, 12 Jul 2020 19:36:12 +0000 (21:36 +0200)]
Ensure we compile discovery.c unconditionally.

3 years agoDon't link with Catta anymore.
Guus Sliepen [Sun, 12 Jul 2020 19:11:32 +0000 (21:11 +0200)]
Don't link with Catta anymore.

3 years agoSend and receive multicast mDNS packets.
Guus Sliepen [Sun, 12 Jul 2020 15:31:40 +0000 (17:31 +0200)]
Send and receive multicast mDNS packets.

We don't actually support the full mDNS spec, we just send something that
passes for a valid mDNS packet, and expect other nodes to send packets back
with exactly the same format. All other mDNS packets will be ignored.

3 years agoKeep track of interfaces and local addresses.
Guus Sliepen [Fri, 10 Jul 2020 20:16:12 +0000 (22:16 +0200)]
Keep track of interfaces and local addresses.

3 years agoParse Netlink NEW/DELLINK and NEW/DELADDR messages.
Guus Sliepen [Sat, 27 Jun 2020 21:19:17 +0000 (23:19 +0200)]
Parse Netlink NEW/DELLINK and NEW/DELADDR messages.

Parse link and address information. Also send GETLINK and GETADDR
messages to the Netlink socket, so we get the current state of the
interfaces and addresses.

3 years agoMonitor a Netlink socket on Linux.
Guus Sliepen [Sat, 27 Jun 2020 17:01:34 +0000 (19:01 +0200)]
Monitor a Netlink socket on Linux.

3 years agoMonitor a PFROUTE socket on *BSD and macOS.
Guus Sliepen [Thu, 18 Jun 2020 20:41:12 +0000 (22:41 +0200)]
Monitor a PFROUTE socket on *BSD and macOS.

Catta is not handling network changes correctly on *BSD and macOS. In
particular, after the initial startup, interfaces that go up and down
do not cause a callback to be generated, so MeshLink is not notified of
the changes.

To ensure MeshLink responds rapidly to network changes on these
platforms, we open a PFROUTE socket and monitor it ourself. We only
check the message type, and don't track exactly what addresses get added
or removed.

3 years agoCheck the return value of catta_simple_poll_get().
Guus Sliepen [Mon, 25 Jan 2021 20:00:47 +0000 (21:00 +0100)]
Check the return value of catta_simple_poll_get().

This ensures we gracefully handle the case of Catta not being able to bind
to the NETLINK_ROUTE socket.

3 years agoUse AI_* instead of NI_* constants for getaddrinfo().
Guus Sliepen [Thu, 14 Jan 2021 21:10:45 +0000 (22:10 +0100)]
Use AI_* instead of NI_* constants for getaddrinfo().

3 years agoSend our canonical address to nodes we want to communicate with.
Guus Sliepen [Wed, 30 Dec 2020 13:55:35 +0000 (14:55 +0100)]
Send our canonical address to nodes we want to communicate with.

This ensures canonical addresses are propagated automatically, and can be
used when making meta and UDP connections.

3 years agoClean up the request jump table.
Guus Sliepen [Wed, 30 Dec 2020 13:53:46 +0000 (14:53 +0100)]
Clean up the request jump table.

Use C99 designated array initializers to ensure the jump table and list of
request names is kept in sync with the enums.

3 years agoUse the canonical address during UDP probes.
Guus Sliepen [Wed, 30 Dec 2020 13:50:56 +0000 (14:50 +0100)]
Use the canonical address during UDP probes.

It is possible that a node has a canonical address, but due to NAT or other
reasons, the meta-connections with that node use other addresses. If UDP is
only possible to the canonical address, then we need to include that during
the initial UDP probing phase.

3 years agoAdd missing calls to init_sync_flag() in test cases.
Guus Sliepen [Sun, 6 Dec 2020 15:18:18 +0000 (16:18 +0100)]
Add missing calls to init_sync_flag() in test cases.

3 years agoFix deleting configuration directories with hidden files.
Guus Sliepen [Sun, 6 Dec 2020 15:17:58 +0000 (16:17 +0100)]
Fix deleting configuration directories with hidden files.

We incorrectly skipped files starting with a dot when deleting directories.
This is a problem on macOS, which might add .DS_Store files.

3 years agoFix potential NULL pointer dereference.
Guus Sliepen [Sun, 22 Nov 2020 10:59:54 +0000 (11:59 +0100)]
Fix potential NULL pointer dereference.

It is possible that an attempt is made to forward a request to a node
that is not reachable via meta-connections. This would trigger an assert
in debug builds, or cause a segmentation fault in release builds. Add
checks before attempts to send a request to node->nexthop->connection.

3 years agoDon't try to renew SPTPS keys for unreachable nodes. fix/deterministic-sptps-reset
Guus Sliepen [Mon, 16 Nov 2020 19:57:46 +0000 (20:57 +0100)]
Don't try to renew SPTPS keys for unreachable nodes.

This caused other functions that incorrectly used status.validkey to check
if they could send data to a node to pass a NULL pointer to send_request(),
causing a crash about an hour after a node went offline.

3 years agoOnly reset UDP SPTPS sessions if the session ID changed.
Guus Sliepen [Tue, 10 Nov 2020 20:10:00 +0000 (21:10 +0100)]
Only reset UDP SPTPS sessions if the session ID changed.

Previously we reset the SPTPS session if we detected if a node was
unreachable. However, that node might not think it was unreachable,
leading to only one side to reset the SPTPS connection. This would then
take some time to resolve itself.

We already had code to detect whether a node was restarted, so we use
that to detect if, once a node becomes reachable again, it remembers the
old SPTPS session or whether we have to start a new one. This should be
deterministic and not depend on the exact timing of events.

3 years agoAlso send the blacklist notification when we already have a connection.
Guus Sliepen [Thu, 29 Oct 2020 22:38:22 +0000 (23:38 +0100)]
Also send the blacklist notification when we already have a connection.

Instead of just closing the connection, and having to wait for the
reconnection to happen to send the blacklist notification, we do it
immediately when meshlink_blacklist() is called.

3 years agoAdd a callback that notifies the application when it is blacklisted.
Guus Sliepen [Thu, 29 Oct 2020 22:30:41 +0000 (23:30 +0100)]
Add a callback that notifies the application when it is blacklisted.

If an outgoing connection is made to a node that blacklists the local node,
a callback can now be set that informs the application of it.

3 years agoFix Doxygen errors.
Guus Sliepen [Sun, 25 Oct 2020 21:20:43 +0000 (22:20 +0100)]
Fix Doxygen errors.

3 years agoAdd API functions to query the blacklist status of nodes.
Guus Sliepen [Sun, 25 Oct 2020 21:18:53 +0000 (22:18 +0100)]
Add API functions to query the blacklist status of nodes.

3 years agoCheck blacklist status before committing an invitation.
Guus Sliepen [Sun, 25 Oct 2020 21:17:29 +0000 (22:17 +0100)]
Check blacklist status before committing an invitation.

Although we delete invitation files when blacklisting a node, there is a
race condition where an invitation connection is created right before the
invitee is blacklisted. So check that the node is blacklisted right before
committing the node config file to disk.

3 years agoRemove invitation files when blacklisting or forgetting a node.
Guus Sliepen [Sun, 25 Oct 2020 21:15:04 +0000 (22:15 +0100)]
Remove invitation files when blacklisting or forgetting a node.

3 years agoWhen a new connection is activated, terminate any pending connections to the same...
Guus Sliepen [Sun, 11 Oct 2020 14:16:31 +0000 (16:16 +0200)]
When a new connection is activated, terminate any pending connections to the same peer.

This prevents issues mainly in the test suite where peers try to connect to
each other simultaneously, and have to terminate one of the connections.
Before both connections would succeed, and both would be terminated, leading
to a loop of reconnections until enough randomness got in to break the tie.

3 years agoDon't reset the UDP SPTPS session when a node becomes reachable.
Guus Sliepen [Sun, 11 Oct 2020 13:40:34 +0000 (15:40 +0200)]
Don't reset the UDP SPTPS session when a node becomes reachable.

Only do this when it becomes unreachable. This fixes an issue where right
after a meta-connection is established, the initiator sends a proactive
REQ_KEY, before the peer really becomes reachable according to the graph.
When the latter happened, it would reset the session so far, causing a new
REQ_KEY to be sent, which could cross the ANS_KEY from the peer. This would
resolve itself after a few seconds, but causes an unnecessary delay that is
easy to trigger.

3 years agoFix waiting for peer node to become reachable in test suite.
Guus Sliepen [Sun, 11 Oct 2020 13:19:01 +0000 (15:19 +0200)]
Fix waiting for peer node to become reachable in test suite.

3 years agoFix cornercases closing channels.
Guus Sliepen [Wed, 30 Sep 2020 20:16:22 +0000 (22:16 +0200)]
Fix cornercases closing channels.

Closing a channel while there was data in the receive buffer would cause a
RST to be sent instead of a FIN. We now always send a FIN, and let data
in the receive buffer be handled for a later data handling (which would
then send a RST if necessary).

The RST could be dropped if the ACK seqno was not in the correct range.
We now always accept RSTs for established connections.

Finally, when receiving more data after closing the channel, we would just
accept the data but discard it, instead of sending a RST back. Now we do
send a RST back.

3 years agoSend RST packets when receiving data after we closed a UDP channel.
Guus Sliepen [Tue, 29 Sep 2020 20:38:55 +0000 (22:38 +0200)]
Send RST packets when receiving data after we closed a UDP channel.

If the application closed a channel, we keep the UTCP connection alive for
a bit longer to handle resends of FIN packets. However, if this is missed
for some reason, either because the FIN got lost or the peer ignored the
receive callback, and the peer is sending new data, we need to inform it
that we are no longer listening. To do this, send a RST back.

3 years agoExtend the timeout period of the authentication phase on progress.
Guus Sliepen [Fri, 25 Sep 2020 20:00:55 +0000 (22:00 +0200)]
Extend the timeout period of the authentication phase on progress.

If there is progress during the authentication phase of connections, we reset
the ping timer to give extra time to complete the authentication.

We do the same for invitation connections.

3 years agoDon't use fast timeouts for fully established connections.
Guus Sliepen [Fri, 25 Sep 2020 19:53:12 +0000 (21:53 +0200)]
Don't use fast timeouts for fully established connections.

During the fast retry period, we want to have a fast ping timeout until we have
a fully working connection. However, the code still used fast timeouts during
the fast retry window even if the connection was fully established.

3 years agoFix timeouts of 1 second expiring in less than one second.
Guus Sliepen [Fri, 25 Sep 2020 19:48:59 +0000 (21:48 +0200)]
Fix timeouts of 1 second expiring in less than one second.

3 years agoAllow sptps_force_kex() in all situations.
Guus Sliepen [Thu, 10 Sep 2020 21:18:26 +0000 (23:18 +0200)]
Allow sptps_force_kex() in all situations.

Also allow sptps_force_kex() during the initial key exchange.

3 years agoAllow sptps_force_kex() while a key exchange is in progress
Guus Sliepen [Thu, 10 Sep 2020 21:13:39 +0000 (23:13 +0200)]
Allow sptps_force_kex() while a key exchange is in progress

We should not do anything if we are already exchanging a new key, and
just return true. This change prevents higher layers in MeshLink from
terminating a connection between two nodes if both peers call
sptps_force_kex() at nearly the same time.

3 years agoUse the canonical address exclusively for making outgoing meta-connections.
Guus Sliepen [Mon, 7 Sep 2020 19:12:28 +0000 (21:12 +0200)]
Use the canonical address exclusively for making outgoing meta-connections.

If we have a node's canonical address, we now always use that as a source
for addresses for outgoing meta-connection attempts. This commit also adds
the function meshlink_clear_canonical_address() to ensure the canonical
address can be removed if it is no longer valid.

3 years agoUpdate the invite-join test to update the canonical address after a port change.
Guus Sliepen [Mon, 7 Sep 2020 19:10:22 +0000 (21:10 +0200)]
Update the invite-join test to update the canonical address after a port change.

3 years agoAlways ensure we store a port number when setting the canonical address.
Guus Sliepen [Mon, 7 Sep 2020 15:58:23 +0000 (17:58 +0200)]
Always ensure we store a port number when setting the canonical address.

3 years agoUse the fast retry period of the destination node's device class.
Guus Sliepen [Sat, 5 Sep 2020 09:52:12 +0000 (11:52 +0200)]
Use the fast retry period of the destination node's device class.

3 years agoRemove temporary files at startup.
Guus Sliepen [Tue, 4 Aug 2020 13:24:07 +0000 (15:24 +0200)]
Remove temporary files at startup.

When something happens while a host config files is written, a temporary
file might be left over. Clean these up when we find them when starting
MeshLink.

3 years agoAdd meshlink_set_channel_listen_cb().
Guus Sliepen [Wed, 29 Jul 2020 12:44:42 +0000 (14:44 +0200)]
Add meshlink_set_channel_listen_cb().

The accept callback is called when the peer has already fully established a
connection. The listen callback is called earlier, when there is no
fully established channel yet. However, the listen callback itself does not
get a channel handle, it can only make a decision based on the peer node
and port number whether to accept the channel, and if so the accept callback
will be called later.

3 years agoEnsure the poll callback is called when a UDP channel has finished connecting.
Guus Sliepen [Wed, 29 Jul 2020 12:40:27 +0000 (14:40 +0200)]
Ensure the poll callback is called when a UDP channel has finished connecting.

3 years agoSpeed up the import-export test by using the PMTU callback.
Guus Sliepen [Thu, 23 Jul 2020 22:06:53 +0000 (00:06 +0200)]
Speed up the import-export test by using the PMTU callback.

3 years agoFix the import-export test failing sporadically.
Guus Sliepen [Thu, 23 Jul 2020 22:06:26 +0000 (00:06 +0200)]
Fix the import-export test failing sporadically.

Since two nodes connecting simultaneously can cause a node to be seen as
temporarily being down, thus setting the last_unreachable status.

3 years agoAlways let the initiator send a REQ_KEY once a connection is activated.
Guus Sliepen [Thu, 23 Jul 2020 22:04:38 +0000 (00:04 +0200)]
Always let the initiator send a REQ_KEY once a connection is activated.

Before, the logic was to do this when the graph reported a bidirectional
edge. However, there was a possibility that if two nodes connect to each
other simultaneously, causing a second connection to be activated while the
first was also still active, which caused the REQ_KEY to not be sent.

3 years agoFix the channels-udp test case.
Guus Sliepen [Thu, 23 Jul 2020 21:13:57 +0000 (23:13 +0200)]
Fix the channels-udp test case.

Close channels gracefully after the server has finished sending the streams.

3 years agoCombine blackbox join test cases into the invite-join test.
Guus Sliepen [Thu, 23 Jul 2020 14:19:29 +0000 (16:19 +0200)]
Combine blackbox join test cases into the invite-join test.

3 years agoDon't attempt to sync confbase for ephemeral nodes during a join.
Guus Sliepen [Wed, 22 Jul 2020 21:34:06 +0000 (23:34 +0200)]
Don't attempt to sync confbase for ephemeral nodes during a join.

3 years agoPort the blackbox status_cb test.
Guus Sliepen [Wed, 22 Jul 2020 19:07:02 +0000 (21:07 +0200)]
Port the blackbox status_cb test.

Use ephemeral MeshLink instances to speed up the test.

3 years agoPort the blackbox meta-connections test using network namespaces.
Guus Sliepen [Wed, 22 Jul 2020 18:36:18 +0000 (20:36 +0200)]
Port the blackbox meta-connections test using network namespaces.

3 years agoWhen activating a meta-connection, remember the address of the peer.
Guus Sliepen [Wed, 22 Jul 2020 18:35:18 +0000 (20:35 +0200)]
When activating a meta-connection, remember the address of the peer.

There was a possible situation where we did not remember the address of a
peer when there is only a TCP connection.

3 years agoReset last_connect_try for all nodes when starting the mesh.
Guus Sliepen [Wed, 22 Jul 2020 18:31:59 +0000 (20:31 +0200)]
Reset last_connect_try for all nodes when starting the mesh.

This helps the autoconnect algorithm reconnect faster if the mesh was
stopped and restarted in quick succession.

3 years agoAdd reset_sync_flag().
Guus Sliepen [Wed, 22 Jul 2020 18:30:14 +0000 (20:30 +0200)]
Add reset_sync_flag().

This is for the test suite to reset a flag without broadcasting that it
changed state.

3 years agoAdd devtool_set_meta_status_cb().
Guus Sliepen [Wed, 22 Jul 2020 18:29:22 +0000 (20:29 +0200)]
Add devtool_set_meta_status_cb().

This function is similar to meshlink_set_node_status_cb(), except that
this callback will only be called when a meta-connection to a node is
activated or terminated. This is mainly useful for the test suite.

3 years agoDon't store empty canonical addresses.
Guus Sliepen [Mon, 13 Jul 2020 20:40:06 +0000 (22:40 +0200)]
Don't store empty canonical addresses.

Use a NULL pointer instead of an empty string to signal the lack of a
canonical address.

3 years agoFix invitation URL generation when running in a network namespace.
Guus Sliepen [Wed, 22 Jul 2020 13:00:59 +0000 (15:00 +0200)]
Fix invitation URL generation when running in a network namespace.

MeshLink could call getifaddrs() in the namespace of the caller instead of
the MeshLink thread, causing the wrong addresses to be put in the inviation
URL.

3 years agoExport missing meshlink_open_params_* symbols.
Guus Sliepen [Wed, 22 Jul 2020 12:59:44 +0000 (14:59 +0200)]
Export missing meshlink_open_params_* symbols.

3 years agoFix a crash with some network configurations.
Guus Sliepen [Fri, 10 Jul 2020 20:15:39 +0000 (22:15 +0200)]
Fix a crash with some network configurations.

It is apparently possible for getifaddrs() to return a struct ifaddrs that
contains a NULL ifa_addr pointer.

3 years agoAdd meshlink_reset_timers().
Guus Sliepen [Fri, 10 Jul 2020 20:13:23 +0000 (22:13 +0200)]
Add meshlink_reset_timers().

This resets the outgoing connections timers and ping timers, exactly what
is done when the network intterface status changes.

3 years agoCheck for the presence of stdatomic.h before using it.
Guus Sliepen [Tue, 7 Jul 2020 08:26:21 +0000 (10:26 +0200)]
Check for the presence of stdatomic.h before using it.

3 years agoDon't use assert() to check the results of pthread_*() calls.
Guus Sliepen [Sat, 4 Jul 2020 11:59:52 +0000 (13:59 +0200)]
Don't use assert() to check the results of pthread_*() calls.

This was done to debug the code, but it fails when MeshLink is compiled with
-DNDEBUG. Remove all assert()s from calls to pthread functions, and instead
add explicit checks to only those functions that can fail.

3 years agoExport meshlink_set_dev_class_maxtimeout().
Guus Sliepen [Sat, 4 Jul 2020 10:26:15 +0000 (12:26 +0200)]
Export meshlink_set_dev_class_maxtimeout().

3 years agoEnsure the maxtimeout value is taken from the destination node's device class.
Guus Sliepen [Sat, 4 Jul 2020 10:26:00 +0000 (12:26 +0200)]
Ensure the maxtimeout value is taken from the destination node's device class.

3 years agoMake the maximum outgoing connection timeout runtime configurable.
Guus Sliepen [Wed, 24 Jun 2020 20:22:01 +0000 (22:22 +0200)]
Make the maximum outgoing connection timeout runtime configurable.

This moves maxtimeout to the dev_class_traits, and adds a function to
change it, similar to how we handle other configurable timeouts.

3 years agoFix compiling the C++ examples.
Guus Sliepen [Tue, 16 Jun 2020 19:34:52 +0000 (21:34 +0200)]
Fix compiling the C++ examples.

3 years agoRevert "Fix warnings caused by C-only flags passed to the C++ compiler."
Guus Sliepen [Tue, 16 Jun 2020 18:07:12 +0000 (20:07 +0200)]
Revert "Fix warnings caused by C-only flags passed to the C++ compiler."

This reverts commit 9382f55b3f1c14c74e3bda229e277400743b11cc.

3 years agoRevert "Don't overwrite CFLAGS when adding -std=c11."
Guus Sliepen [Tue, 16 Jun 2020 18:06:59 +0000 (20:06 +0200)]
Revert "Don't overwrite CFLAGS when adding -std=c11."

This reverts commit 6d0820fda557de28c014b8ad4c40c385d23029a7.

3 years agoDon't overwrite CFLAGS when adding -std=c11.
Guus Sliepen [Mon, 15 Jun 2020 08:03:36 +0000 (10:03 +0200)]
Don't overwrite CFLAGS when adding -std=c11.

3 years agoReact faster to network changes, including point-to-point links.
Guus Sliepen [Sun, 14 Jun 2020 12:45:18 +0000 (14:45 +0200)]
React faster to network changes, including point-to-point links.

Tell Catta to also include point-to-point links, and when we get an
update from the Catta thread, wake up the main MeshLink thread so we
react to it immediately.

3 years agoOnly call setitimer if ITIMER_REAL is defined. fix/pthread-fixes
Guus Sliepen [Sat, 13 Jun 2020 19:45:08 +0000 (21:45 +0200)]
Only call setitimer if ITIMER_REAL is defined.

Musl doesn't implement setitimer().

3 years agoSet NOSIGPIPE on all sockets.
Guus Sliepen [Sat, 13 Jun 2020 19:39:39 +0000 (21:39 +0200)]
Set NOSIGPIPE on all sockets.

MacOS can raise a SIGPIPE when a local socket gets disconnected.

3 years agoFix warnings and missing mutex/cond initialization in the test suite.
Guus Sliepen [Fri, 12 Jun 2020 22:41:47 +0000 (00:41 +0200)]
Fix warnings and missing mutex/cond initialization in the test suite.

3 years agoInitialize the adns_done_queue.
Guus Sliepen [Fri, 12 Jun 2020 22:40:43 +0000 (00:40 +0200)]
Initialize the adns_done_queue.

3 years agoFix warnings caused by C-only flags passed to the C++ compiler.
Guus Sliepen [Fri, 12 Jun 2020 22:40:09 +0000 (00:40 +0200)]
Fix warnings caused by C-only flags passed to the C++ compiler.

3 years agoAdd missing initialization of a condition variable.
Guus Sliepen [Fri, 12 Jun 2020 07:09:52 +0000 (09:09 +0200)]
Add missing initialization of a condition variable.

3 years agoFix some test cases using the same configuration directory.
Guus Sliepen [Thu, 11 Jun 2020 20:31:25 +0000 (22:31 +0200)]
Fix some test cases using the same configuration directory.

3 years agoUse atomic operations to check whether to write to the signal pipe.
Guus Sliepen [Thu, 11 Jun 2020 19:52:00 +0000 (21:52 +0200)]
Use atomic operations to check whether to write to the signal pipe.

We need to do an atomic test-and-set operation to check whether we can
avoid writing to the signal pipe. Use C11 atomics to do this in a portable
way (hopefully).

3 years agoRemove gettimeofday() usage from test cases.
Guus Sliepen [Thu, 11 Jun 2020 20:22:37 +0000 (22:22 +0200)]
Remove gettimeofday() usage from test cases.

3 years agoAdd asserts() to all pthread related function calls.
Guus Sliepen [Thu, 11 Jun 2020 20:17:23 +0000 (22:17 +0200)]
Add asserts() to all pthread related function calls.

We normally expect all pthread-related functions to succeed, so in all
places where we didn't already explicitly check the return value, assert()
that the functions return 0.

3 years agoProperly initialize mutexes and condition variables.
Guus Sliepen [Wed, 10 Jun 2020 20:25:12 +0000 (22:25 +0200)]
Properly initialize mutexes and condition variables.

On Linux, zeroing a pthread_mutex_t or pthread_cond_t variable ensures
the mutex/cond is properly initialized, however this is not the case om
some other platforms. Ensure we always call pthread_mutex/cond_init().

3 years agoFix compiler warnings on macOS.
Guus Sliepen [Tue, 9 Jun 2020 21:18:04 +0000 (23:18 +0200)]
Fix compiler warnings on macOS.

3 years agoCheck whether IP_MTU is defined.
Guus Sliepen [Tue, 9 Jun 2020 21:12:44 +0000 (23:12 +0200)]
Check whether IP_MTU is defined.

3 years agoFix meshlink_join() failing on Android.
Guus Sliepen [Fri, 5 Jun 2020 16:09:38 +0000 (18:09 +0200)]
Fix meshlink_join() failing on Android.

The adns_blocking_request() function did not pass a hint to
getaddrinfo(). With glibc, the resulting struct addrinfo sets socktype
and protocol to SOCK_STREAM and IPPROTO_TCP, and the call to connect()
copied these values. However, bionic doesn't set the socktype and
protocol to those values if no hint was specified.

3 years agoEnsure utcp-test is compiled with the same flags as libmeshlink.
Guus Sliepen [Fri, 5 Jun 2020 07:40:26 +0000 (09:40 +0200)]
Ensure utcp-test is compiled with the same flags as libmeshlink.

3 years agoInclude "system.h" in the UTCP sources.
Guus Sliepen [Wed, 3 Jun 2020 19:23:33 +0000 (21:23 +0200)]
Include "system.h" in the UTCP sources.

The UTCP sources were not using the system.h header file like the rest
of the code, resulting in issues with some compilers.

3 years agoDon't crash when trying to connect a channel to port 0.
Guus Sliepen [Wed, 3 Jun 2020 19:19:09 +0000 (21:19 +0200)]
Don't crash when trying to connect a channel to port 0.

3 years agoExplicitly set the stack size for the MeshLink thread.
Guus Sliepen [Thu, 21 May 2020 12:48:02 +0000 (14:48 +0200)]
Explicitly set the stack size for the MeshLink thread.

Different libcs have different default sizes for newly created threads. In
particular, Musl defaults to 80 kB, which is too small for MeshLink. We now
request 1 MB, which should be more than enough to handle the deepest call
stacks.

3 years agoLimit the size of the fd read buffer in channel_poll().
Guus Sliepen [Wed, 20 May 2020 22:13:50 +0000 (00:13 +0200)]
Limit the size of the fd read buffer in channel_poll().

3 years agoAdd a test for AIO callback cornercases.
Guus Sliepen [Mon, 18 May 2020 21:25:50 +0000 (23:25 +0200)]
Add a test for AIO callback cornercases.

3 years agoFix assert that could incorrectly be triggered when a peer closed the channel.
Guus Sliepen [Mon, 18 May 2020 21:24:56 +0000 (23:24 +0200)]
Fix assert that could incorrectly be triggered when a peer closed the channel.

If we are sending AIO data on a channel and the peer closed the connection,
we could trigger an assert incorrectly.