Open indexds opened 14 hours ago
As said before, I've narrowed down the error to esp_wireguard_netif_create,
static esp_err_t esp_wireguard_netif_create(const wireguard_config_t *config)
{
esp_err_t err;
ip_addr_t ip_addr;
ip_addr_t netmask;
ip_addr_t gateway = IPADDR4_INIT_BYTES(0, 0, 0, 0);
struct wireguardif_init_data wg = {0};
if (!config) {
err = ESP_ERR_INVALID_ARG;
goto fail;
}
/* Setup the WireGuard device structure */
wg.private_key = config->private_key;
wg.listen_port = config->listen_port;
wg.bind_netif = NULL;
ESP_LOGI(TAG, "allowed_ip: %s", config->allowed_ip);
if (ipaddr_aton(config->allowed_ip, &ip_addr) != 1) {
ESP_LOGE(TAG, "ipaddr_aton: invalid allowed_ip: `%s`", config->allowed_ip);
err = ESP_ERR_INVALID_ARG;
goto fail;
}
if (ipaddr_aton(config->allowed_ip_mask, &netmask) != 1) {
ESP_LOGE(TAG, "ipaddr_aton: invalid allowed_ip_mask: `%s`", config->allowed_ip_mask);
err = ESP_ERR_INVALID_ARG;
goto fail;
}
/* Register the new WireGuard network interface with lwIP */
wg_netif = netif_add(
&wg_netif_struct,
ip_2_ip4(&ip_addr),
ip_2_ip4(&netmask),
ip_2_ip4(&gateway),
&wg, &wireguardif_init,
&ip_input);
if (wg_netif == NULL) {
ESP_LOGE(TAG, "netif_add: failed");
err = ESP_FAIL;
goto fail;
}
/* Mark the interface as administratively up, link up flag is set
* automatically when peer connects */
netif_set_up(wg_netif);
err = ESP_OK;
fail:
return err;
}
Specifically, the crash occurs when the interface is being created here:
wg_netif = netif_add(
&wg_netif_struct,
ip_2_ip4(&ip_addr),
ip_2_ip4(&netmask),
ip_2_ip4(&gateway),
&wg, &wireguardif_init,
&ip_input);
if (wg_netif == NULL) {
ESP_LOGE(TAG, "netif_add: failed");
err = ESP_FAIL;
goto fail;
}
We never get to see the "netif_add: failed" error, so clearly the crash occurs inside netif_add..
Hello,
I've been trying to use this component with Rust and I've been met with a crash that has me scratching my head.
The component was imported through the esp component registry like so,
And I can now use this to add the functions exposed in esp_wireguard.h to scope:
Now that this is done I try to initialize wireguard and connect to a remote peer like in the example,
Yet when I run the program, I get a guru meditation error, supposedly implying a null pointer was dereferenced somewhere.
I assume it has something to do with the lwip code but diving into the C implementation reveals little apart from a failure inside the netif_add function that I fail to understand.. Is there something wrong with my code?