Prepend source node ID information to UDP datagrams.
authorEtienne Dechamps <etienne@edechamps.fr>
Sat, 27 Sep 2014 17:13:33 +0000 (18:13 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 4 Oct 2014 10:21:44 +0000 (11:21 +0100)
commit8dd1c8a020e3babf5054179b0d30e2aa850d2e2b
tree75d56e2e4bd9c574297b31084271021870b0fbc6
parent092d620dbb3fdc8226ea0a4e1cfd5cd53d608420
Prepend source node ID information to UDP datagrams.

This commit changes the layout of UDP datagrams to include the 6-byte ID
(i.e. node name hash) of the node that crafted the packet at the very
beginning of the datagram (i.e. before the seqno). Note that this only
applies to SPTPS.

This is implemented at the lowest layer, i.e. in
handle_incoming_vpn_data() and send_sptps_data() functions. Source ID is
added and removed there, in such a way that the upper layers are unaware
of its presence.

This is the first stepping stone towards supporting UDP relaying in
SPTPS, by providing information about the original sender in the packet
itself. Nevertheless, even without relaying this commit already provides
a few benefits such as being able to reliably determine the source node
of a packet in the presence of an unknown source IP address, without
having to painfully go through all node keys. This makes tinc's behavior
much more scalable in this regard.

This change does not break anything with regard to the protocol: It
preserves compatibility with 1.0 and even with older pre-1.1 releases
thanks to a minor protocol version change (17.4). Source ID information
won't be included in packets sent to nodes with minor version < 4.

One drawback, however, is that this change increases SPTPS datagram
overhead by 6 bytes (the size of the source ID itself).
src/net.h
src/net_packet.c
src/protocol.h