-
Notifications
You must be signed in to change notification settings - Fork 175
Component/net connect #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
1. move resource allocation from xxx_init to xxx_new 2. fix enabling tx checksum insertion by mistake 3. iperf example: enlarge max arguments 4. add examples for spi-ethernet Closes espressif/esp-idf#3715 Closes espressif/esp-idf#3711
This fixes the issue that if Wi-Fi is stopped from a shutdown handler, the code in connect.c tries to reconnect, and fails because Wi-Fi is already stopped. Also make the error check in connect.c less strict.
OpenCores Ethernet MAC has a relatively simple interface, and is already supported in QEMU. This makes it a good candidate for enabling network support when running IDF apps in QEMU, compared to the relatively more complex task of writing a QEMU model of ESP32 EMAC. This driver is written with QEMU in mind: it does not implement or handle things that aren't implemented or handled in the QEMU model: error flags, error interrupts. The transmit part of the driver also assumes that the TX operation is done immediately when the TX descriptor is written (which is the case with QEMU), hence waiting for the TX operation to complete is not necessary. For simplicity, the driver assumes that the peripheral register occupy the same memory range as the ESP32 EMAC registers, and the same interrupt source number is used.
instead of tcpip_adapter
… tests to pass the CI
…sal interface defined by if handle and callback
1. move netif glue into single file 2. add reference counter for Ethernet driver
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver possible to work when cache disabled Closes espressif/esp-idf#4406
Closes IDF-1115
examples: enable IPv6 in example common connect for esp32s2 Closes IDF-1115 See merge request espressif/esp-idf!7879
Deprecated esp_vfs_dev_uart_xxx APIs vfs_uart test case moved to esp_driver_uart test_apps Astyle fixed for uart_vfs
fix(examples): Make esp_eth public dependency of protocol_examples_comon See merge request espressif/esp-idf!28618
…ments Fixed memory leak in emac_esp_new_dma function. Polished ESP EMAC cache management. Added emac_periph definitions based on SoC features and improved(generalized) ESP EMAC GPIO initialization. Added ESP EMAC GPIO reservation. Added check for frame error condition indicated by EMAC DMA and created a target test.
* Add MQTT test configuration with WiFi on ESP32-P4 * Document esp_wifi_remote workflow in the example's README
…nd stop reconnecting
…ore roaming disconnect - Common component's wifi disconnect handler should ignore roaming disconnect (WIFI_REASON_ROAMING) as connect gets issued internally in these cases.
…once Function example_configure_stdin_stdout() was used for simple UART I/O operation in CI to enter test env configuration (wifi ssid, IPs, etc). It could be called multiple times, but didn't handle the situation where we install UART interrupt from multiple source (e.g. in ICMP tests, where we first need to enter wifi credentials of test AP and then we start ping-cmd console to handle ping commands)
remove leftover dependencies on `driver` component See merge request espressif/esp-idf!33548
The intention of the code block was to set MAC address for SPI Ethernet modules, however !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET also affected the case of CONFIG_EXAMPLE_USE_OPENETH. This commit corrects the code to match the original intention. Related to espressif/qemu#107
…for the protocol examples
feat(protocol_examples_common): Add Thread connect to support Thread for the protocol examples See merge request espressif/esp-idf!34892
…them On wifi-disconnect (after all retries), we signal to the IP semaphores and delete them immediately, while the wait thread might be still holding on them causing: ``` I (1682) example_connect: Waiting for IP(s) I (4092) example_connect: Wi-Fi disconnected 201, trying to reconnect... I (6502) example_connect: WiFi Connect failed 2 times, stop reconnect. assert failed: spinlock_acquire spinlock.h:142 (lock->count == 0) ```
…t interrupt Update example for polling mode, without interrupt pin
Added example to net_connect component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| wifi_config.sta.channel = (uint8_t)(connect_args.channel->ival[0]); | ||
| } | ||
| const char *ssid = connect_args.ssid->sval[0]; | ||
| const char *pass = connect_args.password->sval[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unchecked Optional Argument Causes Undefined Behavior
Accessing connect_args.password->sval[0] without checking connect_args.password->count first causes undefined behavior when password is not provided. Since password is defined as arg_str0 (optional argument), the code must verify count > 0 before dereferencing sval[0], similar to how other optional arguments are handled in the codebase.
| // run getaddrinfo() to decide on the IP protocol | ||
| hints.ai_family = AF_UNSPEC; | ||
| hints.ai_socktype = sock_type; | ||
| hints.ai_protocol = IPPROTO_TCP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Protocol Mismatch Breaks UDP Address Resolution
Hardcoding hints.ai_protocol = IPPROTO_TCP ignores the sock_type parameter. When sock_type is SOCK_DGRAM, the protocol should be IPPROTO_UDP or left unspecified to let getaddrinfo infer it from ai_socktype. This causes UDP socket address resolution to potentially fail or behave incorrectly.
|
|
||
| char *rest = NULL; | ||
| char *temp = strtok_r(buf, " ", &rest); | ||
| strncpy((char*)wifi_config.sta.ssid, temp, sizeof(wifi_config.sta.ssid)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Null Pointer Crash on Empty Input
Null pointer dereference when strtok_r returns NULL. If the user enters only whitespace or an empty line, strtok_r at line 225 returns NULL, causing strncpy at line 226 to crash with a null pointer dereference. The code should verify temp is not NULL before using it.
| ESP_ERROR_CHECK(uart_set_pin(UART_NUM_1, CONFIG_NET_CONNECT_CONNECT_UART_TX_PIN, CONFIG_NET_CONNECT_CONNECT_UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); | ||
| ESP_ERROR_CHECK(uart_set_rx_timeout(UART_NUM_1, 1)); | ||
|
|
||
| char *buffer = (char*)malloc(BUF_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unchecked Memory Allocation Leads to Instability
Missing null check after malloc(BUF_SIZE). If memory allocation fails, buffer will be NULL, causing crashes when used in subsequent operations like uart_read_bytes and ESP_LOG_BUFFER_HEXDUMP. The code should verify allocation succeeded before proceeding.
| s_stop_task = false; | ||
| if (xTaskCreate(ppp_task, "ppp connect", 4096, NULL, 5, NULL) != pdTRUE) { | ||
| ESP_LOGE(TAG, "Failed to create a ppp connection task"); | ||
| return ESP_FAIL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| esp_err_t ret = esp_wifi_connect(); | ||
| if (ret != ESP_OK) { | ||
| ESP_LOGE(TAG, "WiFi connect failed! ret:%x", ret); | ||
| return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Connection Failure Causes Resource Leaks
Resource leak when esp_wifi_connect fails. Event handlers registered at lines 149-154 are not unregistered before returning, and if wait is true, the semaphores created at lines 136-145 are not deleted. This causes handle and memory leaks on connection failure.
Description
Related
Testing
Checklist
Before submitting a Pull Request, please ensure the following:
Note
Introduces a new net_connect component with unified APIs and Kconfig for WiFi, Ethernet, Thread, and PPP connectivity, plus minor code-style cleanups across examples and components.
net_connect(),net_disconnect(),net_get_netif_from_desc(),net_configure_stdin_stdout(), URI encode/decode helpers, stdin IP resolver.wifi_connect,wifi_disconnect).Kconfig.projbuild,CMakeLists.txt,idf_component.yml,README.mddescribing usage and setup.Written by Cursor Bugbot for commit 24d6b84. This will update automatically on new commits. Configure here.