Merge branch 'master' of black:tinc
This commit is contained in:
commit
1b2846d907
2 changed files with 14 additions and 10 deletions
|
@ -389,7 +389,6 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||||
static int priority = 0;
|
static int priority = 0;
|
||||||
#endif
|
#endif
|
||||||
int origpriority;
|
int origpriority;
|
||||||
int sock;
|
|
||||||
|
|
||||||
if(!n->status.reachable) {
|
if(!n->status.reachable) {
|
||||||
ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname);
|
ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname);
|
||||||
|
@ -476,26 +475,28 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||||
|
|
||||||
/* Determine which socket we have to use */
|
/* Determine which socket we have to use */
|
||||||
|
|
||||||
for(sock = 0; sock < listen_sockets; sock++)
|
if(n->address.sa.sa_family != listen_socket[n->sock].sa.sa.sa_family) {
|
||||||
if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family)
|
for(int sock = 0; sock < listen_sockets; sock++) {
|
||||||
break;
|
if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family) {
|
||||||
|
n->sock = sock;
|
||||||
if(sock >= listen_sockets)
|
break;
|
||||||
sock = 0; /* If none is available, just use the first and hope for the best. */
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
#if defined(SOL_IP) && defined(IP_TOS)
|
#if defined(SOL_IP) && defined(IP_TOS)
|
||||||
if(priorityinheritance && origpriority != priority
|
if(priorityinheritance && origpriority != priority
|
||||||
&& listen_socket[sock].sa.sa.sa_family == AF_INET) {
|
&& listen_socket[n->sock].sa.sa.sa_family == AF_INET) {
|
||||||
priority = origpriority;
|
priority = origpriority;
|
||||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting outgoing packet priority to %d", priority);
|
ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting outgoing packet priority to %d", priority);
|
||||||
if(setsockopt(listen_socket[sock].udp, SOL_IP, IP_TOS, &priority, sizeof(priority))) /* SO_PRIORITY doesn't seem to work */
|
if(setsockopt(listen_socket[n->sock].udp, SOL_IP, IP_TOS, &priority, sizeof(priority))) /* SO_PRIORITY doesn't seem to work */
|
||||||
logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno));
|
logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa)) < 0 && !sockwouldblock(sockerrno)) {
|
if(sendto(listen_socket[n->sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa)) < 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;
|
||||||
|
@ -635,5 +636,7 @@ void handle_incoming_vpn_data(int sock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n->sock = sock;
|
||||||
|
|
||||||
receive_udppacket(n, &pkt);
|
receive_udppacket(n, &pkt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct node_t {
|
||||||
char *name; /* name of this node */
|
char *name; /* name of this node */
|
||||||
uint32_t options; /* options turned on for this node */
|
uint32_t options; /* options turned on for this node */
|
||||||
|
|
||||||
|
int sock; /* Socket to use for outgoing UDP packets */
|
||||||
sockaddr_t address; /* his real (internet) ip to send UDP packets to */
|
sockaddr_t address; /* his real (internet) ip to send UDP packets to */
|
||||||
char *hostname; /* the hostname of its real ip */
|
char *hostname; /* the hostname of its real ip */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue