Only forward SPTPS packets if Forwarding = internal.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 25 Oct 2017 19:08:29 +0000 (21:08 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 25 Oct 2017 19:08:29 +0000 (21:08 +0200)
This tries to match what is done for packets using the legacy protocol.
However, since SPTPS is end-to-end encrypted, Forwarding = kernel cannot
be implemented. In that case, we also drop the packets.

doc/tinc.conf.5.in
doc/tinc.texi
src/protocol_key.c

index cb7d1b1..53440a1 100644 (file)
@@ -306,9 +306,11 @@ Incoming packets that are meant for another node are forwarded by tinc internall
 .Pp
 This is the default mode, and unless you really know you need another forwarding mode, don't change it.
 .It kernel
-Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node.
+Incoming packets using the legacy protocol are always sent to the TUN/TAP device,
+even if the packets are not for the local node.
 This is less efficient, but allows the kernel to apply its routing and firewall rules on them,
 and can also help debugging.
+Incoming packets using the SPTPS protocol are dropped, since they are end-to-end encrypted.
 .El
 .It Va Hostnames Li = yes | no Pq no
 This option selects whether IP addresses (both real and on the VPN) should
index 987c36e..0c2f8c0 100644 (file)
@@ -1048,9 +1048,11 @@ Incoming packets that are meant for another node are forwarded by tinc internall
 This is the default mode, and unless you really know you need another forwarding mode, don't change it.
 
 @item kernel
-Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node.
+Incoming packets using the legacy protocol are always sent to the TUN/TAP device,
+even if the packets are not for the local node.
 This is less efficient, but allows the kernel to apply its routing and firewall rules on them,
 and can also help debugging.
+Incoming packets using the SPTPS protocol are dropped, since they are end-to-end encrypted.
 @end table
 
 @cindex Hostnames
index a7de07e..a0a1846 100644 (file)
@@ -29,6 +29,7 @@
 #include "node.h"
 #include "prf.h"
 #include "protocol.h"
+#include "route.h"
 #include "sptps.h"
 #include "utils.h"
 #include "xalloc.h"
@@ -150,8 +151,10 @@ static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, no
 
                if(to != myself) {
                        /* We don't just forward the request, because we want to use UDP if it's available. */
-                       send_sptps_data(to, from, 0, buf, len);
-                       try_tx(to, true);
+                       if(forwarding_mode == FMODE_INTERNAL) {
+                               send_sptps_data(to, from, 0, buf, len);
+                               try_tx(to, true);
+                       }
                } else {
                        /* The packet is for us */
                        if(!sptps_receive_data(&from->sptps, buf, len)) {