mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/optimize_lwip_loopback_route' into 'master'
optimize lwip route when loopback open and in "APSTA" mode See merge request !1252
This commit is contained in:
commit
4c97fc04ca
@ -172,12 +172,6 @@ ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
|
|||||||
struct netif *
|
struct netif *
|
||||||
ip4_route(const ip4_addr_t *dest)
|
ip4_route(const ip4_addr_t *dest)
|
||||||
{
|
{
|
||||||
#if ESP_LWIP
|
|
||||||
struct netif *non_default_netif = NULL;
|
|
||||||
#if LWIP_HAVE_LOOPIF
|
|
||||||
struct netif *loop_default_netif = netif_find("lo0");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
|
|
||||||
#if LWIP_MULTICAST_TX_OPTIONS
|
#if LWIP_MULTICAST_TX_OPTIONS
|
||||||
@ -201,23 +195,8 @@ ip4_route(const ip4_addr_t *dest)
|
|||||||
/* return netif on which to forward IP packet */
|
/* return netif on which to forward IP packet */
|
||||||
return netif;
|
return netif;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netif != netif_default){
|
|
||||||
#if LWIP_HAVE_LOOPIF
|
|
||||||
non_default_netif = (netif == loop_default_netif) ? NULL : netif;
|
|
||||||
#else
|
|
||||||
non_default_netif = netif;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ESP_LWIP
|
|
||||||
if (non_default_netif && !ip4_addr_isbroadcast(dest, non_default_netif)){
|
|
||||||
return non_default_netif;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|
||||||
/* loopif is disabled, looopback traffic is passed through any netif */
|
/* loopif is disabled, looopback traffic is passed through any netif */
|
||||||
if (ip4_addr_isloopback(dest)) {
|
if (ip4_addr_isloopback(dest)) {
|
||||||
|
@ -138,6 +138,19 @@ static int tcpip_adapter_ipc_check(tcpip_adapter_api_msg_t *msg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static esp_err_t tcpip_adapter_update_default_netif(void)
|
||||||
|
{
|
||||||
|
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
|
||||||
|
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]);
|
||||||
|
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) {
|
||||||
|
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]);
|
||||||
|
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_AP])) {
|
||||||
|
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_AP]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
|
esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
|
||||||
{
|
{
|
||||||
netif_init_fn netif_init;
|
netif_init_fn netif_init;
|
||||||
@ -176,14 +189,7 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if ap is on, choose ap as default if */
|
tcpip_adapter_update_default_netif();
|
||||||
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_AP])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_AP]);
|
|
||||||
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]);
|
|
||||||
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -245,15 +251,7 @@ esp_err_t tcpip_adapter_stop(tcpip_adapter_if_t tcpip_if)
|
|||||||
|
|
||||||
netif_set_down(esp_netif[tcpip_if]);
|
netif_set_down(esp_netif[tcpip_if]);
|
||||||
netif_remove(esp_netif[tcpip_if]);
|
netif_remove(esp_netif[tcpip_if]);
|
||||||
|
tcpip_adapter_update_default_netif();
|
||||||
/* in ap + sta mode, if stop ap, choose sta as default if */
|
|
||||||
if (tcpip_if == TCPIP_ADAPTER_IF_AP) {
|
|
||||||
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]);
|
|
||||||
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -278,13 +276,7 @@ esp_err_t tcpip_adapter_up(tcpip_adapter_if_t tcpip_if)
|
|||||||
netif_set_up(esp_netif[tcpip_if]);
|
netif_set_up(esp_netif[tcpip_if]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_AP])) {
|
tcpip_adapter_update_default_netif();
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_AP]);
|
|
||||||
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_STA]);
|
|
||||||
} else if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_ETH])) {
|
|
||||||
netif_set_default(esp_netif[TCPIP_ADAPTER_IF_ETH]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user