From: Guus Sliepen Date: Mon, 9 May 2011 19:35:14 +0000 (+0200) Subject: Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 X-Git-Tag: release-1.1pre1~65 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=ce8775000ab38229a78ecf3dc26bab008ca0f332 Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 Conflicts: NEWS README configure.in doc/tincd.8.in lib/pidfile.c src/bsd/device.c src/dropin.h src/net.c src/net_packet.c src/node.c src/process.c src/tincd.c --- ce8775000ab38229a78ecf3dc26bab008ca0f332 diff --cc NEWS index cee37ea8,792a71f1..c48a0e80 --- a/NEWS +++ b/NEWS @@@ -1,10 -1,4 +1,10 @@@ +Version 1.1-cvs Work in progress + + * Use libevent to handle I/O events and timeouts. + + * Use splay trees instead of AVL trees. + - Version 1.0.14 not released yet + Version 1.0.14 May 8 2011 * Fixed reading configuration files that do not end with a newline. Again. diff --cc README index 3f21f25d,bc8bea00..b1236fab --- a/README +++ b/README @@@ -1,7 -1,7 +1,7 @@@ -This is the README file for tinc version 1.0.14. Installation +This is the README file for tinc version 1.1-cvs. Installation instructions may be found in the INSTALL file. - tinc is Copyright (C) 1998-2010 by: + tinc is Copyright (C) 1998-2011 by: Ivo Timmermans, Guus Sliepen , @@@ -69,18 -69,13 +69,16 @@@ this library is not installed on you sy manual in doc/tinc.texi contains more detailed information on how to install this library. - Since 1.0pre6, the zlib library is used for optional compression. You need this - library whether or not you plan to enable the compression. You can find it at - http://www.gzip.org/zlib/. Because of a possible exploit in earlier versions we - recommand that you download version 1.1.4 or later. + Since 1.0pre6, the zlib library is used for optional compression. You can + find it at http://www.gzip.org/zlib/. Because of a possible exploit in + earlier versions we recommend that you download version 1.1.4 or later. - Since 1.0, the lzo library is also used for optional compression. You need this - library whether or not you plan to enable compression. You can find it at - http://www.oberhumer.com/opensource/lzo/. + Since 1.0, the lzo library is also used for optional compression. You can + find it at http://www.oberhumer.com/opensource/lzo/. +Since 1.1, the libevent library is used for the main event loop. You can find +it at http://monkey.org/~provos/libevent/. + In order to compile tinc, you will need a GNU C compiler environment. diff --cc configure.in index 5aacff6a,a6dd6d69..7c050139 --- a/configure.in +++ b/configure.in @@@ -98,8 -101,8 +100,8 @@@ dnl Checks for header files dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. AC_HEADER_STDC - AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) - AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h], -AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h dirent.h]) -AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h], ++AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) ++AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h], [], [], [#include "have.h"] ) AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h], @@@ -127,7 -130,7 +129,7 @@@ dnl Checks for library functions AC_FUNC_MEMCMP AC_FUNC_ALLOCA AC_TYPE_SIGNAL - AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time unsetenv vsyslog writev], -AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system unsetenv usleep vsyslog writev], ++AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev], [], [], [#include "have.h"] ) AC_FUNC_MALLOC diff --cc doc/tinc.texi index 3dc9eca4,6bbc2e24..7fc8909f --- a/doc/tinc.texi +++ b/doc/tinc.texi @@@ -37,10 -37,9 +37,10 @@@ permission notice identical to this one @page @vskip 0pt plus 1filll +@cindex copyright This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon. - Copyright @copyright{} 1998-2010 Ivo Timmermans, + Copyright @copyright{} 1998-2011 Ivo Timmermans, Guus Sliepen and Wessel Dankers . @@@ -1552,12 -1558,24 +1574,16 @@@ This will also disable the automatic re Set debug level to @var{level}. The higher the debug level, the more gets logged. Everything goes via syslog. -@item -k, --kill[=@var{signal}] -Attempt to kill a running tincd (optionally with the specified @var{signal} instead of SIGTERM) and exit. -Use it in conjunction with the -n option to make sure you kill the right tinc daemon. -Under native Windows the optional argument is ignored, -the service will always be stopped and removed. - @item -n, --net=@var{netname} - Use configuration for net @var{netname}. @xref{Multiple networks}. + Use configuration for net @var{netname}. + This will let tinc read all configuration files from + @file{@value{sysconfdir}/tinc/@var{netname}/}. + Specifying . for @var{netname} is the same as not specifying any @var{netname}. + @xref{Multiple networks}. -@item -K, --generate-keys[=@var{bits}] -Generate public/private keypair of @var{bits} length. If @var{bits} is not specified, -2048 is the default. tinc will ask where you want to store the files, -but will default to the configuration directory (you can use the -c or -n option -in combination with -K). After that, tinc will quit. +@item --controlsocket=@var{filename} +Open control socket at @var{filename}. If unspecified, the default is +@file{@value{localstatedir}/run/tinc.@var{netname}.control}. @item -L, --mlock Lock tinc into main memory. diff --cc doc/tincd.8.in index df6af144,a8ef2fb8..a210979e --- a/doc/tincd.8.in +++ b/doc/tincd.8.in @@@ -53,6 -56,29 +53,14 @@@ Increase debug level or set it t .It Fl n, -net Ns = Ns Ar NETNAME Connect to net .Ar NETNAME . + This will let tinc read all configuration files from + .Pa @sysconfdir@/tinc/ Ar NETNAME . + Specifying + .Li . + for + .Ar NETNAME + is the same as not specifying any + .Ar NETNAME . -.It Fl K, -generate-keys Ns Op = Ns Ar BITS -Generate public/private RSA keypair and exit. -If -.Ar BITS -is omitted, the default length will be 2048 bits. -When saving keys to existing files, tinc will not delete the old keys, -you have to remove them manually. .It Fl L, -mlock Lock tinc into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions. diff --cc src/bsd/device.c index 993b9825,d6ef0e82..d647734e --- a/src/bsd/device.c +++ b/src/bsd/device.c @@@ -197,13 -197,12 +197,12 @@@ bool read_packet(vpn_packet_t *packet) #ifdef HAVE_TUNEMU case DEVICE_TYPE_TUNEMU: if(device_type == DEVICE_TYPE_TUNEMU) - lenin = tunemu_read(device_fd, packet->data + 14, MTU - 14); + inlen = tunemu_read(device_fd, packet->data + 14, MTU - 14); else - #else - inlen = read(device_fd, packet->data + 14, MTU - 14); #endif - lenin = read(device_fd, packet->data + 14, MTU - 14); ++ inlen = read(device_fd, packet->data + 14, MTU - 14); - if(lenin <= 0) { + if(inlen <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; diff --cc src/net_packet.c index 7be46620,c7efa886..ded80a2f --- a/src/net_packet.c +++ b/src/net_packet.c @@@ -551,32 -572,38 +561,44 @@@ void broadcast_packet(const node_t *fro } static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { - avl_node_t *node; + splay_node_t *node; - node_t *n, *found = NULL; + edge_t *e; + node_t *n = NULL; + bool hard = false; static time_t last_hard_try = 0; + time_t now = time(NULL); + + if(last_hard_try == now) + return NULL; + else + last_hard_try = now; - for(node = node_tree->head; node; node = node->next) { - n = node->data; + for(node = edge_weight_tree->head; node; node = node->next) { + e = node->data; - if(n == myself || !n->status.reachable || !digest_active(&n->indigest)) + if(e->to == myself) continue; - if(try_mac(n, pkt)) { - found = n; - break; + if(sockaddrcmp_noport(from, &e->address)) { + if(last_hard_try == now) + continue; + hard = true; } + + if(!try_mac(e->to, pkt)) + continue; + + n = e->to; + break; } - return found; + if(hard) + last_hard_try = now; + + return n; } -void handle_incoming_vpn_data(int sock) { +void handle_incoming_vpn_data(int sock, short events, void *data) { vpn_packet_t pkt; char *hostname; sockaddr_t from; diff --cc src/node.c index 862bd696,36979ef3..9281178b --- a/src/node.c +++ b/src/node.c @@@ -142,7 -141,12 +142,12 @@@ node_t *lookup_node_udp(const sockaddr_ } void update_node_udp(node_t *n, const sockaddr_t *sa) { + if(n == myself) { + logger(LOG_WARNING, "Trying to update UDP address of myself!\n"); + return; + } + - avl_delete(node_udp_tree, n); + splay_delete(node_udp_tree, n); if(n->hostname) free(n->hostname); diff --cc src/process.c index d588a3fd,e74c1d9a..737a75e2 --- a/src/process.c +++ b/src/process.c @@@ -386,7 -540,13 +386,8 @@@ static struct {SIGBUS, fatal_signal_handler}, {SIGILL, fatal_signal_handler}, {SIGPIPE, ignore_signal_handler}, - {SIGINT, sigint_handler}, - {SIGUSR1, sigusr1_handler}, - {SIGUSR2, sigusr2_handler}, {SIGCHLD, ignore_signal_handler}, - {SIGALRM, sigalrm_handler}, - {SIGWINCH, sigwinch_handler}, + {SIGABRT, SIG_DFL}, {0, NULL} }; #endif