Replace the connection_tree with a connection_list.
The tree functions were never used on the connection_tree, a list is more appropriate. Also be more paranoid about connections disappearing while traversing the list.
This commit is contained in:
parent
ce059e36fd
commit
ff306f0cda
15 changed files with 77 additions and 116 deletions
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
#include "list.h"
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "control_common.h"
|
#include "control_common.h"
|
||||||
|
@ -31,22 +31,18 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
splay_tree_t *connection_tree; /* Meta connections */
|
list_t *connection_list; /* Meta connections */
|
||||||
connection_t *everyone;
|
connection_t *everyone;
|
||||||
|
|
||||||
static int connection_compare(const connection_t *a, const connection_t *b) {
|
|
||||||
return a < b ? -1 : a == b ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_connections(void) {
|
void init_connections(void) {
|
||||||
connection_tree = splay_alloc_tree((splay_compare_t) connection_compare, (splay_action_t) free_connection);
|
connection_list = list_alloc((list_action_t) free_connection);
|
||||||
everyone = new_connection();
|
everyone = new_connection();
|
||||||
everyone->name = xstrdup("everyone");
|
everyone->name = xstrdup("everyone");
|
||||||
everyone->hostname = xstrdup("BROADCAST");
|
everyone->hostname = xstrdup("BROADCAST");
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_connections(void) {
|
void exit_connections(void) {
|
||||||
splay_delete_tree(connection_tree);
|
list_delete_list(connection_list);
|
||||||
free_connection(everyone);
|
free_connection(everyone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,19 +87,22 @@ void free_connection(connection_t *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void connection_add(connection_t *c) {
|
void connection_add(connection_t *c) {
|
||||||
splay_insert(connection_tree, c);
|
list_insert_tail(connection_list, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void connection_del(connection_t *c) {
|
void connection_del(connection_t *c) {
|
||||||
splay_delete(connection_tree, c);
|
for(list_node_t *node = connection_list->head; node; node = node->next) {
|
||||||
|
if(node->data == c) {
|
||||||
|
list_delete_node(connection_list, node);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dump_connections(connection_t *cdump) {
|
bool dump_connections(connection_t *cdump) {
|
||||||
splay_node_t *node;
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
connection_t *c;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
|
||||||
c = node->data;
|
|
||||||
send_request(cdump, "%d %d %s %s %x %d %x",
|
send_request(cdump, "%d %d %s %s %x %d %x",
|
||||||
CONTROL, REQ_DUMP_CONNECTIONS,
|
CONTROL, REQ_DUMP_CONNECTIONS,
|
||||||
c->name, c->hostname, c->options, c->socket,
|
c->name, c->hostname, c->options, c->socket,
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "digest.h"
|
#include "digest.h"
|
||||||
#include "rsa.h"
|
#include "rsa.h"
|
||||||
#include "splay_tree.h"
|
#include "list.h"
|
||||||
#include "sptps.h"
|
#include "sptps.h"
|
||||||
|
|
||||||
#define OPTION_INDIRECT 0x0001
|
#define OPTION_INDIRECT 0x0001
|
||||||
|
@ -100,7 +100,7 @@ typedef struct connection_t {
|
||||||
splay_tree_t *config_tree; /* Pointer to configuration tree belonging to him */
|
splay_tree_t *config_tree; /* Pointer to configuration tree belonging to him */
|
||||||
} connection_t;
|
} connection_t;
|
||||||
|
|
||||||
extern splay_tree_t *connection_tree;
|
extern list_t *connection_list;
|
||||||
extern connection_t *everyone;
|
extern connection_t *everyone;
|
||||||
|
|
||||||
extern void init_connections(void);
|
extern void init_connections(void);
|
||||||
|
|
|
@ -100,13 +100,12 @@ bool control_h(connection_t *c, const char *request) {
|
||||||
case REQ_DISCONNECT: {
|
case REQ_DISCONNECT: {
|
||||||
char name[MAX_STRING_SIZE];
|
char name[MAX_STRING_SIZE];
|
||||||
connection_t *other;
|
connection_t *other;
|
||||||
splay_node_t *node, *next;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if(sscanf(request, "%*d %*d " MAX_STRING, name) != 1)
|
if(sscanf(request, "%*d %*d " MAX_STRING, name) != 1)
|
||||||
return control_return(c, REQ_DISCONNECT, -1);
|
return control_return(c, REQ_DISCONNECT, -1);
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
other = node->data;
|
other = node->data;
|
||||||
if(strcmp(other->name, name))
|
if(strcmp(other->name, name))
|
||||||
|
|
19
src/graph.c
19
src/graph.c
|
@ -44,12 +44,12 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "edge.h"
|
#include "edge.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
#include "list.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "netutl.h"
|
#include "netutl.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
@ -66,15 +66,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void mst_kruskal(void) {
|
static void mst_kruskal(void) {
|
||||||
splay_node_t *node, *next;
|
|
||||||
edge_t *e;
|
|
||||||
node_t *n;
|
|
||||||
connection_t *c;
|
|
||||||
|
|
||||||
/* Clear MST status on connections */
|
/* Clear MST status on connections */
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head; node; node = node->next) {
|
||||||
c = node->data;
|
connection_t *c = node->data;
|
||||||
c->status.mst = false;
|
c->status.mst = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,16 +77,16 @@ static void mst_kruskal(void) {
|
||||||
|
|
||||||
/* Clear visited status on nodes */
|
/* Clear visited status on nodes */
|
||||||
|
|
||||||
for(node = node_tree->head; node; node = node->next) {
|
for(splay_node_t *node = node_tree->head; node; node = node->next) {
|
||||||
n = node->data;
|
node_t *n = node->data;
|
||||||
n->status.visited = false;
|
n->status.visited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add safe edges */
|
/* Add safe edges */
|
||||||
|
|
||||||
for(node = edge_weight_tree->head; node; node = next) {
|
for(splay_node_t *node = edge_weight_tree->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
e = node->data;
|
edge_t *e = node->data;
|
||||||
|
|
||||||
if(!e->reverse || (e->from->status.visited && e->to->status.visited))
|
if(!e->reverse || (e->from->status.visited && e->to->status.visited))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -140,7 +140,8 @@ void logger(int level, int priority, const char *format, ...) {
|
||||||
if(logcontrol) {
|
if(logcontrol) {
|
||||||
suppress = true;
|
suppress = true;
|
||||||
logcontrol = false;
|
logcontrol = false;
|
||||||
for(splay_node_t *node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
|
next = node->next;
|
||||||
connection_t *c = node->data;
|
connection_t *c = node->data;
|
||||||
if(!c->status.log)
|
if(!c->status.log)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
@ -77,11 +76,9 @@ bool send_meta(connection_t *c, const char *buffer, int length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void broadcast_meta(connection_t *from, const char *buffer, int length) {
|
void broadcast_meta(connection_t *from, const char *buffer, int length) {
|
||||||
splay_node_t *node;
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
connection_t *c;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
|
||||||
c = node->data;
|
|
||||||
|
|
||||||
if(c != from && c->status.active)
|
if(c != from && c->status.active)
|
||||||
send_meta(c, buffer, length);
|
send_meta(c, buffer, length);
|
||||||
|
|
40
src/net.c
40
src/net.c
|
@ -23,7 +23,6 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
@ -158,13 +157,11 @@ void terminate_connection(connection_t *c, bool report) {
|
||||||
and close the connection.
|
and close the connection.
|
||||||
*/
|
*/
|
||||||
static void timeout_handler(int fd, short events, void *event) {
|
static void timeout_handler(int fd, short events, void *event) {
|
||||||
splay_node_t *node, *next;
|
|
||||||
connection_t *c;
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
c = node->data;
|
connection_t *c = node->data;
|
||||||
|
|
||||||
if(c->status.control)
|
if(c->status.control)
|
||||||
continue;
|
continue;
|
||||||
|
@ -249,10 +246,7 @@ static void sigalrm_handler(int signal, short events, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int reload_configuration(void) {
|
int reload_configuration(void) {
|
||||||
connection_t *c;
|
|
||||||
splay_node_t *node, *next;
|
|
||||||
char *fname;
|
char *fname;
|
||||||
struct stat s;
|
|
||||||
|
|
||||||
/* Reread our own configuration file */
|
/* Reread our own configuration file */
|
||||||
|
|
||||||
|
@ -278,18 +272,16 @@ int reload_configuration(void) {
|
||||||
/* If StrictSubnet is set, expire deleted Subnets and read new ones in */
|
/* If StrictSubnet is set, expire deleted Subnets and read new ones in */
|
||||||
|
|
||||||
if(strictsubnets) {
|
if(strictsubnets) {
|
||||||
subnet_t *subnet;
|
for(splay_node_t *node = subnet_tree->head; node; node = node->next) {
|
||||||
|
subnet_t *subnet = node->data;
|
||||||
for(node = subnet_tree->head; node; node = node->next) {
|
|
||||||
subnet = node->data;
|
|
||||||
subnet->expires = 1;
|
subnet->expires = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_all_subnets();
|
load_all_subnets();
|
||||||
|
|
||||||
for(node = subnet_tree->head; node; node = next) {
|
for(splay_node_t *node = subnet_tree->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
subnet = node->data;
|
subnet_t *subnet = node->data;
|
||||||
if(subnet->expires == 1) {
|
if(subnet->expires == 1) {
|
||||||
send_del_subnet(everyone, subnet);
|
send_del_subnet(everyone, subnet);
|
||||||
if(subnet->owner->status.reachable)
|
if(subnet->owner->status.reachable)
|
||||||
|
@ -304,9 +296,7 @@ int reload_configuration(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* Only read our own subnets back in */
|
} else { /* Only read our own subnets back in */
|
||||||
subnet_t *subnet, *s2;
|
for(splay_node_t *node = myself->subnet_tree->head; node; node = node->next) {
|
||||||
|
|
||||||
for(node = myself->subnet_tree->head; node; node = node->next) {
|
|
||||||
subnet_t *subnet = node->data;
|
subnet_t *subnet = node->data;
|
||||||
if(!subnet->expires)
|
if(!subnet->expires)
|
||||||
subnet->expires = 1;
|
subnet->expires = 1;
|
||||||
|
@ -315,6 +305,8 @@ int reload_configuration(void) {
|
||||||
config_t *cfg = lookup_config(config_tree, "Subnet");
|
config_t *cfg = lookup_config(config_tree, "Subnet");
|
||||||
|
|
||||||
while(cfg) {
|
while(cfg) {
|
||||||
|
subnet_t *subnet, *s2;
|
||||||
|
|
||||||
if(!get_config_subnet(cfg, &subnet))
|
if(!get_config_subnet(cfg, &subnet))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -332,7 +324,7 @@ int reload_configuration(void) {
|
||||||
cfg = lookup_config_next(config_tree, cfg);
|
cfg = lookup_config_next(config_tree, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(node = myself->subnet_tree->head; node; node = next) {
|
for(splay_node_t *node = myself->subnet_tree->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
subnet_t *subnet = node->data;
|
subnet_t *subnet = node->data;
|
||||||
if(subnet->expires == 1) {
|
if(subnet->expires == 1) {
|
||||||
|
@ -349,14 +341,15 @@ int reload_configuration(void) {
|
||||||
|
|
||||||
/* Close connections to hosts that have a changed or deleted host config file */
|
/* Close connections to hosts that have a changed or deleted host config file */
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
c = node->data;
|
connection_t *c = node->data;
|
||||||
next = node->next;
|
next = node->next;
|
||||||
|
|
||||||
if(c->status.control)
|
if(c->status.control)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name);
|
xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name);
|
||||||
|
struct stat s;
|
||||||
if(stat(fname, &s) || s.st_mtime > last_config_check) {
|
if(stat(fname, &s) || s.st_mtime > last_config_check) {
|
||||||
logger(DEBUG_CONNECTIONS, LOG_INFO, "Host config file of %s has been changed", c->name);
|
logger(DEBUG_CONNECTIONS, LOG_INFO, "Host config file of %s has been changed", c->name);
|
||||||
terminate_connection(c, c->status.active);
|
terminate_connection(c, c->status.active);
|
||||||
|
@ -370,12 +363,9 @@ int reload_configuration(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void retry(void) {
|
void retry(void) {
|
||||||
connection_t *c;
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
splay_node_t *node, *next;
|
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = next) {
|
|
||||||
next = node->next;
|
next = node->next;
|
||||||
c = node->data;
|
connection_t *c = node->data;
|
||||||
|
|
||||||
if(c->outgoing && !c->node) {
|
if(c->outgoing && !c->node) {
|
||||||
if(timeout_initialized(&c->outgoing->ev))
|
if(timeout_initialized(&c->outgoing->ev))
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include LZO1X_H
|
#include LZO1X_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
@ -750,10 +749,6 @@ void send_packet(node_t *n, vpn_packet_t *packet) {
|
||||||
/* Broadcast a packet using the minimum spanning tree */
|
/* Broadcast a packet using the minimum spanning tree */
|
||||||
|
|
||||||
void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
|
void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
|
||||||
splay_node_t *node;
|
|
||||||
connection_t *c;
|
|
||||||
node_t *n;
|
|
||||||
|
|
||||||
// Always give ourself a copy of the packet.
|
// Always give ourself a copy of the packet.
|
||||||
if(from != myself)
|
if(from != myself)
|
||||||
send_packet(myself, packet);
|
send_packet(myself, packet);
|
||||||
|
@ -771,8 +766,9 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
|
||||||
// This guarantees all nodes receive the broadcast packet, and
|
// This guarantees all nodes receive the broadcast packet, and
|
||||||
// usually distributes the sending of broadcast packets over all nodes.
|
// usually distributes the sending of broadcast packets over all nodes.
|
||||||
case BMODE_MST:
|
case BMODE_MST:
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
c = node->data;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
|
|
||||||
if(c->status.active && c->status.mst && c != from->nexthop->connection)
|
if(c->status.active && c->status.mst && c != from->nexthop->connection)
|
||||||
send_packet(c->node, packet);
|
send_packet(c->node, packet);
|
||||||
|
@ -786,8 +782,8 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
|
||||||
if(from != myself)
|
if(from != myself)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for(node = node_tree->head; node; node = node->next) {
|
for(splay_node_t *node = node_tree->head; node; node = node->next) {
|
||||||
n = node->data;
|
node_t *n = node->data;
|
||||||
|
|
||||||
if(n->status.reachable && ((n->via == myself && n->nexthop == n) || n->via == n))
|
if(n->status.reachable && ((n->via == myself && n->nexthop == n) || n->via == n))
|
||||||
send_packet(n, packet);
|
send_packet(n, packet);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
@ -972,14 +971,9 @@ bool setup_network(void) {
|
||||||
close all open network connections
|
close all open network connections
|
||||||
*/
|
*/
|
||||||
void close_network_connections(void) {
|
void close_network_connections(void) {
|
||||||
splay_node_t *node, *next;
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
connection_t *c;
|
|
||||||
char *envp[5];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = next) {
|
|
||||||
next = node->next;
|
next = node->next;
|
||||||
c = node->data;
|
connection_t *c = node->data;
|
||||||
/* Keep control connections open until the end, so they know when we really terminated */
|
/* Keep control connections open until the end, so they know when we really terminated */
|
||||||
if(c->status.control)
|
if(c->status.control)
|
||||||
c->socket = -1;
|
c->socket = -1;
|
||||||
|
@ -995,13 +989,14 @@ void close_network_connections(void) {
|
||||||
free_connection(myself->connection);
|
free_connection(myself->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < listen_sockets; i++) {
|
for(int i = 0; i < listen_sockets; i++) {
|
||||||
event_del(&listen_socket[i].ev_tcp);
|
event_del(&listen_socket[i].ev_tcp);
|
||||||
event_del(&listen_socket[i].ev_udp);
|
event_del(&listen_socket[i].ev_udp);
|
||||||
close(listen_socket[i].tcp);
|
close(listen_socket[i].tcp);
|
||||||
close(listen_socket[i].udp);
|
close(listen_socket[i].udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *envp[5];
|
||||||
xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
|
xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
|
||||||
xasprintf(&envp[1], "DEVICE=%s", device ? : "");
|
xasprintf(&envp[1], "DEVICE=%s", device ? : "");
|
||||||
xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
|
xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
|
||||||
|
@ -1018,7 +1013,7 @@ void close_network_connections(void) {
|
||||||
|
|
||||||
if(myport) free(myport);
|
if(myport) free(myport);
|
||||||
|
|
||||||
for(i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
free(envp[i]);
|
free(envp[i]);
|
||||||
|
|
||||||
devops.close();
|
devops.close();
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
@ -627,9 +626,9 @@ void try_outgoing_connections(void) {
|
||||||
|
|
||||||
/* Terminate any connections whose outgoing_t is to be deleted. */
|
/* Terminate any connections whose outgoing_t is to be deleted. */
|
||||||
|
|
||||||
for(splay_node_t *n = connection_tree->head, *next; n; n = next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
next = n->next;
|
next = node->next;
|
||||||
connection_t *c = n->data;
|
connection_t *c = node->data;
|
||||||
if(c->outgoing && c->outgoing->timeout == -1) {
|
if(c->outgoing && c->outgoing->timeout == -1) {
|
||||||
c->outgoing = NULL;
|
c->outgoing = NULL;
|
||||||
logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name);
|
logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name);
|
||||||
|
@ -639,10 +638,10 @@ void try_outgoing_connections(void) {
|
||||||
|
|
||||||
/* Delete outgoing_ts for which there is no ConnectTo. */
|
/* Delete outgoing_ts for which there is no ConnectTo. */
|
||||||
|
|
||||||
for(list_node_t *i = outgoing_list->head, *next; i; i = next) {
|
for(list_node_t *node = outgoing_list->head, *next; node; node = next) {
|
||||||
next = i->next;
|
next = node->next;
|
||||||
outgoing = i->data;
|
outgoing = node->data;
|
||||||
if(outgoing->timeout == -1)
|
if(outgoing->timeout == -1)
|
||||||
list_delete_node(outgoing_list, i);
|
list_delete_node(outgoing_list, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "edge.h"
|
#include "edge.h"
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
|
@ -37,15 +36,13 @@
|
||||||
static bool mykeyused = false;
|
static bool mykeyused = false;
|
||||||
|
|
||||||
void send_key_changed(void) {
|
void send_key_changed(void) {
|
||||||
splay_node_t *node;
|
|
||||||
connection_t *c;
|
|
||||||
|
|
||||||
send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), myself->name);
|
send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), myself->name);
|
||||||
|
|
||||||
/* Immediately send new keys to directly connected nodes to keep UDP mappings alive */
|
/* Immediately send new keys to directly connected nodes to keep UDP mappings alive */
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
c = node->data;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
if(c->status.active && c->node && c->node->status.reachable) {
|
if(c->status.active && c->node && c->node->status.reachable) {
|
||||||
if(!c->node->status.sptps)
|
if(!c->node->status.sptps)
|
||||||
send_ans_key(c->node);
|
send_ans_key(c->node);
|
||||||
|
@ -55,7 +52,7 @@ void send_key_changed(void) {
|
||||||
/* Force key exchange for connections using SPTPS */
|
/* Force key exchange for connections using SPTPS */
|
||||||
|
|
||||||
if(experimental) {
|
if(experimental) {
|
||||||
for(node = node_tree->head; node; node = node->next) {
|
for(splay_node_t *node = node_tree->head; node; node = node->next) {
|
||||||
node_t *n = node->data;
|
node_t *n = node->data;
|
||||||
if(n->status.reachable && n->status.validkey && n->status.sptps)
|
if(n->status.reachable && n->status.validkey && n->status.sptps)
|
||||||
sptps_force_kex(&n->sptps);
|
sptps_force_kex(&n->sptps);
|
||||||
|
|
27
src/route.c
27
src/route.c
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "splay_tree.h"
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "control_common.h"
|
#include "control_common.h"
|
||||||
#include "ethernet.h"
|
#include "ethernet.h"
|
||||||
|
@ -187,15 +186,12 @@ static void swap_mac_addresses(vpn_packet_t *packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void age_subnets(int fd, short events, void *data) {
|
static void age_subnets(int fd, short events, void *data) {
|
||||||
subnet_t *s;
|
|
||||||
connection_t *c;
|
|
||||||
splay_node_t *node, *next, *node2;
|
|
||||||
bool left = false;
|
bool left = false;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
for(node = myself->subnet_tree->head; node; node = next) {
|
for(splay_node_t *node = myself->subnet_tree->head, *next; node; node = next) {
|
||||||
next = node->next;
|
next = node->next;
|
||||||
s = node->data;
|
subnet_t *s = node->data;
|
||||||
if(s->expires && s->expires < now) {
|
if(s->expires && s->expires < now) {
|
||||||
if(debug_level >= DEBUG_TRAFFIC) {
|
if(debug_level >= DEBUG_TRAFFIC) {
|
||||||
char netstr[MAXNETSTR];
|
char netstr[MAXNETSTR];
|
||||||
|
@ -203,8 +199,9 @@ static void age_subnets(int fd, short events, void *data) {
|
||||||
logger(DEBUG_TRAFFIC, LOG_INFO, "Subnet %s expired", netstr);
|
logger(DEBUG_TRAFFIC, LOG_INFO, "Subnet %s expired", netstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(node2 = connection_tree->head; node2; node2 = node2->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
c = node2->data;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
if(c->status.active)
|
if(c->status.active)
|
||||||
send_del_subnet(c, s);
|
send_del_subnet(c, s);
|
||||||
}
|
}
|
||||||
|
@ -221,11 +218,7 @@ static void age_subnets(int fd, short events, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void learn_mac(mac_t *address) {
|
static void learn_mac(mac_t *address) {
|
||||||
subnet_t *subnet;
|
subnet_t *subnet = lookup_subnet_mac(myself, address);
|
||||||
splay_node_t *node;
|
|
||||||
connection_t *c;
|
|
||||||
|
|
||||||
subnet = lookup_subnet_mac(myself, address);
|
|
||||||
|
|
||||||
/* If we don't know this MAC address yet, store it */
|
/* If we don't know this MAC address yet, store it */
|
||||||
|
|
||||||
|
@ -244,8 +237,9 @@ static void learn_mac(mac_t *address) {
|
||||||
|
|
||||||
/* And tell all other tinc daemons it's our MAC */
|
/* And tell all other tinc daemons it's our MAC */
|
||||||
|
|
||||||
for(node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
c = node->data;
|
next = node->next;
|
||||||
|
connection_t *c = node->data;
|
||||||
if(c->status.active)
|
if(c->status.active)
|
||||||
send_add_subnet(c, subnet);
|
send_add_subnet(c, subnet);
|
||||||
}
|
}
|
||||||
|
@ -878,7 +872,8 @@ static void route_mac(node_t *source, vpn_packet_t *packet) {
|
||||||
|
|
||||||
static void send_pcap(vpn_packet_t *packet) {
|
static void send_pcap(vpn_packet_t *packet) {
|
||||||
pcap = false;
|
pcap = false;
|
||||||
for(splay_node_t *node = connection_tree->head; node; node = node->next) {
|
for(list_node_t *node = connection_list->head, *next; node; node = next) {
|
||||||
|
next = node->next;
|
||||||
connection_t *c = node->data;
|
connection_t *c = node->data;
|
||||||
if(!c->status.pcap)
|
if(!c->status.pcap)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
// Symbols necessary to link with logger.o
|
// Symbols necessary to link with logger.o
|
||||||
bool send_request(void *c, const char *msg, ...) { return false; }
|
bool send_request(void *c, const char *msg, ...) { return false; }
|
||||||
struct splay_tree_t *connection_tree = NULL;
|
struct list_t *connection_list = NULL;
|
||||||
bool send_meta(void *c, const char *msg , int len) { return false; }
|
bool send_meta(void *c, const char *msg , int len) { return false; }
|
||||||
char *logfilename = NULL;
|
char *logfilename = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue