From c1154bf696b0b3ad22126a76750d610e32e2ffc1 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Sun, 17 May 2015 22:21:11 +0100 Subject: [PATCH 1/9] Make sure the MIN() macro is defined. On MinGW this is not automatically the case, thereby breaking the build. --- src/meta.c | 4 ++++ src/protocol_misc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/meta.c b/src/meta.c index a05c7bd2..260cb005 100644 --- a/src/meta.c +++ b/src/meta.c @@ -30,6 +30,10 @@ #include "utils.h" #include "xalloc.h" +#ifndef MIN +#define MIN(x, y) (((x)<(y))?(x):(y)) +#endif + bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) { connection_t *c = handle; diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 6e242742..de426c78 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -30,6 +30,10 @@ #include "utils.h" #include "xalloc.h" +#ifndef MIN +#define MIN(x, y) (((x)<(y))?(x):(y)) +#endif + int maxoutbufsize = 0; int mtu_info_interval = 5; int udp_info_interval = 5; From 01d251986260faf306927aa91daff705ee0523d6 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Sun, 17 May 2015 22:36:15 +0100 Subject: [PATCH 2/9] Don't pollute the system header directory namespace. Since commit 13f9bc1ff199bea46d3dde391a848f119e2cc0f0, tinc passes the -I. option to the preprocessor so that version_git.h can be found during out-of-tree ("VPATH") builds. The problem is, this option also affects the directory search for files included *from* system headers. For example, on MinGW, unistd.h contains the following line: #include Which, due to -I. putting the tinc directory at the head of the search order, results in tinc's process.h being included instead of the file from MinGW. Hilarity ensues. This commit fixes the issue by using -iquote, which doesn't affect system headers. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2ae43b03..a6489dfd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -260,4 +260,4 @@ if TUNEMU LIBS += -lpcap endif -AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" -I. +AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" -iquote. From 643149b44991121c618a2412c64072ad22955991 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Mon, 18 May 2015 20:35:44 +0100 Subject: [PATCH 3/9] Fix SPTPS condition in try_harder(). A condition in try_harder() is always evaluating to false when talking to a SPTPS node because n->status.validkey_in is always false in that case. Fix the condition so that the SPTPS status is correctly checked. This prevented recent tinc-1.1 nodes from talking to older, pre-node-ID tinc-1.1 nodes. The regression was introduced in 6056f1c13bb37bf711dff9c25a6eaea99f14d31f. --- src/net_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net_packet.c b/src/net_packet.c index 8313a54f..e169e2cd 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1350,7 +1350,7 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { if(!n->status.reachable || n == myself) continue; - if((n->status.sptps && !n->sptps.instate) || !n->status.validkey_in) + if(!n->status.validkey_in && !(n->status.sptps && n->sptps.instate)) continue; bool soft = false; From fef29d0193afc7e0a9dc766ef75b79cd4dc6fa37 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Mon, 18 May 2015 20:48:45 +0100 Subject: [PATCH 4/9] Don't parse node IDs if the sending node doesn't support them. Currently, tinc tries to parse node IDs for all SPTPS packets, including ones sent from older, pre-node-IDs tinc-1.1 nodes, and therefore doesn't recognize packets from these nodes. This commit fixes that. It also makes code slightly clearer by reducing the amount of fiddling around packet offset/length. --- src/net_packet.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/net_packet.c b/src/net_packet.c index e169e2cd..4c060453 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -282,9 +282,8 @@ static bool receive_udppacket(node_t *n, vpn_packet_t *inpkt) { } return false; } - inpkt->offset += 2 * sizeof(node_id_t); n->status.udppacket = true; - bool result = sptps_receive_data(&n->sptps, DATA(inpkt), inpkt->len - 2 * sizeof(node_id_t)); + bool result = sptps_receive_data(&n->sptps, DATA(inpkt), inpkt->len); n->status.udppacket = false; if(!result) { @@ -1440,10 +1439,16 @@ skip_harder: return; } - if(n->status.sptps) { - pkt.offset = 2 * sizeof(node_id_t); + pkt.offset = 0; - if(!memcmp(DSTID(&pkt), &nullid, sizeof nullid)) { + if(n->status.sptps) { + bool relay_enabled = (n->options >> 24) >= 4; + if (relay_enabled) { + pkt.offset = 2 * sizeof(node_id_t); + pkt.len -= pkt.offset; + } + + if(!memcmp(DSTID(&pkt), &nullid, sizeof nullid) || !relay_enabled) { direct = true; from = n; to = myself; @@ -1468,7 +1473,7 @@ skip_harder: /* If we're not the final recipient, relay the packet. */ if(to != myself) { - send_sptps_data(to, from, 0, DATA(&pkt), pkt.len - 2 * sizeof(node_id_t)); + send_sptps_data(to, from, 0, DATA(&pkt), pkt.len); try_tx_sptps(to, true); return; } @@ -1477,7 +1482,6 @@ skip_harder: from = n; } - pkt.offset = 0; if(!receive_udppacket(from, &pkt)) return; From a196e9b0fde1e8a67108eacd51ac663eac5a63ae Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Mon, 18 May 2015 21:06:16 +0100 Subject: [PATCH 5/9] Fix direct UDP communciation with pre-relaying 1.1 nodes. try_tx_sptps() gives up on UDP communication if the recipient doesn't support relaying. This is too restrictive - we only need the other node to support relaying if we actually want to relay through them. If the packet is sent directly, it's fine to send it to an old pre-node-IDs tinc-1.1 node. --- src/net_packet.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/net_packet.c b/src/net_packet.c index 4c060453..fc24c9a5 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1190,15 +1190,13 @@ static void try_tx_sptps(node_t *n, bool mtu) { node_t *via = (n->via == myself) ? n->nexthop : n->via; - /* If the static relay doesn't support SPTPS, everything goes via TCP anyway. */ + /* If we do have a static relay, try everything with that one instead, if it supports relaying. */ - if((via->options >> 24) < 4) - return; - - /* If we do have a static relay, try everything with that one instead. */ - - if(via != n) + if(via != n) { + if((via->options >> 24) < 4) + return; return try_tx_sptps(via, mtu); + } /* Otherwise, try to establish UDP connectivity. */ From 51b5aab9b042dffc6ef0791358f097895a3234eb Mon Sep 17 00:00:00 2001 From: Sven-Haegar Koch Date: Wed, 13 May 2015 21:24:29 +0200 Subject: [PATCH 6/9] Fix check for public key in invite-join.test. Small fix to test/invite-join.test, comparing no-longer-existing ECDSAPublicKey does not make sense. --- test/invite-join.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/invite-join.test b/test/invite-join.test index dbe6f8ae..c1bd1b8e 100755 --- a/test/invite-join.test +++ b/test/invite-join.test @@ -24,7 +24,7 @@ $tinc $c1 invite bar | $tinc $c2 join # Test equivalence of host config files cmp $d1/hosts/foo $d2/hosts/foo -test "`grep ^ECDSAPublicKey $d1/hosts/bar`" = "`grep ^ECDSAPublicKey $d2/hosts/bar`" +test "`grep ^Ed25519PublicKey $d1/hosts/bar`" = "`grep ^Ed25519PublicKey $d2/hosts/bar`" # Test Mode, Broadcast and ConnectTo statements From 96a323e16a1f3e99d0b498aa90423b060c3d458f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 19 May 2015 13:31:26 +0200 Subject: [PATCH 7/9] Remove info-in-builddir option from AM_INIT_AUTOMAKE(). This option is not supported by older, but still widely used versions of automake. The drawback is that when doing multiple VPATH builds in a row, the info manual may mention incorrect paths, but it doesn't affect the executables at all. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 120a8db5..4c5c0560 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ(2.61) AC_INIT([tinc], m4_esyscmd_s((git describe || echo UNKNOWN) | sed 's/release-//')) AC_CONFIG_SRCDIR([src/tincd.c]) AC_GNU_SOURCE -AM_INIT_AUTOMAKE([info-in-builddir std-options subdir-objects -Wall]) +AM_INIT_AUTOMAKE([std-options subdir-objects -Wall]) AC_CONFIG_HEADERS([config.h]) # Enable GNU extensions. From d8a3a182de30d649ed6764dd5d64b57ad77a446e Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 19 May 2015 14:09:53 +0200 Subject: [PATCH 8/9] Fix src/Makefile.am for *BSD. Apparently the BSDs don't like $(srcdir) but want to see ${srcdir} in their rules. --- src/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a6489dfd..63af709c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,11 +3,11 @@ sbin_PROGRAMS = tincd tinc sptps_test sptps_keypair ## Make sure version.c is always rebuilt with the latest git information -.PHONY: $(srcdir)/version.c version_git.h +.PHONY: ${srcdir}/version.c version_git.h version_git.h: echo >$@ -(cd $(srcdir) && git describe) && echo '#define GIT_DESCRIPTION "'`(cd $(srcdir) && git describe) | sed 's/release-//'`'"' >$@ -$(srcdir)/version.c: version_git.h +${srcdir}/version.c: version_git.h if LINUX sbin_PROGRAMS += sptps_speed From d89f37eb17196e38105a92d746ed7cb6b6f6ba45 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 19 May 2015 14:25:20 +0200 Subject: [PATCH 9/9] Add newline at end of precomp_data.h and sc.h. --- src/ed25519/precomp_data.h | 2 +- src/ed25519/sc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ed25519/precomp_data.h b/src/ed25519/precomp_data.h index 776b84f4..ce59788c 100644 --- a/src/ed25519/precomp_data.h +++ b/src/ed25519/precomp_data.h @@ -1388,4 +1388,4 @@ static ge_precomp base[32][8] = { { -20430234, 14955537, -24126347, 8124619, -5369288, -5990470, 30468147, -13900640, 18423289, 4177476 }, }, }, -}; \ No newline at end of file +}; diff --git a/src/ed25519/sc.h b/src/ed25519/sc.h index 8fa727ef..e29e7fa5 100644 --- a/src/ed25519/sc.h +++ b/src/ed25519/sc.h @@ -9,4 +9,4 @@ where l = 2^252 + 27742317777372353535851937790883648493. void sc_reduce(unsigned char *s); void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c); -#endif \ No newline at end of file +#endif