From aedbb8c2202d22f0eebe06b99e24afc3dd0637cd Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 19 Sep 2017 14:30:27 +0300 Subject: [PATCH] net: arp: Exit early on zero gateway provided In a case gateway is not set drop packet early otherwise bogus ARPs for 0.0.0.0 are sent. ... [net/arp] [DBG] find_entry: (0xa8006720): dst 0.0.0.0 [net/arp] [DBG] find_entry: (0xa8006720): [0] iface 0xa800cd80 dst 0.0.0.0 ll 00:00:00:00:00:00 pending 0xa800a7c0 [net/arp] [DBG] find_entry: (0xa8006720): ARP already pending to 0.0.0.0 ll 00:00:00:00:00:00 [net/arp] [DBG] net_arp_prepare: (0xa8006720): Resending ARP 0xa800a380 ... Signed-off-by: Andrei Emeltchenko --- subsys/net/ip/l2/arp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subsys/net/ip/l2/arp.c b/subsys/net/ip/l2/arp.c index 97abfaf36a3..aaa647d719f 100644 --- a/subsys/net/ip/l2/arp.c +++ b/subsys/net/ip/l2/arp.c @@ -222,9 +222,13 @@ struct net_pkt *net_arp_prepare(struct net_pkt *pkt) if (!net_if_ipv4_addr_mask_cmp(net_pkt_iface(pkt), &NET_IPV4_HDR(pkt)->dst)) { addr = &net_pkt_iface(pkt)->ipv4.gw; - if (IS_ENABLED(CONFIG_NET_DEBUG_ARP) - && net_is_ipv4_addr_unspecified(addr)) { - NET_ERR("Gateway not set for iface %p", net_pkt_iface(pkt)); + if (net_is_ipv4_addr_unspecified(addr)) { + if (IS_ENABLED(CONFIG_NET_DEBUG_ARP)) { + NET_ERR("Gateway not set for iface %p", + net_pkt_iface(pkt)); + } + + return NULL; } } else { addr = &NET_IPV4_HDR(pkt)->dst;