esp_wireguard
esp_wireguard copied to clipboard
Crash When remote server goes down
I have a strange scenario. I am connected to a server/endpoint and all is working as expected. The server/endpoint then goes down, and I stop receiving traffic.
I then call esp_wireguardif_peer_is_up() to see if it is still available, but this causes a crash The crash is due to the following assert failing
esp_wireguardif_peer_is_up() -> wireguardif_peer_is_up() wireguardif_peer_is_up() -> wireguardif_lookup_peer()
This assert fails due to netif being NULL
static err_t wireguardif_lookup_peer(struct netif *netif, u8_t peer_index, struct wireguard_peer **out) {
LWIP_ASSERT("netif != NULL", (netif != NULL));
I put a simple fix into this function, to check that ctx->netif is non NULL
esp_err_t esp_wireguardif_peer_is_up(wireguard_ctx_t *ctx)
{
...
if (!ctx->netif) {
err = ESP_ERR_INVALID_ARG;
goto fail;
}
I don't understand enough about this code, but this solves my problem, what I do not understand is why is ctx->netif==NULL ? All I do to get to this state, is to take down the remote wireguard after connection has been established
Thx Lee