Commit 5a159579 authored by Julien Muchembled's avatar Julien Muchembled Committed by Juliusz Chroboczek

Fix nodes incorrectly rejecting packets.

Nodes with default mac-verify would not accept packets from nodes with
non-default mac-verify.
Co-authored-by: default avatarJulien Muchembled <jm@jmuchemb.eu>
Co-authored-by: default avatarAntonin Décimo <antonin.decimo@gmail.com>
parent af02039b
......@@ -259,6 +259,7 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
{
int i = bodylen + 4;
int len;
int rc = -1;
debugf("check_hmac %s -> %s\n",
format_address(src), format_address(dst));
......@@ -278,8 +279,9 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
packet + i + 2, len, ifp->key);
if(ok)
return 1;
rc = 0;
}
i += len + 2;
}
return 0;
return rc;
}
......@@ -608,16 +608,21 @@ parse_packet(const unsigned char *from, struct interface *ifp,
bodylen = packetlen - 4;
}
if(ifp->key != NULL && !(ifp->flags & IF_NO_HMAC_VERIFY)) {
if(check_hmac(packet, packetlen, bodylen, from, to, ifp) != 1) {
fprintf(stderr, "Received wrong hmac.\n");
return;
}
neigh = preparse_packet(packet, bodylen, from, ifp);
if(neigh == NULL) {
fputs("Received wrong PC or failed the challenge.\n", stderr);
if(ifp->key != NULL) {
switch(check_hmac(packet, packetlen, bodylen, from, to, ifp)) {
case -1: /* no mac trailer */
if(ifp->flags & IF_NO_HMAC_VERIFY)
break;
/* fallthrough */
case 0:
fputs("Received wrong hmac.\n", stderr);
return;
case 1:
neigh = preparse_packet(packet, bodylen, from, ifp);
if(neigh == NULL) {
fputs("Received wrong PC or failed the challenge.\n", stderr);
return;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment