From 6a666a66200091b4dc35cbd85b811ff17d51afa3 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 (cherry picked from commit 19392a6d2b5eee26ba62fcc6f61e769b4cebaa32) --- 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 c400878991f842..bbc5366a904bcc 100644 --- a/subsys/net/ip/ipv4.c +++ b/subsys/net/ip/ipv4.c @@ -272,6 +272,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(&hdr->src)) { + NET_DBG("DROP: src addr is %s", "mine"); + goto drop; + } } if (net_ipv4_is_addr_mcast(&hdr->src)) {