Handle UDP packets from different and ports than advertised.
Previously, tinc used a fixed address and port for each node for UDP packet exchange. The port was the one advertised by that node as its listening port. However, due to NAT the port might be different. Now, tinc sends a different session key to each node. This way, the sending node can be determined from incoming packets by checking the MAC against all session keys. If a match is found, the address and port for that node are updated.
This commit is contained in:
parent
43fa7283ac
commit
3308d13e7e
9 changed files with 242 additions and 149 deletions
27
src/graph.c
27
src/graph.c
|
|
@ -226,27 +226,8 @@ void sssp_bfs(void)
|
|||
e->to->via = indirect ? n->via : e->to;
|
||||
e->to->options = e->options;
|
||||
|
||||
if(sockaddrcmp(&e->to->address, &e->address)) {
|
||||
node = avl_unlink(node_udp_tree, e->to);
|
||||
sockaddrfree(&e->to->address);
|
||||
sockaddrcpy(&e->to->address, &e->address);
|
||||
|
||||
if(e->to->hostname)
|
||||
free(e->to->hostname);
|
||||
|
||||
e->to->hostname = sockaddr2hostname(&e->to->address);
|
||||
|
||||
if(node)
|
||||
avl_insert_node(node_udp_tree, node);
|
||||
|
||||
if(e->to->options & OPTION_PMTU_DISCOVERY) {
|
||||
e->to->mtuprobes = 0;
|
||||
e->to->minmtu = 0;
|
||||
e->to->maxmtu = MTU;
|
||||
if(e->to->status.validkey)
|
||||
send_mtu_probe(e->to);
|
||||
}
|
||||
}
|
||||
if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN)
|
||||
update_node_udp(e->to, &e->address);
|
||||
|
||||
list_insert_tail(todo_list, e->to);
|
||||
}
|
||||
|
|
@ -269,13 +250,13 @@ void sssp_bfs(void)
|
|||
if(n->status.reachable) {
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"),
|
||||
n->name, n->hostname);
|
||||
avl_insert(node_udp_tree, n);
|
||||
} else {
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became unreachable"),
|
||||
n->name, n->hostname);
|
||||
avl_delete(node_udp_tree, n);
|
||||
}
|
||||
|
||||
/* TODO: only clear status.validkey if node is unreachable? */
|
||||
|
||||
n->status.validkey = false;
|
||||
n->status.waitingforkey = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue