Try all known addresses of node during the PMTU discovery phase.
This helps in situations where some nodes have IPv6 and others have not.
This commit is contained in:
parent
0ed0cc6f9c
commit
58f4b845b9
4 changed files with 68 additions and 24 deletions
|
|
@ -208,6 +208,7 @@ static void check_reachability(void) {
|
||||||
}
|
}
|
||||||
n->last_req_key = 0;
|
n->last_req_key = 0;
|
||||||
|
|
||||||
|
n->status.udp_confirmed = false;
|
||||||
n->maxmtu = MTU;
|
n->maxmtu = MTU;
|
||||||
n->minmtu = 0;
|
n->minmtu = 0;
|
||||||
n->mtuprobes = 0;
|
n->mtuprobes = 0;
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ static int info_node(int fd, const char *item) {
|
||||||
printf(" indirect");
|
printf(" indirect");
|
||||||
if(status.sptps)
|
if(status.sptps)
|
||||||
printf(" sptps");
|
printf(" sptps");
|
||||||
|
if(status.udp_confirmed)
|
||||||
|
printf(" udp_confirmed");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("Options: ");
|
printf("Options: ");
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ static void send_mtu_probe_handler(int fd, short events, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger(DEBUG_TRAFFIC, LOG_INFO, "%s (%s) did not respond to UDP ping, restarting PMTU discovery", n->name, n->hostname);
|
logger(DEBUG_TRAFFIC, LOG_INFO, "%s (%s) did not respond to UDP ping, restarting PMTU discovery", n->name, n->hostname);
|
||||||
|
n->status.udp_confirmed = false;
|
||||||
n->mtuprobes = 1;
|
n->mtuprobes = 1;
|
||||||
n->minmtu = 0;
|
n->minmtu = 0;
|
||||||
n->maxmtu = MTU;
|
n->maxmtu = MTU;
|
||||||
|
|
@ -166,6 +167,8 @@ static void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
|
||||||
packet->data[0] = 1;
|
packet->data[0] = 1;
|
||||||
send_udppacket(n, packet);
|
send_udppacket(n, packet);
|
||||||
} else {
|
} else {
|
||||||
|
n->status.udp_confirmed = true;
|
||||||
|
|
||||||
if(n->mtuprobes > 30) {
|
if(n->mtuprobes > 30) {
|
||||||
if(n->minmtu)
|
if(n->minmtu)
|
||||||
n->mtuprobes = 30;
|
n->mtuprobes = 30;
|
||||||
|
|
@ -528,42 +531,77 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||||
inpkt->len += digest_length(&n->outdigest);
|
inpkt->len += digest_length(&n->outdigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine which socket we have to use */
|
|
||||||
|
|
||||||
if(n->address.sa.sa_family != listen_socket[n->sock].sa.sa.sa_family) {
|
|
||||||
for(int sock = 0; sock < listen_sockets; sock++) {
|
|
||||||
if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family) {
|
|
||||||
n->sock = sock;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
struct sockaddr *sa;
|
sockaddr_t *sa;
|
||||||
socklen_t sl;
|
|
||||||
int sock;
|
int sock;
|
||||||
|
|
||||||
/* Overloaded use of priority field: -1 means local broadcast */
|
/* Overloaded use of priority field: -1 means local broadcast */
|
||||||
|
|
||||||
if(origpriority == -1 && n->prevedge) {
|
if(origpriority == -1 && n->prevedge) {
|
||||||
struct sockaddr_in in;
|
sockaddr_t broadcast;
|
||||||
in.sin_family = AF_INET;
|
broadcast.in.sin_family = AF_INET;
|
||||||
in.sin_addr.s_addr = -1;
|
broadcast.in.sin_addr.s_addr = -1;
|
||||||
in.sin_port = n->prevedge->address.in.sin_port;
|
broadcast.in.sin_port = n->prevedge->address.in.sin_port;
|
||||||
sa = (struct sockaddr *)∈
|
sa = &broadcast;
|
||||||
sl = sizeof in;
|
|
||||||
sock = 0;
|
sock = 0;
|
||||||
} else {
|
} else {
|
||||||
if(origpriority == -1)
|
if(origpriority == -1)
|
||||||
origpriority = 0;
|
origpriority = 0;
|
||||||
|
|
||||||
sa = &(n->address.sa);
|
if(n->status.udp_confirmed) {
|
||||||
sl = SALEN(n->address.sa);
|
/* Address of this node is confirmed, so use it. */
|
||||||
sock = n->sock;
|
sa = &n->address;
|
||||||
|
sock = n->sock;
|
||||||
|
} else {
|
||||||
|
/* Otherwise, go through the list of known addresses of
|
||||||
|
this node. The first address we try is always the
|
||||||
|
one in n->address; that could be set to the node's
|
||||||
|
reflexive UDP address discovered during key
|
||||||
|
exchange. The other known addresses are those found
|
||||||
|
in edges to this node. */
|
||||||
|
|
||||||
|
static unsigned int i;
|
||||||
|
int j = 0;
|
||||||
|
edge_t *candidate = NULL;
|
||||||
|
|
||||||
|
if(i) {
|
||||||
|
for splay_each(edge_t, e, edge_weight_tree) {
|
||||||
|
if(e->to != n)
|
||||||
|
continue;
|
||||||
|
j++;
|
||||||
|
if(!candidate || j == i)
|
||||||
|
candidate = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!candidate) {
|
||||||
|
sa = &n->address;
|
||||||
|
sock = n->sock;
|
||||||
|
} else {
|
||||||
|
sa = &candidate->address;
|
||||||
|
sock = rand() % listen_sockets;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i++)
|
||||||
|
if(i > j)
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Determine which socket we have to use */
|
||||||
|
|
||||||
|
if(sa->sa.sa_family != listen_socket[sock].sa.sa.sa_family)
|
||||||
|
for(sock = 0; sock < listen_sockets; sock++)
|
||||||
|
if(sa->sa.sa_family == listen_socket[sock].sa.sa.sa_family)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(sock >= listen_sockets)
|
||||||
|
sock = 0;
|
||||||
|
|
||||||
|
if(!n->status.udp_confirmed)
|
||||||
|
n->sock = sock;
|
||||||
|
|
||||||
#if defined(SOL_IP) && defined(IP_TOS)
|
#if defined(SOL_IP) && defined(IP_TOS)
|
||||||
if(priorityinheritance && origpriority != priority
|
if(priorityinheritance && origpriority != priority
|
||||||
&& listen_socket[n->sock].sa.sa.sa_family == AF_INET) {
|
&& listen_socket[n->sock].sa.sa.sa_family == AF_INET) {
|
||||||
|
|
@ -574,7 +612,9 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, sa, sl) < 0 && !sockwouldblock(sockerrno)) {
|
socklen_t sl = SALEN(n->address.sa);
|
||||||
|
|
||||||
|
if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &sa->sa, sl) < 0 && !sockwouldblock(sockerrno)) {
|
||||||
if(sockmsgsize(sockerrno)) {
|
if(sockmsgsize(sockerrno)) {
|
||||||
if(n->maxmtu >= origlen)
|
if(n->maxmtu >= origlen)
|
||||||
n->maxmtu = origlen - 1;
|
n->maxmtu = origlen - 1;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ typedef struct node_status_t {
|
||||||
unsigned int reachable:1; /* 1 if this node is reachable in the graph */
|
unsigned int reachable:1; /* 1 if this node is reachable in the graph */
|
||||||
unsigned int indirect:1; /* 1 if this node is not directly reachable by us */
|
unsigned int indirect:1; /* 1 if this node is not directly reachable by us */
|
||||||
unsigned int sptps:1; /* 1 if this node supports SPTPS */
|
unsigned int sptps:1; /* 1 if this node supports SPTPS */
|
||||||
unsigned int unused:25;
|
unsigned int udp_confirmed:1; /* 1 if the address is one that we received UDP traffic on */
|
||||||
|
unsigned int unused:24;
|
||||||
} node_status_t;
|
} node_status_t;
|
||||||
|
|
||||||
typedef struct node_t {
|
typedef struct node_t {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue