Merge branch 'bugfix/esp_netif_ppp_setdefault_fix' into 'master'

ESP-NETIF: Set default interface for ppp netif must be called from lw_ip context

Closes IDFGH-2672

See merge request espressif/esp-idf!7555
This commit is contained in:
David Čermák
2020-03-20 14:50:41 +08:00
4 changed files with 44 additions and 10 deletions

View File

@@ -47,8 +47,10 @@
#define ESP_NETIF_HOSTNAME_MAX_SIZE 32
/**
* @brief lwip thread safe tcpip function utility macro
* @brief lwip thread safe tcpip function utility macros
*/
#define _RUN_IN_LWIP_TASK(function, netif, param) { return esp_netif_lwip_ipc_call(function, netif, (void *)(param)); }
#define _RUN_IN_LWIP_TASK_IF_SUPPORTED(function, netif, param) \
{ \
if (netif->is_ppp_netif) { \
@@ -140,6 +142,8 @@ static esp_netif_t* esp_netif_is_active(esp_netif_t *arg)
* @brief This function sets default netif no matter which implementation used
*
* @param esp_netif handle to network interface
*
* @note: This function must be called from lwip thread
*/
static void esp_netif_set_default_netif(esp_netif_t *esp_netif)
{
@@ -151,14 +155,17 @@ static void esp_netif_set_default_netif(esp_netif_t *esp_netif)
}
/**
* @brief This function sets default routing netif based on priorities of all interfaces which are up
* @param esp_netif current interface which just updated state
* @param action updating action (on-off)
*
* @note: This function must be called from lwip thread
* @brief tcpip thread version of esp_netif_update_default_netif
*
* @note This function and all functions called from this must be called from lwip task context
*/
static void esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_action_t action) {
static esp_err_t esp_netif_update_default_netif_lwip(esp_netif_api_msg_t *msg)
{
esp_netif_t *esp_netif = msg->esp_netif;
esp_netif_action_t action = (esp_netif_action_t)msg->data;
ESP_LOGD(TAG, "%s %p", __func__, esp_netif);
switch (action) {
case ESP_NETIF_STARTED:
{
@@ -200,6 +207,18 @@ static void esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_act
}
break;
}
return ESP_OK;
}
/**
* @brief This function sets default routing netif based on priorities of all interfaces which are up
*
* @param esp_netif current interface which just updated state
* @param action updating action (on-off)
*/
static esp_err_t esp_netif_update_default_netif(esp_netif_t *esp_netif, esp_netif_action_t action)
{
return esp_netif_lwip_ipc_call(esp_netif_update_default_netif_lwip, esp_netif, (void*)action);
}
void esp_netif_set_ip4_addr(esp_ip4_addr_t *addr, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
@@ -1080,7 +1099,7 @@ static esp_err_t esp_netif_up_api(esp_netif_api_msg_t *msg)
return ESP_OK;
}
esp_err_t esp_netif_up(esp_netif_t *esp_netif) _RUN_IN_LWIP_TASK_IF_SUPPORTED(esp_netif_up_api, esp_netif, NULL)
esp_err_t esp_netif_up(esp_netif_t *esp_netif) _RUN_IN_LWIP_TASK(esp_netif_up_api, esp_netif, NULL)
static esp_err_t esp_netif_down_api(esp_netif_api_msg_t *msg)
{
@@ -1116,7 +1135,7 @@ static esp_err_t esp_netif_down_api(esp_netif_api_msg_t *msg)
return ESP_OK;
}
esp_err_t esp_netif_down(esp_netif_t *esp_netif) _RUN_IN_LWIP_TASK_IF_SUPPORTED(esp_netif_down_api, esp_netif, NULL)
esp_err_t esp_netif_down(esp_netif_t *esp_netif) _RUN_IN_LWIP_TASK(esp_netif_down_api, esp_netif, NULL)
bool esp_netif_is_netif_up(esp_netif_t *esp_netif)
{