mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
net/arp: Improve arp_find() commit 9774d35010 to reduce the amount and frequency of data copies.
This commit is contained in:
@@ -1259,7 +1259,7 @@ static int netdev_arp_ioctl(FAR struct socket *psock, int cmd,
|
||||
|
||||
/* Find the existing ARP table entry for this protocol address. */
|
||||
|
||||
FAR struct arp_entry *entry = arp_lookup(addr->sin_addr.s_addr);
|
||||
FAR struct arp_entry_s *entry = arp_lookup(addr->sin_addr.s_addr);
|
||||
if (entry != NULL)
|
||||
{
|
||||
/* The ARP table is fixed size; an entry is deleted
|
||||
@@ -1287,19 +1287,18 @@ static int netdev_arp_ioctl(FAR struct socket *psock, int cmd,
|
||||
{
|
||||
FAR struct sockaddr_in *addr =
|
||||
(FAR struct sockaddr_in *)&req->arp_pa;
|
||||
struct arp_entry entry;
|
||||
|
||||
/* Find the existing ARP table entry for this protocol address. */
|
||||
/* Get the hardware address from an existing ARP table entry
|
||||
* matching this protocol address.
|
||||
*/
|
||||
|
||||
ret = arp_find(addr->sin_addr.s_addr, &entry);
|
||||
ret = arp_find(addr->sin_addr.s_addr,
|
||||
(FAR struct ether_addr *)req->arp_ha.sa_data);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Return the mapped hardware address. */
|
||||
|
||||
req->arp_ha.sa_family = ARPHRD_ETHER;
|
||||
memcpy(req->arp_ha.sa_data,
|
||||
entry.at_ethaddr.ether_addr_octet,
|
||||
ETHER_ADDR_LEN);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user