mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-08-26 11:51:31 +00:00
ip6: Add on-demand timer config for IP6 reassembly timer
2.1.3-esp: 9813ea9a lwip:optimization lwip ip6 reassembly timer
This commit is contained in:
@@ -330,6 +330,7 @@ void lwip_example_app_platform_assert(const char *msg, int line, const char *fil
|
||||
#define ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND ESP_LWIP
|
||||
#define ESP_LWIP_DNS_TIMERS_ONDEMAND ESP_LWIP
|
||||
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND ESP_LWIP
|
||||
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND ESP_LWIP
|
||||
#define ESP_DNS ESP_LWIP
|
||||
#define ESP_LWIP_ARP ESP_LWIP
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
#include "stdbool.h"
|
||||
#include "lwip/timeouts.h"
|
||||
static bool s_is_tmr_start = false;
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
|
||||
/** Setting this to 0, you can turn off checking the fragments for overlapping
|
||||
* regions. The code gets a little smaller. Only use this if you know that
|
||||
@@ -109,10 +114,24 @@ static void ip6_reass_free_complete_datagram(struct ip6_reassdata *ipr);
|
||||
static void ip6_reass_remove_oldest_datagram(struct ip6_reassdata *ipr, int pbufs_needed);
|
||||
#endif /* IP_REASS_FREE_OLDEST */
|
||||
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
/**
|
||||
* Wrapper function with matching prototype which calls the actual callback
|
||||
*/
|
||||
static void ip6_reass_timeout_cb(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
ip6_reass_tmr();
|
||||
}
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
|
||||
void
|
||||
ip6_reass_tmr(void)
|
||||
{
|
||||
struct ip6_reassdata *r, *tmp;
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
bool tmr_restart = false;
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
|
||||
#if !IPV6_FRAG_COPYHEADER
|
||||
LWIP_ASSERT("sizeof(struct ip6_reass_helper) <= IP6_FRAG_HLEN, set IPV6_FRAG_COPYHEADER to 1",
|
||||
@@ -126,6 +145,9 @@ ip6_reass_tmr(void)
|
||||
if (r->timer > 0) {
|
||||
r->timer--;
|
||||
r = r->next;
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
tmr_restart = true;
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
} else {
|
||||
/* reassembly timed out */
|
||||
tmp = r;
|
||||
@@ -135,6 +157,14 @@ ip6_reass_tmr(void)
|
||||
ip6_reass_free_complete_datagram(tmp);
|
||||
}
|
||||
}
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
if (tmr_restart) {
|
||||
sys_timeout(IP6_REASS_TMR_INTERVAL, ip6_reass_timeout_cb, NULL);
|
||||
} else {
|
||||
sys_untimeout(ip6_reass_timeout_cb, NULL);
|
||||
s_is_tmr_start = false;
|
||||
}
|
||||
#endif/* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +387,6 @@ ip6_reass(struct pbuf *p)
|
||||
/* enqueue the new structure to the front of the list */
|
||||
ipr->next = reassdatagrams;
|
||||
reassdatagrams = ipr;
|
||||
|
||||
/* Use the current IPv6 header for src/dest address reference.
|
||||
* Eventually, we will replace it when we get the first fragment
|
||||
* (it might be this one, in any case, it is done later). */
|
||||
@@ -660,6 +689,12 @@ ip6_reass(struct pbuf *p)
|
||||
/* Return the pbuf chain */
|
||||
return p;
|
||||
}
|
||||
#if ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
if (!s_is_tmr_start) {
|
||||
sys_timeout(IP6_REASS_TMR_INTERVAL, ip6_reass_timeout_cb, NULL);
|
||||
s_is_tmr_start = true;
|
||||
}
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
/* the datagram is not (yet?) reassembled completely */
|
||||
return NULL;
|
||||
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
|
||||
#endif /* LWIP_DNS */
|
||||
#if LWIP_IPV6
|
||||
{ND6_TMR_INTERVAL, HANDLER(nd6_tmr)},
|
||||
#if LWIP_IPV6_REASS
|
||||
#if LWIP_IPV6_REASS && !ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
{IP6_REASS_TMR_INTERVAL, HANDLER(ip6_reass_tmr)},
|
||||
#endif /* LWIP_IPV6_REASS */
|
||||
#if LWIP_IPV6_MLD && !ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
|
||||
@@ -166,6 +166,7 @@ u32_t esp_random(void);
|
||||
#define ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND 1
|
||||
#define ESP_LWIP_DNS_TIMERS_ONDEMAND 1
|
||||
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND 1
|
||||
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND 1
|
||||
|
||||
#else
|
||||
#define ESP_LWIP 0
|
||||
@@ -185,6 +186,10 @@ u32_t esp_random(void);
|
||||
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND 0
|
||||
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
|
||||
#ifndef ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND 0
|
||||
#endif /* ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND */
|
||||
|
||||
#endif /* ESP_LWIP */
|
||||
|
||||
#endif /* LWIP_HDR_LWIPOPTS_H */
|
||||
|
||||
Reference in New Issue
Block a user