tests: net: rpl: Fix unicast NS sending

If we send unicast NS, then the destination IPv6 address needs
to be in the neighbor cache, otherwise we have a NS sending loop.

Change-Id: I11e8f5d5740248024a0becc77055786cd2e32199
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
diff --git a/tests/net/rpl/src/main.c b/tests/net/rpl/src/main.c
index 03be28b..0c9beba 100644
--- a/tests/net/rpl/src/main.c
+++ b/tests/net/rpl/src/main.c
@@ -428,9 +428,25 @@
 
 static bool net_test_send_ns(void)
 {
+	struct net_if *iface = net_if_get_default();
+	struct net_nbr *nbr;
 	int ret;
 
-	ret = net_ipv6_send_ns(net_if_get_default(),
+	/* As we are sending a node reachability NS (RFC 4861 ch 4.3),
+	 * we need to add the neighbor to the cache, otherwise we cannot
+	 * send a NS with unicast destination address.
+	 */
+	nbr = net_ipv6_nbr_add(iface,
+			       &in6addr_my,
+			       &iface->link_addr,
+			       false,
+			       NET_NBR_REACHABLE);
+	if (!nbr) {
+		TC_ERROR("Cannot add to neighbor cache\n");
+		return false;
+	}
+
+	ret = net_ipv6_send_ns(iface,
 			       NULL,
 			       &peer_addr,
 			       &in6addr_my,