This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 81325a8a3d45fedcc03dce97c88ff99945ba9f7f Author: chao an <[email protected]> AuthorDate: Sun Nov 27 03:11:22 2022 +0800 net/arp: add link layer check for arp_out/arp_ipin ARP support is only built if the Ethernet link layer is supported. Continue and send the ARP request only if this device uses the Ethernet link layer protocol. Signed-off-by: chao an <[email protected]> --- net/arp/arp_ipin.c | 11 +++++++++++ net/arp/arp_out.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/net/arp/arp_ipin.c b/net/arp/arp_ipin.c index 893f80327a..8803301e28 100644 --- a/net/arp/arp_ipin.c +++ b/net/arp/arp_ipin.c @@ -76,6 +76,17 @@ void arp_ipin(FAR struct net_driver_s *dev) { in_addr_t srcipaddr; + /* ARP support is only built if the Ethernet link layer is supported. + * Continue and send the ARP request only if this device uses the + * Ethernet link layer protocol. + */ + + if (dev->d_lltype != NET_LL_ETHERNET && + dev->d_lltype != NET_LL_IEEE80211) + { + return; + } + /* Only insert/update an entry if the source IP address of the incoming IP * packet comes from a host on the local network. */ diff --git a/net/arp/arp_out.c b/net/arp/arp_out.c index a6dba47420..cf4b57b465 100644 --- a/net/arp/arp_out.c +++ b/net/arp/arp_out.c @@ -137,6 +137,17 @@ void arp_out(FAR struct net_driver_s *dev) in_addr_t destipaddr; int ret; + /* ARP support is only built if the Ethernet link layer is supported. + * Continue and send the ARP request only if this device uses the + * Ethernet link layer protocol. + */ + + if (dev->d_lltype != NET_LL_ETHERNET && + dev->d_lltype != NET_LL_IEEE80211) + { + return; + } + #if defined(CONFIG_NET_PKT) || defined(CONFIG_NET_ARP_SEND) /* Skip sending ARP requests when the frame to be transmitted was * written into a packet socket.
