mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-09-08 10:10:05 +00:00
arp: Return ERR_MEM on ARP queue full
Root Cause: When the ARP cache table is filled, when a new packet comes in, the ARP cache table will be emptied. Solution: If the ARP cache table is full, ERR_MEM is returned. picked from espressif/esp-lwip@602d25c5 Ref IDF-4849
This commit is contained in:
@@ -48,8 +48,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cp ${CONTRIB}/examples/example_app/lwipcfg.h.example ${CONTRIB}/examples/example_app/lwipcfg.h
|
cp ${CONTRIB}/examples/example_app/lwipcfg.h.example ${CONTRIB}/examples/example_app/lwipcfg.h
|
||||||
cd ${CONTRIB}/ports/unix/example_app
|
cd ${CONTRIB}/ports/unix/example_app
|
||||||
export CFLAGS="-DESP_LWIP=LWIP_NETCONN_FULLDUPLEX -DESP_LWIP_IGMP_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_MLD6_TIMERS_ONDEMAND=ESP_LWIP -DESP_DNS=ESP_LWIP"
|
export CFLAGS="-DESP_LWIP=LWIP_NETCONN_FULLDUPLEX -DESP_LWIP_IGMP_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_MLD6_TIMERS_ONDEMAND=ESP_LWIP -DESP_DNS=ESP_LWIP -DESP_LWIP_ARP=ESP_LWIP"
|
||||||
export LWIPDIR=../../../../src/
|
export LWIPDIR=../../../../src/
|
||||||
|
make TESTFLAGS="-Wno-documentation" -j 4
|
||||||
chmod +x iteropts.sh && ./iteropts.sh
|
chmod +x iteropts.sh && ./iteropts.sh
|
||||||
|
|
||||||
- name: Build and run unit tests with cmake
|
- name: Build and run unit tests with cmake
|
||||||
|
|||||||
@@ -1037,12 +1037,12 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
|||||||
/* allocate a new arp queue entry */
|
/* allocate a new arp queue entry */
|
||||||
new_entry = (struct etharp_q_entry *)memp_malloc(MEMP_ARP_QUEUE);
|
new_entry = (struct etharp_q_entry *)memp_malloc(MEMP_ARP_QUEUE);
|
||||||
if (new_entry != NULL) {
|
if (new_entry != NULL) {
|
||||||
|
struct etharp_q_entry *r;
|
||||||
unsigned int qlen = 0;
|
unsigned int qlen = 0;
|
||||||
new_entry->next = 0;
|
new_entry->next = 0;
|
||||||
new_entry->p = p;
|
new_entry->p = p;
|
||||||
if (arp_table[i].q != NULL) {
|
if (arp_table[i].q != NULL) {
|
||||||
/* queue was already existent, append the new entry to the end */
|
/* queue was already existent, append the new entry to the end */
|
||||||
struct etharp_q_entry *r;
|
|
||||||
r = arp_table[i].q;
|
r = arp_table[i].q;
|
||||||
qlen++;
|
qlen++;
|
||||||
while (r->next != NULL) {
|
while (r->next != NULL) {
|
||||||
@@ -1056,11 +1056,19 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
|||||||
}
|
}
|
||||||
#if ARP_QUEUE_LEN
|
#if ARP_QUEUE_LEN
|
||||||
if (qlen >= ARP_QUEUE_LEN) {
|
if (qlen >= ARP_QUEUE_LEN) {
|
||||||
|
#if ESP_LWIP_ARP
|
||||||
|
r->next = NULL;
|
||||||
|
pbuf_free(new_entry->p);
|
||||||
|
memp_free(MEMP_ARP_QUEUE, new_entry);
|
||||||
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue the packet %p (queue is full)\n", (void *)q));
|
||||||
|
return ERR_MEM;
|
||||||
|
#else
|
||||||
struct etharp_q_entry *old;
|
struct etharp_q_entry *old;
|
||||||
old = arp_table[i].q;
|
old = arp_table[i].q;
|
||||||
arp_table[i].q = arp_table[i].q->next;
|
arp_table[i].q = arp_table[i].q->next;
|
||||||
pbuf_free(old->p);
|
pbuf_free(old->p);
|
||||||
memp_free(MEMP_ARP_QUEUE, old);
|
memp_free(MEMP_ARP_QUEUE, old);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"U16_F"\n", (void *)q, i));
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"U16_F"\n", (void *)q, i));
|
||||||
|
|||||||
Reference in New Issue
Block a user