From a33098aed9805f78ecd23c2936ecdbd588b60c62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 27 May 2015 17:59:35 +0300
Subject: [PATCH] do not establish shortcut entry if cie code indicates failure

---
 nhrp/nhrp_peer.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nhrp/nhrp_peer.c b/nhrp/nhrp_peer.c
index 9f8f45f..8aa7a64 100644
--- a/nhrp/nhrp_peer.c
+++ b/nhrp/nhrp_peer.c
@@ -1210,14 +1210,18 @@ static void nhrp_peer_handle_resolution_reply(void *ctx,
 	if (cie == NULL)
 		goto ret;
 
-	nhrp_info("Received Resolution Reply %s/%d is at proto %s nbma %s",
+	nhrp_info("Received Resolution Reply %s/%d is at proto %s nbma %s (code %d)",
 		  nhrp_address_format(&peer->protocol_address,
 				      sizeof(dst), dst),
 		  cie->hdr.prefix_length,
 		  nhrp_address_format(&cie->protocol_address,
 				      sizeof(tmp), tmp),
 		  nhrp_address_format(&cie->nbma_address,
-				      sizeof(nbma), nbma));
+				      sizeof(nbma), nbma),
+		  cie->hdr.code);
+
+	if (cie->hdr.code != NHRP_CODE_SUCCESS)
+		goto ret;
 
 	payload = nhrp_packet_extension(reply,
 					NHRP_EXTENSION_NAT_ADDRESS |
-- 
2.4.6

