net: loopback: Skip neighbor checks for local packets

No need to do any IPv6 neighbor checks if the packet is routed back
to us by loopback driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c
index b4cf61a..eb2b699 100644
--- a/subsys/net/ip/net_if.c
+++ b/subsys/net/ip/net_if.c
@@ -278,6 +278,15 @@
 		net_pkt_ll_src(pkt)->len = net_pkt_ll_if(pkt)->len;
 	}
 
+#if defined(CONFIG_NET_LOOPBACK)
+	/* If the packet is destined back to us, then there is no need to do
+	 * additional checks, so let the packet through.
+	 */
+	if (iface->l2 == &NET_L2_GET_NAME(DUMMY)) {
+		goto send;
+	}
+#endif
+
 #if defined(CONFIG_NET_IPV6)
 	/* If the ll dst address is not set check if it is present in the nbr
 	 * cache.
@@ -291,6 +300,9 @@
 	}
 #endif
 
+#if defined(CONFIG_NET_LOOPBACK)
+send:
+#endif
 	verdict = iface->l2->send(iface, pkt);
 
 done: