net: ipv4: Drop packet if source address is my address
If we receive a packet where the source address is our own
address, then we should drop it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 19392a6d2b5eee26ba62fcc6f61e769b4cebaa32)
diff --git a/subsys/net/ip/ipv4.c b/subsys/net/ip/ipv4.c
index 6f4dd8c..d39566f 100644
--- a/subsys/net/ip/ipv4.c
+++ b/subsys/net/ip/ipv4.c
@@ -286,6 +286,11 @@
NET_DBG("DROP: localhost packet");
goto drop;
}
+
+ if (net_ipv4_is_my_addr((struct in_addr *)hdr->src)) {
+ NET_DBG("DROP: src addr is %s", "mine");
+ goto drop;
+ }
}
if (net_ipv4_is_addr_mcast((struct in_addr *)hdr->src)) {