mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-13 02:05:43 +00:00
etharp_query(): Fixed the case where the packet that initiates the ARP request is not queued, and gets lost.
etharp_query(): Fixed the case where the packets destination address is already known. As a result, we now always queue the packet and perform an ARP request, unless the entry is stable and no packet is submitted for transmission.
This commit is contained in:
parent
6d704c728e
commit
2e2dada561
@ -772,9 +772,14 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
}
|
}
|
||||||
else if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
else if (arp_table[i].state == ETHARP_STATE_STABLE) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i));
|
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i));
|
||||||
/* user may wish to queue a packet on a stable entry, so we proceed without ARP requesting */
|
/* User wishes to queue a packet on a stable entry (or does she want to send
|
||||||
/* TODO: even if the ARP entry is stable, we might do an ARP request anyway */
|
* out the packet immediately, we will not know), so we force an ARP request.
|
||||||
perform_arp_request = 0;
|
* Upon response we will send out the queued packet in etharp_update().
|
||||||
|
*
|
||||||
|
* Alternatively, we could accept the stable entry, and just send out the packet
|
||||||
|
* immediately. I chose to implement the former approach.
|
||||||
|
*/
|
||||||
|
perform_arp_request = (q?1:0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -786,18 +791,17 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
|||||||
i = find_arp_entry();
|
i = find_arp_entry();
|
||||||
/* bail out if no ARP entries are available */
|
/* bail out if no ARP entries are available */
|
||||||
if (i == ERR_MEM) {
|
if (i == ERR_MEM) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available. Should seldom occur.\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available. Should seldomly occur.\n"));
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
/* i is available, create ARP entry */
|
/* i is available, create ARP entry */
|
||||||
arp_table[i].state = ETHARP_STATE_PENDING;
|
arp_table[i].state = ETHARP_STATE_PENDING;
|
||||||
ip_addr_set(&arp_table[i].ipaddr, ipaddr);
|
ip_addr_set(&arp_table[i].ipaddr, ipaddr);
|
||||||
/* queried address was already in ARP table */
|
}
|
||||||
} else {
|
/* { i is now valid } */
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING /* queue packet (even on a stable entry, see above) */
|
||||||
etharp_enqueue(i, q);
|
etharp_enqueue(i, q);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
/* ARP request? */
|
/* ARP request? */
|
||||||
if (perform_arp_request)
|
if (perform_arp_request)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user