From 19392a6d2b5eee26ba62fcc6f61e769b4cebaa32 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 19 Dec 2023 12:31:37 +0200 Subject: [PATCH] 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 --- subsys/net/ip/ipv4.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/net/ip/ipv4.c b/subsys/net/ip/ipv4.c index e873ab82650..1c40d8f1788 100644 --- a/subsys/net/ip/ipv4.c +++ b/subsys/net/ip/ipv4.c @@ -299,6 +299,11 @@ enum net_verdict net_ipv4_input(struct net_pkt *pkt, bool is_loopback) 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)) {