net/arp: Improve arp_find() commit 9774d35010 to reduce the amount and frequency of data copies.

This commit is contained in:
Gregory Nutt
2018-08-25 06:47:10 -06:00
parent aa409f46ab
commit 3bf96c8e7e
11 changed files with 94 additions and 55 deletions
+6 -7
View File
@@ -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;
}
}