Commit graph

419 commits

Author SHA1 Message Date
thorkill
f96d2d5d76 Add functions for timers initialization and cleanup 2017-05-06 17:51:58 +02:00
thorkill
350e2d2d15 merged with guus/1.1 2017-04-28 10:40:50 +02:00
Guus Sliepen
1be0c284c7 Fix compiler warnings on *BSD. 2017-04-17 13:07:15 +02:00
thorkill
4b3c0aea78 Merge remote-tracking branch 'guus/1.1' into thkr-20170131-merge 2017-01-31 15:44:02 +01:00
Guus Sliepen
49edf9c53a Fix warnings from the Clang static analyzer.
These are all false positives or harmless dead stores.
2016-06-23 15:59:16 +02:00
thorkill
11b8eb81b9 Refactor of SLPD - moved most of the SLPD related code into slpd.{c,h} 2016-05-25 18:23:42 +02:00
thorkill
20df09ef89 Fix compile error 2016-05-23 21:27:53 +02:00
thorkill
f922b1c1e1 merged with guus/1.1 2016-05-23 21:17:42 +02:00
lemoer
9d0e86683c Added comments and unfold deep "if"-construct in timeout_handler 2016-05-21 12:54:02 +02:00
thorkill
fca59a36de Rephase a log message 2016-05-19 23:35:20 +02:00
thorkill
19177f823c Merged src/net.c wigth guus/1.1 2016-05-19 23:27:44 +02:00
thorkill
5baecfd11b Prevent tincd from sending packets to unexpecting nodes
Make tincd recognize when it was asleep and close connections to it's
peers. This happens when e.g. RoadWarrior has been suspended for
"longer" time period. After resume, it will start to communicate
with it's peers using the contextes it had before suspend.

On the other side, the nodes closed the connections since PingTimeout
and/or TCP connection went down.

Sending data to such unaware (sptps mostly) nodes will cause
havoc in the logs. Misleading the developers to wrong assumptions
that something is wrong with sptps.

# Conflicts:
#	src/net.c
2016-05-19 15:58:29 +02:00
thorkill
ae7bcad221 Prevent tincd from sending packets to unexpecting nodes
Make tincd recognize when it was asleep and close connections to it's
peers. This happens when e.g. RoadWarrior has been suspended for
"longer" time period. After resume, it will start to communicate
with it's peers using the contextes it had before suspend.

On the other side, the nodes closed the connections since PingTimeout
and/or TCP connection went down.

Sending data to such unaware (sptps mostly) nodes will cause
havoc in the logs. Misleading the developers to wrong assumptions
that something is wrong with sptps.
2016-05-19 15:48:15 +02:00
thorkill
4401c645ab Silence log messages on autoconnect 2016-05-14 23:21:36 +02:00
thorkill
c7d838eb41 Fixed autoconnect after merge 2016-05-08 16:46:29 +02:00
thorkill
4be26caf4e Merge remote-tracking branch 'guus/1.1' into thkr-foor2Vup 2016-05-08 15:58:29 +02:00
Guus Sliepen
2055c3e21d AutoConnect now only chooses from nodes for which we know an address.
Based partially on work from Rafał Leśniak.
2016-04-30 20:11:55 +02:00
Guus Sliepen
b6b302cee9 Speed up AutoConnect at startup.
Call periodic_handler() immediately at startup. Also, don't try to
connect to ourself.
2016-04-17 17:06:11 +02:00
Guus Sliepen
0037ec7cb3 Fix a non-working cast to get rid of a compiler warning. 2016-04-15 12:29:31 +02:00
Guus Sliepen
b5b04910b9 Replace usleep() with nanosleep(). 2016-04-14 17:21:47 +02:00
thorkill
f58e8679e7 Revert "Working on fix "stuck" outgoing connections."
This reverts commit 703ed7fff6.
2015-11-24 16:55:03 +01:00
thorkill
703ed7fff6 Working on fix "stuck" outgoing connections.
This problem occurs on "road-warriors" when tincd setups
outgoing connections but you do not have any active uplink then
dns-lookups will fail and any following attempt to make outgoing
connections will keep failing forever.
2015-11-22 22:50:51 +01:00
thorkill
618ddadeab Fixed a segfault when all nodes available for autoconnect has been exhausted
In cases when tinc has all available nodes in outgoing connections and
can not establish those connection due to network outage periodic_handler()
would crash since tmp_node_tree->count is 0.

This commit adds also new flag node->status.has_cfg_address to prevent
update_udp_address() from removing this flag.

Fixed node_status_t->unused - 13 + 19 = 32
2015-07-23 20:46:20 +02:00
thorkill
f12d4a3e6d Merged load_all_subnets and load_all_nodes to make autoconnect and strictsubnets work faster
When AutoConnect is on tinc needs to know if nodes have Address to defined
in thier hosts files. Currently tinc parsed node's host files if StrictSubnet
was enabled. To reduce the parsing overhead I have merged load_all_subnets
with load_all_nodes, such that load_all_subnets has been removed and
load_all_nodes has if-statement extracting Subnet information from node's host
file.
2015-07-23 18:34:29 +02:00
thorkill
3c67735720 Make autoconnect faster
When AutoConnect is enabled tinc tries to connect to other nodes picking them at random.
This may be sane default behavior but it may take ages if only few nodes have
defined Address in thier config.

Proposed solution to this problem:
- Filter out nodes without known address in periodic_handler
  I have added new node->status.has_known_address bool
- On update_node_udp() update this flag
2015-07-23 18:02:30 +02:00
thorkill
970283c148 Still working on ConnectTo outgoing connections 2015-07-10 02:18:06 +02:00
thorkill
85bf50612b Fixed typo in if statement 2015-07-10 02:05:22 +02:00
thorkill
6c6675e72a Do not cancel outgoing reconnects to nodes defined with ConnectTo 2015-07-10 02:01:06 +02:00
thorkill
606948116d Do not disconnect random hosts which are explicit set with ConnectTo 2015-07-10 01:43:24 +02:00
thorkill
78be3b19de Fixed signal_t initialization 2015-06-30 19:14:54 +02:00
thorkill
4f82a6359f Revert "Proper struct initialization"
This reverts commit bc8dbfc9fd.
2015-06-30 18:09:07 +02:00
thorkill
bc8dbfc9fd Proper struct initialization
Detected by clang -Wmissing-field-initializers
2015-06-29 23:32:34 +02:00
thorkill
26c7ff7fdd fixed conflict in src/sptps.c 2015-05-20 14:34:10 +02:00
Guus Sliepen
3ccdf50beb Allocate temporary filenames on the stack.
This gets rid of xasprintf() in a number of places, and removes the need
to free() the temporary strings. A few potential memory leaks have been
fixed.
2015-05-20 00:58:00 +02:00
thorkill
0cd387fd90 This commit implements average RTT estimation based on PING-PONG between active TCP connections.
Average RTT can be used to update edge weight and propagate it to the network.
tinc dump edges has been also extended to give the current RTT.
New edge weight will change only if the config has EdgeUpdateInterval set to other value than 0.

- Ignore local configuration for editors
- Extended manpage with informations about EdgeUpdateInterval
- Added clone_edge and fixed potential segfault when b->from not defined
- Compute avg_rtt based on the time values we got back in PONG
- Add avg_rtt on dump edge
- Send current time on PING and return it on PONG
- Changed last_ping_time to struct timeval
- Extended edge_t with avg_rtt
2015-04-11 15:27:28 +02:00
Guus Sliepen
0b310bf406 Always call res_init() before getaddrinfo().
Unfortunately, glibc assumes that /etc/resolv.conf is a static file that
never changes. Even on servers, /etc/resolv.conf might be a dynamically
generated file, and we never know when it changes. So just call
res_init() every time, so glibc uses up-to-date nameserver information.
2015-02-09 15:16:36 +01:00
Guus Sliepen
ae5b56c03d Send gratuitous type 2 probe replies.
If we receive any traffic from another node, we periodically send back a
gratuitous type 2 probe reply with the maximum received packet length.
On the other node, this causes the udp and perhaps mtu probe timers to
be reset, so it does not need to send a probe request. Gratuitous probe
replies from another node also count as received traffic for this
purpose, so for nodes that also have a meta-connection, UDP keepalive
packets in principle can now solely be type 2 replies. This reduces the
amount of probe traffic even more.

To work, gratuitous replies should be sent slightly more often than
udp_discovery_keepalive_interval, so probe requests won't be triggered.
This also means that the timer resolution must be smaller than the
difference between the two, and at the moment it's kind of a hack.
2015-01-11 17:44:50 +01:00
Guus Sliepen
eb7a0db18e Always keep UDP mappings alive for nodes that also have a meta-connection.
This is necessary for assisting with UDP hole punching. But we don't
need to know the PMTU for this, so only send UDP probes.
2015-01-11 13:31:01 +01:00
Etienne Dechamps
b23bf13283 Remove redundant connection_t::status.active field.
The only places where connection_t::status.active is modified is in
ack_h() and terminate_connection(). In both cases, connection_t::edge
is added and removed at the same time, and that's the only places
connection_t::edge is set. Therefore, the following is true at all
times:

    !c->status.active == !c->edge

This commit removes the redundant state information by getting rid of
connection_t::status.active, and using connection_t::edge instead.
2014-07-12 14:21:48 +02:00
Etienne Dechamps
46a5aa0d67 Make broadcast addresses configurable.
This adds a new option, BroadcastSubnet, that allows the user to
declare broadcast subnets, i.e. subnets which are considered broadcast
addresses by the tinc routing layer. Previously only the global IPv4
and IPv6 broadcast addresses were supported by virtue of being
hardcoded.

This is useful when using tinc in router mode with Ethernet virtual
devices, as it can be used to provide broadcast support for a local
broadcast address (e.g. 10.42.255.255) instead of just the global
address (255.255.255.255).

This is implemented by removing hardcoded broadcast addresses and
introducing "broadcast subnets", which are subnets with a NULL owner.
By default, behavior is unchanged; this is accomplished by adding
the global broadcast addresses for Ethernet, IPv4 and IPv6 at start
time.
2014-06-29 16:48:57 +01:00
Etienne Dechamps
0c026f3c6d Fix errno references when handling socket errors.
When using socket functions, "sockerrno" is supposed to be used to
retrieve the error code as opposed to "errno", so that it is translated
to the correct call on Windows (WSAGetLastError() - Windows does not
update errno on socket errors). Unfortunately, the use of sockerrno is
inconsistent throughout the tinc codebase, as errno is often used
incorrectly on socket-related calls.

This commit fixes these oversights, which improves socket error
handling on Windows.
2014-06-26 20:42:40 +01:00
Armin Fisslthaler
e76df30cb2 reload /etc/resolv.conf in SIGALRM handler 2014-06-22 17:20:55 +02:00
Guus Sliepen
332b55d472 Change AutoConnect from int to bool.
The proper value is 3, not 2 or 4, and 5 is right out. So just hardcode this value,
and only have the option to turn AutoConnect on or off.
2014-05-06 14:11:55 +02:00
Guus Sliepen
7da999f4ae Clean up child processes from proxy type exec. 2013-10-18 16:58:47 +02:00
Guus Sliepen
57991e2642 Use PATHEXT when checking for the presence of scripts on Windows.
It seems like a lot of overhead to call access() for every possible extension
defined in PATHEXT, but apparently this is what Windows does itself too. At
least this avoids calling system() when the script one is looking for does not
exist at all.

Since the tinc utility also needs to call scripts, execute_script() is now
split off into its own source file.
2013-08-23 21:23:46 +02:00
Guus Sliepen
76c90e1639 Non-zero exit code when reloading config file fails after SIGHUP.
When reloading the configuration file via the tinc command, the user will get
an error message if reloading has failed. However, no such warning exists when
sending a HUP signal. Previously, tincd would exit in both cases, but with a
zero exit code. Now it will exit with code 1 when reloading fails after a
SIGHUP, but tincd will keep running if it is signaled via the tinc command.
Instead, the tinc command will exit with a non-zero exit code.
2013-08-02 23:50:44 +02:00
Guus Sliepen
f3a2bed063 Really retry outgoing connections immediately if requested.
The retry() function would only abort connections that were in progress of
being made, it wouldn't reschedule the outgoing connections that had been
sleeping.
2013-08-02 20:53:54 +02:00
Guus Sliepen
1e7d1cd3c7 Clean up the SIGINT handler. 2013-08-02 20:50:19 +02:00
Guus Sliepen
fc119fb009 Use read_host_config() where appropriate. 2013-05-11 14:05:28 +02:00
Guus Sliepen
5b07039b07 Rename xmalloc_and_zero() to xzalloc().
The former name is more or less only used by tinc, the latter is used by other
projects as well, and shorter as well.
2013-05-01 17:31:33 +02:00