esp_netif/lwip: Use netif-client-data to store esp_netif ptr

lwip/netif struct has two places to store user's data
* netif->state (1 void*) but that might be occupied in special cases
* netif->client_dtat (n void*s) but that must be enabled in opts.h
This commit stores esp_netif_t* primarily in state, but if any special
netif is enabled in menuconfig (bridgeif, pppos), it uses netif->client_data.
This commit also fixes incorrect esp_netif that is attached to
IP_EVENT_GOT_IP6 event posted by pppos interfaces in:
c585618b97/components/esp_netif/lwip/esp_netif_lwip_ppp.c (L114)

Closes https://github.com/espressif/esp-idf/issues/9345
This commit is contained in:
David Cermak
2022-07-15 17:32:52 +02:00
committed by David Čermák
parent 96c29841bb
commit 64f4f0ac1e
7 changed files with 69 additions and 102 deletions

View File

@@ -665,9 +665,21 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
* LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store
* data in client_data member array of struct netif (max. 256).
*/
#ifdef CONFIG_LWIP_NUM_NETIF_CLIENT_DATA
#define LWIP_NUM_NETIF_CLIENT_DATA CONFIG_LWIP_NUM_NETIF_CLIENT_DATA
#ifndef CONFIG_LWIP_NUM_NETIF_CLIENT_DATA
#define CONFIG_LWIP_NUM_NETIF_CLIENT_DATA 0
#endif
#if defined(CONFIG_ESP_NETIF_BRIDGE_EN) || defined(CONFIG_LWIP_PPP_SUPPORT)
/*
* If special lwip interfaces (like bridge, ppp) enabled
* `netif->state` is used internally and we must store esp-netif ptr
* in `netif->client_data`
*/
#define LWIP_ESP_NETIF_DATA (1)
#else
#define LWIP_ESP_NETIF_DATA (0)
#endif
#define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_ESP_NETIF_DATA + CONFIG_LWIP_NUM_NETIF_CLIENT_DATA)
/**
* BRIDGEIF_MAX_PORTS: this is used to create a typedef used for forwarding