2 net_socket.c -- Handle various kinds of sockets.
3 Copyright (C) 1998-2005 Ivo Timmermans,
4 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
5 2006 Scott Lamb <slamb@slamb.org>
6 2009 Florian Forster <octo@verplant.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "connection.h"
27 #include "control_common.h"
38 int addressfamily = AF_UNSPEC;
40 int seconds_till_retry = 5;
41 int udp_rcvbuf = 1024 * 1024;
42 int udp_sndbuf = 1024 * 1024;
43 int max_connection_burst = 100;
45 listen_socket_t listen_socket[MAXSOCKETS];
50 list_t *outgoing_list = NULL;
54 static void configure_tcp(connection_t *c) {
58 int flags = fcntl(c->socket, F_GETFL);
60 if(fcntl(c->socket, F_SETFL, flags | O_NONBLOCK) < 0) {
61 logger(DEBUG_ALWAYS, LOG_ERR, "fcntl for %s: %s", c->hostname, strerror(errno));
65 unsigned long arg = 1;
67 if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) {
68 logger(DEBUG_ALWAYS, LOG_ERR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno));
73 #if defined(TCP_NODELAY)
75 setsockopt(c->socket, IPPROTO_TCP, TCP_NODELAY, (void *)&option, sizeof(option));
78 #if defined(IP_TOS) && defined(IPTOS_LOWDELAY)
79 option = IPTOS_LOWDELAY;
80 setsockopt(c->socket, IPPROTO_IP, IP_TOS, (void *)&option, sizeof(option));
83 #if defined(IPV6_TCLASS) && defined(IPTOS_LOWDELAY)
84 option = IPTOS_LOWDELAY;
85 setsockopt(c->socket, IPPROTO_IPV6, IPV6_TCLASS, (void *)&option, sizeof(option));
89 static bool bind_to_interface(int sd) {
92 #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
95 #endif /* defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) */
97 if(!get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) {
101 #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
102 memset(&ifr, 0, sizeof(ifr));
103 strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
104 ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0;
106 status = setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr));
109 logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to interface %s: %s", iface,
110 sockstrerror(sockerrno));
114 #else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */
115 logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface");
121 static bool bind_to_address(connection_t *c) {
124 for(int i = 0; i < listen_sockets && listen_socket[i].bindto; i++) {
125 if(listen_socket[i].sa.sa.sa_family != c->address.sa.sa_family) {
140 sockaddr_t sa = listen_socket[s].sa;
142 if(sa.sa.sa_family == AF_INET) {
144 } else if(sa.sa.sa_family == AF_INET6) {
145 sa.in6.sin6_port = 0;
148 if(bind(c->socket, &sa.sa, SALEN(sa.sa))) {
149 logger(DEBUG_CONNECTIONS, LOG_WARNING, "Can't bind outgoing socket: %s", sockstrerror(sockerrno));
156 int setup_listen_socket(const sockaddr_t *sa) {
162 nfd = socket(sa->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
165 logger(DEBUG_STATUS, LOG_ERR, "Creating metasocket failed: %s", sockstrerror(sockerrno));
170 fcntl(nfd, F_SETFD, FD_CLOEXEC);
173 /* Optimize TCP settings */
176 setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option));
178 #if defined(IPV6_V6ONLY)
180 if(sa->sa.sa_family == AF_INET6) {
181 setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
185 #warning IPV6_V6ONLY not defined
189 (lookup_config(config_tree, "BindToInterface"), &iface)) {
190 #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
193 memset(&ifr, 0, sizeof(ifr));
194 strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
196 if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr))) {
198 logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to interface %s: %s", iface,
199 sockstrerror(sockerrno));
204 logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface");
208 if(bind(nfd, &sa->sa, SALEN(sa->sa))) {
210 addrstr = sockaddr2hostname(sa);
211 logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to %s/tcp: %s", addrstr, sockstrerror(sockerrno));
218 logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "listen", sockstrerror(sockerrno));
225 int setup_vpn_in_socket(const sockaddr_t *sa) {
230 nfd = socket(sa->sa.sa_family, SOCK_DGRAM, IPPROTO_UDP);
233 logger(DEBUG_ALWAYS, LOG_ERR, "Creating UDP socket failed: %s", sockstrerror(sockerrno));
238 fcntl(nfd, F_SETFD, FD_CLOEXEC);
243 int flags = fcntl(nfd, F_GETFL);
245 if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0) {
247 logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl",
254 unsigned long arg = 1;
256 if(ioctlsocket(nfd, FIONBIO, &arg) != 0) {
258 logger(DEBUG_ALWAYS, LOG_ERR, "Call to `%s' failed: %s", "ioctlsocket", sockstrerror(sockerrno));
265 setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option));
266 setsockopt(nfd, SOL_SOCKET, SO_BROADCAST, (void *)&option, sizeof(option));
268 if(udp_rcvbuf && setsockopt(nfd, SOL_SOCKET, SO_RCVBUF, (void *)&udp_rcvbuf, sizeof(udp_rcvbuf))) {
269 logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_RCVBUF to %i: %s", udp_rcvbuf, sockstrerror(sockerrno));
272 if(udp_sndbuf && setsockopt(nfd, SOL_SOCKET, SO_SNDBUF, (void *)&udp_sndbuf, sizeof(udp_sndbuf))) {
273 logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_SNDBUF to %i: %s", udp_sndbuf, sockstrerror(sockerrno));
276 #if defined(IPV6_V6ONLY)
278 if(sa->sa.sa_family == AF_INET6) {
279 setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
284 #if defined(IP_DONTFRAG) && !defined(IP_DONTFRAGMENT)
285 #define IP_DONTFRAGMENT IP_DONTFRAG
288 #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
290 if(myself->options & OPTION_PMTU_DISCOVERY) {
291 option = IP_PMTUDISC_DO;
292 setsockopt(nfd, IPPROTO_IP, IP_MTU_DISCOVER, (void *)&option, sizeof(option));
295 #elif defined(IP_DONTFRAGMENT)
297 if(myself->options & OPTION_PMTU_DISCOVERY) {
299 setsockopt(nfd, IPPROTO_IP, IP_DONTFRAGMENT, (void *)&option, sizeof(option));
304 #if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO)
306 if(myself->options & OPTION_PMTU_DISCOVERY) {
307 option = IPV6_PMTUDISC_DO;
308 setsockopt(nfd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, (void *)&option, sizeof(option));
311 #elif defined(IPV6_DONTFRAG)
313 if(myself->options & OPTION_PMTU_DISCOVERY) {
315 setsockopt(nfd, IPPROTO_IPV6, IPV6_DONTFRAG, (void *)&option, sizeof(option));
320 if(!bind_to_interface(nfd)) {
325 if(bind(nfd, &sa->sa, SALEN(sa->sa))) {
327 addrstr = sockaddr2hostname(sa);
328 logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to %s/udp: %s", addrstr, sockstrerror(sockerrno));
334 } /* int setup_vpn_in_socket */
336 static void retry_outgoing_handler(void *data) {
337 setup_outgoing_connection(data, true);
340 void retry_outgoing(outgoing_t *outgoing) {
341 outgoing->timeout += 5;
343 if(outgoing->timeout > maxtimeout) {
344 outgoing->timeout = maxtimeout;
347 timeout_add(&outgoing->ev, retry_outgoing_handler, outgoing, &(struct timeval) {
348 outgoing->timeout, rand() % 100000
351 logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Trying to re-establish outgoing connection in %d seconds", outgoing->timeout);
354 void finish_connecting(connection_t *c) {
355 logger(DEBUG_CONNECTIONS, LOG_INFO, "Connected to %s (%s)", c->name, c->hostname);
357 c->last_ping_time = now.tv_sec;
358 c->status.connecting = false;
363 static void do_outgoing_pipe(connection_t *c, char *command) {
367 if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) {
368 logger(DEBUG_ALWAYS, LOG_ERR, "Could not create socketpair: %s", sockstrerror(sockerrno));
375 logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Using proxy %s", command);
386 // Other filedescriptors should be closed automatically by CLOEXEC
391 sockaddr2str(&c->address, &host, &port);
392 setenv("REMOTEADDRESS", host, true);
393 setenv("REMOTEPORT", port, true);
394 setenv("NODE", c->name, true);
395 setenv("NAME", myself->name, true);
398 setenv("NETNAME", netname, true);
401 int result = system(command);
404 logger(DEBUG_ALWAYS, LOG_ERR, "Could not execute %s: %s", command, strerror(errno));
406 logger(DEBUG_ALWAYS, LOG_ERR, "%s exited with non-zero status %d", command, result);
411 logger(DEBUG_ALWAYS, LOG_ERR, "Proxy type exec not supported on this platform!");
416 static void handle_meta_write(connection_t *c) {
417 if(c->outbuf.len <= c->outbuf.offset) {
421 ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0);
424 if(!sockerrno || sockerrno == EPIPE) {
425 logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection closed by %s (%s)", c->name, c->hostname);
426 } else if(sockwouldblock(sockerrno)) {
427 logger(DEBUG_META, LOG_DEBUG, "Sending %d bytes to %s (%s) would block", c->outbuf.len - c->outbuf.offset, c->name, c->hostname);
430 logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not send %d bytes of data to %s (%s): %s", c->outbuf.len - c->outbuf.offset, c->name, c->hostname, sockstrerror(sockerrno));
433 terminate_connection(c, c->edge);
437 buffer_read(&c->outbuf, outlen);
440 io_set(&c->io, IO_READ);
444 static void handle_meta_io(void *data, int flags) {
445 connection_t *c = data;
447 if(c->status.connecting) {
449 The event loop does not protect against spurious events. Verify that we are actually connected
450 by issuing an empty send() call.
452 Note that the behavior of send() on potentially unconnected sockets differ between platforms:
453 +------------+-----------+-------------+-----------+
454 | Event | POSIX | Linux | Windows |
455 +------------+-----------+-------------+-----------+
456 | Spurious | ENOTCONN | EWOULDBLOCK | ENOTCONN |
457 | Failed | ENOTCONN | (cause) | ENOTCONN |
458 | Successful | (success) | (success) | (success) |
459 +------------+-----------+-------------+-----------+
461 if(send(c->socket, NULL, 0, 0) != 0) {
462 if(sockwouldblock(sockerrno)) {
468 if(!socknotconn(sockerrno)) {
469 socket_error = sockerrno;
471 socklen_t len = sizeof(socket_error);
472 getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&socket_error, &len);
476 logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Error while connecting to %s (%s): %s", c->name, c->hostname, sockstrerror(socket_error));
477 terminate_connection(c, false);
483 c->status.connecting = false;
484 finish_connecting(c);
487 if(flags & IO_WRITE) {
488 handle_meta_write(c);
490 handle_meta_connection_data(c);
494 static void free_known_addresses(struct addrinfo *ai) {
495 for(struct addrinfo *aip = ai, *next; aip; aip = next) {
501 bool do_outgoing_connection(outgoing_t *outgoing) {
502 char *address, *port, *space;
503 struct addrinfo *proxyai = NULL;
508 if(!outgoing->ai && !outgoing->kai) {
510 logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not set up a meta connection to %s", outgoing->name);
511 retry_outgoing(outgoing);
515 get_config_string(outgoing->cfg, &address);
517 space = strchr(address, ' ');
520 port = xstrdup(space + 1);
523 if(!get_config_string(lookup_config(outgoing->config_tree, "Port"), &port)) {
524 port = xstrdup("655");
528 outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
532 outgoing->aip = outgoing->ai;
533 outgoing->cfg = lookup_config_next(outgoing->config_tree, outgoing->cfg);
538 freeaddrinfo(outgoing->ai);
544 free_known_addresses(outgoing->kai);
547 outgoing->kai = NULL;
552 connection_t *c = new_connection();
553 c->outgoing = outgoing;
555 memcpy(&c->address, outgoing->aip->ai_addr, outgoing->aip->ai_addrlen);
556 outgoing->aip = outgoing->aip->ai_next;
558 c->hostname = sockaddr2hostname(&c->address);
560 logger(DEBUG_CONNECTIONS, LOG_INFO, "Trying to connect to %s (%s)", outgoing->name, c->hostname);
563 c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
565 } else if(proxytype == PROXY_EXEC) {
566 do_outgoing_pipe(c, proxyhost);
568 proxyai = str2addrinfo(proxyhost, proxyport, SOCK_STREAM);
575 logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
576 c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
580 if(c->socket == -1) {
581 logger(DEBUG_CONNECTIONS, LOG_ERR, "Creating socket for %s failed: %s", c->hostname, sockstrerror(sockerrno));
587 fcntl(c->socket, F_SETFD, FD_CLOEXEC);
590 if(proxytype != PROXY_EXEC) {
591 #if defined(IPV6_V6ONLY)
594 if(c->address.sa.sa_family == AF_INET6) {
595 setsockopt(c->socket, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
600 bind_to_interface(c->socket);
607 result = connect(c->socket, &c->address.sa, SALEN(c->address.sa));
608 } else if(proxytype == PROXY_EXEC) {
615 result = connect(c->socket, proxyai->ai_addr, proxyai->ai_addrlen);
616 freeaddrinfo(proxyai);
619 if(result == -1 && !sockinprogress(sockerrno)) {
620 logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not connect to %s (%s): %s", outgoing->name, c->hostname, sockstrerror(sockerrno));
626 /* Now that there is a working socket, fill in the rest and register this connection. */
628 c->last_ping_time = time(NULL);
629 c->status.connecting = true;
630 c->name = xstrdup(outgoing->name);
631 #ifndef DISABLE_LEGACY
632 c->outcipher = myself->connection->outcipher;
633 c->outdigest = myself->connection->outdigest;
635 c->outmaclength = myself->connection->outmaclength;
636 c->outcompression = myself->connection->outcompression;
637 c->last_ping_time = now.tv_sec;
641 io_add(&c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE);
646 // Find edges pointing to this node, and use them to build a list of unique, known addresses.
647 static struct addrinfo *get_known_addresses(node_t *n) {
648 struct addrinfo *ai = NULL;
649 struct addrinfo *oai = NULL;
651 for splay_each(edge_t, e, n->edge_tree) {
658 for(struct addrinfo *aip = ai; aip; aip = aip->ai_next) {
659 if(!sockaddrcmp(&e->reverse->address, (sockaddr_t *)aip->ai_addr)) {
670 ai = xzalloc(sizeof(*ai));
671 ai->ai_family = e->reverse->address.sa.sa_family;
672 ai->ai_socktype = SOCK_STREAM;
673 ai->ai_protocol = IPPROTO_TCP;
674 ai->ai_addrlen = SALEN(e->reverse->address.sa);
675 ai->ai_addr = xmalloc(ai->ai_addrlen);
676 memcpy(ai->ai_addr, &e->reverse->address, ai->ai_addrlen);
683 void setup_outgoing_connection(outgoing_t *outgoing, bool verbose) {
684 timeout_del(&outgoing->ev);
686 node_t *n = lookup_node(outgoing->name);
688 if(n && n->connection) {
689 logger(DEBUG_CONNECTIONS, LOG_INFO, "Already connected to %s", outgoing->name);
691 if(!n->connection->outgoing) {
692 n->connection->outgoing = outgoing;
699 init_configuration(&outgoing->config_tree);
700 read_host_config(outgoing->config_tree, outgoing->name, verbose);
701 outgoing->cfg = lookup_config(outgoing->config_tree, "Address");
705 outgoing->aip = outgoing->kai = get_known_addresses(n);
709 logger(verbose ? DEBUG_ALWAYS : DEBUG_CONNECTIONS, LOG_DEBUG, "No address known for %s", outgoing->name);
714 do_outgoing_connection(outgoing);
718 list_delete(outgoing_list, outgoing);
722 accept a new tcp connect and create a
725 void handle_new_meta_connection(void *data, int flags) {
726 listen_socket_t *l = data;
730 socklen_t len = sizeof(sa);
732 fd = accept(l->tcp.fd, &sa.sa, &len);
735 logger(DEBUG_ALWAYS, LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno));
741 // Check if we get many connections from the same host
743 static sockaddr_t prev_sa;
744 static int tarpit = -1;
751 if(!sockaddrcmp_noport(&sa, &prev_sa)) {
752 static int samehost_burst;
753 static int samehost_burst_time;
755 if(now.tv_sec - samehost_burst_time > samehost_burst) {
758 samehost_burst -= now.tv_sec - samehost_burst_time;
761 samehost_burst_time = now.tv_sec;
764 if(samehost_burst > max_connection_burst) {
770 memcpy(&prev_sa, &sa, sizeof(sa));
772 // Check if we get many connections from different hosts
774 static int connection_burst;
775 static int connection_burst_time;
777 if(now.tv_sec - connection_burst_time > connection_burst) {
778 connection_burst = 0;
780 connection_burst -= now.tv_sec - connection_burst_time;
783 connection_burst_time = now.tv_sec;
786 if(connection_burst >= max_connection_burst) {
787 connection_burst = max_connection_burst;
792 // Accept the new connection
794 c = new_connection();
795 c->name = xstrdup("<unknown>");
796 #ifndef DISABLE_LEGACY
797 c->outcipher = myself->connection->outcipher;
798 c->outdigest = myself->connection->outdigest;
800 c->outmaclength = myself->connection->outmaclength;
801 c->outcompression = myself->connection->outcompression;
804 c->hostname = sockaddr2hostname(&sa);
806 c->last_ping_time = now.tv_sec;
808 logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection from %s", c->hostname);
810 io_add(&c->io, handle_meta_io, c, c->socket, IO_READ);
816 c->allow_request = ID;
822 accept a new UNIX socket connection
824 void handle_new_unix_connection(void *data, int flags) {
829 socklen_t len = sizeof(sa);
831 fd = accept(io->fd, &sa.sa, &len);
834 logger(DEBUG_ALWAYS, LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno));
840 c = new_connection();
841 c->name = xstrdup("<control>");
843 c->hostname = xstrdup("localhost port unix");
845 c->last_ping_time = now.tv_sec;
847 logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection from %s", c->hostname);
849 io_add(&c->io, handle_meta_io, c, c->socket, IO_READ);
853 c->allow_request = ID;
859 static void free_outgoing(outgoing_t *outgoing) {
860 timeout_del(&outgoing->ev);
863 freeaddrinfo(outgoing->ai);
867 free_known_addresses(outgoing->kai);
870 if(outgoing->config_tree) {
871 exit_configuration(&outgoing->config_tree);
875 free(outgoing->name);
881 void try_outgoing_connections(void) {
882 /* If there is no outgoing list yet, create one. Otherwise, mark all outgoings as deleted. */
885 outgoing_list = list_alloc((list_action_t)free_outgoing);
887 for list_each(outgoing_t, outgoing, outgoing_list) {
888 outgoing->timeout = -1;
892 /* Make sure there is one outgoing_t in the list for each ConnectTo. */
894 for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
896 get_config_string(cfg, &name);
898 if(!check_id(name)) {
899 logger(DEBUG_ALWAYS, LOG_ERR,
900 "Invalid name for outgoing connection in %s line %d",
901 cfg->file, cfg->line);
906 if(!strcmp(name, myself->name)) {
913 for list_each(outgoing_t, outgoing, outgoing_list) {
914 if(!strcmp(outgoing->name, name)) {
916 outgoing->timeout = 0;
922 outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
923 outgoing->name = name;
924 list_insert_tail(outgoing_list, outgoing);
925 setup_outgoing_connection(outgoing, true);
929 /* Terminate any connections whose outgoing_t is to be deleted. */
931 for list_each(connection_t, c, connection_list) {
932 if(c->outgoing && c->outgoing->timeout == -1) {
934 logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name);
935 terminate_connection(c, c->edge);
939 /* Delete outgoing_ts for which there is no ConnectTo. */
941 for list_each(outgoing_t, outgoing, outgoing_list)
942 if(outgoing->timeout == -1) {
943 list_delete_node(outgoing_list, node);