Commit graph

2100 commits

Author SHA1 Message Date
Guus Sliepen
44f8f61396 Try to set DF bit on BSDs as well.
Every operating system seems to have its own, slightly different way to disable
packet fragmentation. Emit a compiler warning when no suitable way is found.
On OpenBSD, it seems impossible to do it for IPv4.
2010-02-02 22:22:27 +01:00
Guus Sliepen
ed14ef93b4 Immediately exchange keys when establishing a meta connection.
This in turn will trigger PMTU discovery, and ensures nodes know each others
reflexive UDP address and port.
2010-02-02 01:02:40 +01:00
Guus Sliepen
4a0b998151 Determine peer's reflexive address and port when exchanging keys.
To help peers that are behind NAT connect to each other directly via UDP, they
need to know the exact external address and port that they use. Keys exchanged
between NATted peers necessarily go via a third node, which knows this address
and port, and can append this information to the keys, which is in turned used
by the peers.

Since PMTU discovery will immediately trigger UDP communication from both sides
to each other, this should allow direct communication between peers behind
full, address-restricted and port-restricted cone NAT.
2010-02-02 00:51:44 +01:00
Guus Sliepen
d15099e002 Be liberal in accepting KEY_CHANGED/REQ_KEY/ANS_KEY requests.
When we got a key request for or from a node we don't know, we disconnected the
node that forwarded us that request.  However, especially in TunnelServer mode,
disconnecting does not help. We now ignore such requests, but since there is no
way of telling the original sender that the request was dropped, we now retry
sending REQ_KEY requests when we don't get an ANS_KEY back.
2010-01-23 18:48:01 +01:00
Guus Sliepen
469fa318bc Run subnet-up/down scripts for local MAC addresses as well. 2010-01-22 21:59:40 +01:00
Guus Sliepen
5d194b9f87 Fix subnet-up/down scripts being called with an empty SUBNET.
Commit 052ff8b2c5 contained a bug that causes
scripts to be called with an empty, or possibly corrupted SUBNET variable when
a Subnet is added or removed while the owner is still online. In router mode,
this normally does not happen, but in switch mode this is normal.
2010-01-22 21:47:26 +01:00
Guus Sliepen
b455111184 Make MSS clamping configurable, but enabled by default.
It can either be set globally in tinc.conf, or per-node in host config files.
2010-01-16 20:16:33 +01:00
Guus Sliepen
95928f7c29 Also clamp MSS of TCP over IPv6 packets. 2010-01-16 19:32:33 +01:00
Guus Sliepen
b1945f70fe Optimise handling of select() returning <= 0.
Before, we immediately retried select() if it returned -1 and errno is EAGAIN
or EINTR, and if it returned 0 it would check for network events even if we
know there are none.  Now, if -1 or 0 is returned we skip checking network
events, but we do check for timer and signal events.
2010-01-15 23:41:14 +01:00
Guus Sliepen
51099658c9 Ping nodes immediately when receiving SIGALRM.
One reason to send the ALRM signal is to let tinc immediately try to connect to
outgoing nodes, for example when PPP or DHCP configuration of the outgoing
interface finished.  Conversely, when the outgoing interface goes down one can
now send this signal to let tinc quickly detect that links are down too.
2010-01-15 23:19:08 +01:00
Guus Sliepen
2a538ed343 Clamp MSS of IPv4 SYN packets.
Some ISPs block the ICMP Fragmentation Needed packets that tinc sends.  We
clamp the MSS of IPv4 SYN packets to prevent hosts behind those ISPs from
sending too large packets.
2010-01-15 13:42:37 +01:00
Guus Sliepen
35b1c25093 Move source from lib/ to src/.
The utility functions in the lib/ directory do not really form a library.
Also, now that we build two binaries, tincctl does not need everything that was
in libvpn.a, so it is wasteful to link to it.
2009-12-31 13:19:13 +01:00
Guus Sliepen
41497246ee Remove unused AVL tree library. 2009-12-31 13:09:14 +01:00
Guus Sliepen
e4812ba9cc Allow Port and PMTUDiscovery options in tinc.conf, always enable PMTUDiscovery by default. 2009-12-24 12:42:21 +01:00
Guus Sliepen
7203d5fb07 Use xstrdup() instead of xasprintf() to copy static strings. 2009-12-23 19:51:55 +01:00
Guus Sliepen
a9a803d566 Allow port to be specified in Address statements.
This allows one to connect to use more than one port number to connect to
another node. The syntax is now:

Address = <hostname> [<port>]
2009-12-23 19:49:38 +01:00
Guus Sliepen
43e34d8180 Do not fragment packets smaller than RFC defined minimum MTUs.
For IPv6, the minimum MTU is 1280 (RFC 2460), for IPv4 the minimum is actually
68, but this is such a low limit that it will probably hurt performance, so we
do as if it is 576 (the minimum packet size hosts should be able to handle, RFC
791). If we detect a path MTU smaller than those minima, and we have to handle
a packet that is bigger than the PMTU but smaller than those minima, we forward
them via TCP instead of fragmenting or returning ICMP packets.
2009-12-23 19:22:06 +01:00
Guus Sliepen
3626165002 Do not use hardcoded cipher block length when padding. 2009-12-19 23:23:25 +01:00
Guus Sliepen
f542ef8f9e Fix alignment of results of RSA operations when using libgcrypt.
If the result of an RSA encryption or decryption operation can be represented
in less bytes than given, gcry_mpi_print() will not add leading zero bytes. Fix
this by adding those ourself.
2009-12-19 22:17:39 +01:00
Guus Sliepen
4c68a8cb60 Do not consider unreachable nodes when trying to determine packet origin. 2009-12-19 20:53:48 +01:00
Guus Sliepen
74e50d52e0 recv() and recvfrom() return int, do not prematurely cast the return value. 2009-12-19 20:52:19 +01:00
Guus Sliepen
0bfd69a273 Fix reading raw RSA keys with libgcrypt. 2009-12-19 20:26:30 +01:00
Guus Sliepen
0ff44fc241 Reinitialise block cipher IV each time we encrypt a packet when using libgcrypt. 2009-12-19 20:10:38 +01:00
Guus Sliepen
3c90be7678 Fix block cipher padding when using libgcrypt. 2009-12-19 18:57:54 +01:00
Guus Sliepen
c845bc109c Fix packet authentication.
This wasn't working at all, since we didn't do HMAC but just a plain hash.
Also, verification of packets failed because it was checking the whole packet,
not the packet minus the HMAC.
2009-12-18 01:15:25 +01:00
Guus Sliepen
10d609b1f0 Start of a GUI for tinc. 2009-12-16 21:18:21 +01:00
Guus Sliepen
55ef2f806f Allow connections to be closed.
This only closes existing meta connections, it may not affect node
reachability.
2009-12-16 21:16:56 +01:00
Guus Sliepen
f12c36afd5 Include missing header files and source directories. 2009-12-14 21:25:06 +01:00
Guus Sliepen
2a410cd26d Do not include OpenSSL headers directly. 2009-12-14 21:20:56 +01:00
Guus Sliepen
5d78e497f1 Fix compiler warnings. 2009-12-11 22:38:06 +01:00
Guus Sliepen
d6c50eb73a Merge branch 'master' into 1.1
Conflicts:
	src/subnet.c
2009-12-11 22:31:27 +01:00
Guus Sliepen
fec14791e8 Only call ioctlsocket() on Windows. 2009-12-11 22:24:07 +01:00
Guus Sliepen
369fe1ab1c Forget addresses of unreachable nodes.
We clear the cached address used for UDP connections when a node becomes
unreachable. This also prevents host-up scripts from passing the old, cached
address from when the host becomes reachable again from a different address.
2009-12-08 22:18:37 +00:00
Guus Sliepen
62f235e05c Remove unused variable in lookup_subnet_*() functions. 2009-11-28 11:56:13 +00:00
Guus Sliepen
92aefd25bf When learning MAC addresses, only check our own Subnets for previous entries.
Before it would check all addresses, and not learn an address if another node
already claimed that address. This caused fast roaming to fail, the code from
commit 6f6f426b35 was never triggered.
2009-11-28 11:52:23 +00:00
Guus Sliepen
edebf579f2 Use the TCP socket infrastructure for control sockets.
The control socket code was completely different from how meta connections are
handled, resulting in lots of extra code to handle requests.  Also, not every
operating system has UNIX sockets, so we have to resort to another type of
sockets or pipes for those anyway.  To reduce code duplication and make control
sockets work the same on all platforms, we now just connect to the TCP port
where tincd is already listening on.

To authenticate, the program that wants to control a running tinc daemon must
send the contents of a cookie file. The cookie is a random 256 bits number that
is regenerated every time tincd starts. The cookie file should only be readable
by the same user that can start a tincd.

Instead of the binary-ish protocol previously used, we now use an ASCII
protocol similar to that of the meta connections, but this can still change.
2009-11-07 23:43:25 +01:00
Guus Sliepen
c388527e34 Small fixes to get really working control sockets on Windows. 2009-11-07 16:09:56 +01:00
Guus Sliepen
5c5548fc71 Better integration of libevent in build system.
Since event.h is not part of tinc, we include it in have.h were all other
system header files are included.  We also ensure -levent comes before -lgdi32
when compiling with MinGW, apparently it doesn't work when the order is
reversed.
2009-11-07 14:35:48 +01:00
Guus Sliepen
075264a9e1 Make sure the 1.1 branch compiles in a MinGW environment.
UNIX domain sockets, of course, don't exist on Windows. For now, when compiling
tinc in a MinGW environment, try to use a TCP socket bound to localhost as an
alternative.
2009-11-05 23:29:28 +01:00
Guus Sliepen
08615e420b Handle PKCS#5 padding in the gcrypt backend. 2009-11-05 00:02:42 +01:00
Guus Sliepen
d9b2ac6767 Handle truncated message authentication codes with gcrypt.
Commit 4124b9682f did not update the gcrypt
backend.
2009-11-05 00:01:25 +01:00
Guus Sliepen
c4afc48154 Use %x instead of %lx where appropriate.
Some conversions were not properly merged from the master branch.
2009-11-04 16:19:08 +01:00
Guus Sliepen
37ccb325af Don't enable device events when there is no valid filedescriptor. 2009-11-04 16:18:08 +01:00
Guus Sliepen
108b238915 Merge branch 'master' into 1.1
Conflicts:
	NEWS
	README
	configure.in
	doc/tinc.texi
	doc/tincd.8.in
	src/Makefile.am
	src/connection.c
	src/edge.c
	src/meta.c
	src/net.c
	src/net.h
	src/net_packet.c
	src/net_setup.c
	src/net_socket.c
	src/node.c
	src/openssl/rsagen.h
	src/protocol_auth.c
	src/protocol_edge.c
	src/subnet.c
2009-11-02 14:24:27 +01:00
Guus Sliepen
44834d0304 Releasing 1.0.11. 2009-11-01 16:24:39 +01:00
Guus Sliepen
d331f04e45 Start a tinc service if it already exists. 2009-11-01 15:57:28 +01:00
Guus Sliepen
6f6f426b35 Fast handoff of roaming MAC addresses.
In switch mode, if a known MAC address is claimed by a second node before it
expired at the first node, it is likely that this is because a computer has
roamed from the LAN of the first node to that of the second node. To ensure
packets for that computer are routed to the second node, the first node should
delete its corresponding Subnet as soon as possible, without waiting for the
normal expiry timeout.
2009-10-27 23:53:49 +01:00
Guus Sliepen
e00b44cb98 Move socket error interpretation to utils.h. 2009-10-25 01:40:07 +02:00
Guus Sliepen
c11dc8079b Use WSAGetLastError() to determine cause of network errors on Windows.
This reduces log spam and lets path MTU discovery work faster.
2009-10-25 00:50:09 +02:00
Michael Tokarev
1bca167b7e Remove localedir leftovers. 2009-10-24 23:46:11 +02:00