Invalidate UDP information on address changes.
[tinc] / src / node.c
index 2f51744..0cb2445 100644 (file)
@@ -50,9 +50,9 @@ void exit_nodes(void) {
 }
 
 node_t *new_node(void) {
-       node_t *n = xmalloc_and_zero(sizeof *n);
+       node_t *n = xzalloc(sizeof *n);
 
-       if(replaywin) n->late = xmalloc_and_zero(replaywin);
+       if(replaywin) n->late = xzalloc(replaywin);
        n->subnet_tree = new_subnet_tree();
        n->edge_tree = new_edge_tree();
        n->mtu = MTU;
@@ -140,6 +140,13 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) {
                n->hostname = sockaddr2hostname(&n->address);
                logger(DEBUG_PROTOCOL, LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        }
+
+       /* invalidate UDP information - note that this is a security feature as well to make sure
+          we can't be tricked into flooding any random address with UDP packets */
+       n->status.udp_confirmed = false;
+       n->mtuprobes = 0;
+       n->minmtu = 0;
+       n->maxmtu = MTU;
 }
 
 bool dump_nodes(connection_t *c) {