From: Guus Sliepen Date: Fri, 15 May 2015 21:08:53 +0000 (+0200) Subject: Be more liberal accepting ADD_EDGE messages with conflicting local address information. X-Git-Tag: release-1.1pre12~161 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=54a8bd78e3fbe2de4d9daea748643f9c9b5b240e;p=tinc Be more liberal accepting ADD_EDGE messages with conflicting local address information. If the ADD_EDGE is for one of the edges we own, and if it is not the same as we actually have, send a correcting ADD_EDGE back. Otherwise, if the ADD_EDGE contains new information, update our idea of the local address for that edge. If the ADD_EDGE does not contain local address information, then we never make a correction nor log a warning. --- diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 43e32364..76e6eb48 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -125,7 +125,7 @@ bool add_edge_h(connection_t *c, const char *request) { e = lookup_edge(from, to); if(e) { - if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address) || sockaddrcmp(&e->local_address, &local_address)) { + if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) { if(from == myself) { logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", "ADD_EDGE", c->name, c->hostname); @@ -137,6 +137,28 @@ bool add_edge_h(connection_t *c, const char *request) { edge_del(e); graph(); } + } else if(sockaddrcmp(&e->local_address, &local_address)) { + if(from == myself) { + if(e->local_address.sa.sa_family && local_address.sa.sa_family) { + // Someone has the wrong local address for ourself. Correct then. + logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", + "ADD_EDGE", c->name, c->hostname); + send_add_edge(c, e); + return true; + } + // Otherwise, just ignore it. + return true; + } else if(local_address.sa.sa_family) { + // We learned a new local address for this edge. + sockaddrfree(&e->local_address); + e->local_address = local_address; + + // Tell others about it. + if(!tunnelserver) + forward_request(c, request); + + return true; + } } else return true; } else if(from == myself) {