Remember whether we sent our key to another node.

In tinc 1.0.x, this was tracked in node->inkey, however in tinc 1.1 we have an abstraction layer for
the legacy cipher and digest, and we don't keep an explicit copy of the key around. We cannot use
cipher_active() or digest_active(), since it is possible to set both to the null algorithm. So add a bit to
node_status_t.
This commit is contained in:
Guus Sliepen 2015-01-10 22:26:33 +01:00
parent f1f2df0738
commit 6056f1c13b
4 changed files with 7 additions and 2 deletions

View file

@ -302,7 +302,7 @@ static bool receive_udppacket(node_t *n, vpn_packet_t *inpkt) {
#ifdef DISABLE_LEGACY #ifdef DISABLE_LEGACY
return false; return false;
#else #else
if(!n->status.validkey) { if(!n->status.validkey_in) {
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", n->name, n->hostname); logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", n->name, n->hostname);
return false; return false;
} }

View file

@ -319,6 +319,8 @@ static void keyexpire_handler(void *data) {
void regenerate_key(void) { void regenerate_key(void) {
logger(DEBUG_STATUS, LOG_INFO, "Expiring symmetric keys"); logger(DEBUG_STATUS, LOG_INFO, "Expiring symmetric keys");
send_key_changed(); send_key_changed();
for splay_each(node_t, n, node_tree)
n->status.validkey_in = false;
} }
/* /*

View file

@ -38,7 +38,8 @@ typedef struct node_status_t {
unsigned int sptps:1; /* 1 if this node supports SPTPS */ unsigned int sptps:1; /* 1 if this node supports SPTPS */
unsigned int udp_confirmed:1; /* 1 if the address is one that we received UDP traffic on */ unsigned int udp_confirmed:1; /* 1 if the address is one that we received UDP traffic on */
unsigned int send_locally:1; /* 1 if the next UDP packet should be sent on the local network */ unsigned int send_locally:1; /* 1 if the next UDP packet should be sent on the local network */
unsigned int unused:23; unsigned int validkey_in; /* 1 if we have sent a valid key to him */
unsigned int unused:22;
} node_status_t; } node_status_t;
typedef struct node_t { typedef struct node_t {

View file

@ -303,6 +303,8 @@ bool send_ans_key(node_t *to) {
to->received = 0; to->received = 0;
if(replaywin) memset(to->late, 0, replaywin); if(replaywin) memset(to->late, 0, replaywin);
to->status.validkey_in = true;
return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY, return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY,
myself->name, to->name, key, myself->name, to->name, key,
cipher_get_nid(to->incipher), cipher_get_nid(to->incipher),