Skip to content

Unexpected reboot after calling wg.end() #18

@kerokerowood

Description

@kerokerowood

Hi, I'm enjoying WireGuard-ESP32@^0.1.5 and thanks for this great library for ESP32. I'm using this library in the following environment:

  • VSCode + PlatformIO (latest) with Arduino framework
  • Issue occurs with any of M5Stack / M5Core2 / M5AtomMatrix

What I am doing is 1) start everything for WireGuard communication, 2) do something thru the tunnel, and 3) stop everything in every cycle in the loop.

        #include <WireGuard-ESP32.h>

        WireGuard wg;
        while(1) {
                Wifi.begin(ssid, pass);
                configTime( parameters );
                wg.begin(  wireguard parameters  );
                  (wait for about 1 second)
                WiFiClient client;  
                     do something thru WireGuard tunnel
                client.stop();
                wg.end();
                WiFi.disconnect();
                vTaskDelay(waitSecond);
        }

The issue is unexpected reboot in void WireGuard::end(). In some cases it happened at every call but in other case at not every call. I could not find any dependencies for these differences. Temporary fix I found in the end is to add net_set_down() just before the netif_remove(). Currently this removes the issue for all the cases I had.

        void WireGuard::end() {
                    :
                netif_set_down(wg_netif);    // <--- temporary fix
                netif_remove(wg_netif);
                wg_netif = nullptr; 

                this->_is_initialized = false;
        }

I'm not sure if it is a correct way or not. So, I would be grateful if you could kindly give me advice about this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions