Skip to content
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

[BUG] TCP will release when FTP Client want to connect in FTPD example #14531

Closed
1 task done
SmartIotMaker opened this issue Oct 28, 2024 · 5 comments
Closed
1 task done
Labels
Arch: all Issues that apply to all architectures Area: Applications Issues related to Applications OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working

Comments

@SmartIotMaker
Copy link

Description / Steps to reproduce the issue

  1. Test ESP32-S3-DevKitC-1 v1.0: esp32s3-devkit:sta_softap with CONFIG_EXAMPLES_FTPD=y and CONFIG_NETUTILS_FTPD.

  2. nuttx base on master and last commit is https://github.com/apache/nuttx/commit/204871513486e940fbb29a9a524de9b9e063d3e0

  3. tool chain:

xtensa-esp32s3-elf-gcc -v
Using built-in specs.
COLLECT_GCC=/home/john/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/xtensa-esp-elf-gcc
COLLECT_LTO_WRAPPER=/home/john/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../libexec/gcc/xtensa-esp-elf/14.2.0/lto-wrapper
Target: xtensa-esp-elf
Configured with: /builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=xtensa-esp-elf --prefix=/builds/idf/crosstool-NG/builds/xtensa-esp-elf --exec_prefix=/builds/idf/crosstool-NG/builds/xtensa-esp-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/xtensa-esp-elf/xtensa-esp-elf --with-sysroot=/builds/idf/crosstool-NG/builds/xtensa-esp-elf/xtensa-esp-elf --with-native-system-header-dir=/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG esp-14.2.0_20240906' --disable-__cxa_atexit --enable-cxx-flags=-ffunction-sections --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libstdcxx-verbose --with-gmp=/builds/idf/crosstool-NG/.build/xtensa-esp-elf/buildtools --with-mpfr=/builds/idf/crosstool-NG/.build/xtensa-esp-elf/buildtools --with-mpc=/builds/idf/crosstool-NG/.build/xtensa-esp-elf/buildtools --with-isl=/builds/idf/crosstool-NG/.build/xtensa-esp-elf/buildtools --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-gcov-custom-rtio --enable-libstdcxx-time=yes
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (crosstool-NG esp-14.2.0_20240906)
  1. then flash nuttx.bin and config wifi with wapi psk wlan0 12345678 3;wapi essid wlan0 John 1;renew wlan0
  2. run ftpd with ftpd_start -4 and connect it with ftp client tools.
  3. ftp client will disconnet after input password(usename:root, password:abc123).
  4. dump with WireShark tool and find board release connect after SYN.
  5. shell will print WARNING: Listen canceled while waiting for ACK on port(line 1287 in tcp_imput.c),this means no any listener in list.

after I modify ftpd_session(handle,5000) to ftpd_session(handle, -1) and connect is ok.
follow is the patch:

diff --git a/examples/ftpd/ftpd_main.c b/examples/ftpd/ftpd_main.c
index d1052b50c..208624c1c 100644
--- a/examples/ftpd/ftpd_main.c
+++ b/examples/ftpd/ftpd_main.c
@@ -229,7 +229,7 @@ int ftpd_daemon(int s_argc, char **s_argv)
        * has been started.
        */
 
-      ret = ftpd_session(handle, 5000);
+      ret = ftpd_session(handle, -1);
 
       /* If any interesting happened (i.e., any thing other than a timeout),
        * then report the interesting event.

this change make accept4() will immediately call after listen().

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Ubuntu 24.04

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Applications]

Verification

  • I have verified before submitting the report.
@SmartIotMaker SmartIotMaker added the Type: Bug Something isn't working label Oct 28, 2024
@github-actions github-actions bot added Arch: all Issues that apply to all architectures Area: Applications Issues related to Applications OS: Linux Issues related to Linux (building system, etc) labels Oct 28, 2024
@acassis
Copy link
Contributor

acassis commented Oct 28, 2024

@wengzhe please take a look

@wengzhe
Copy link
Contributor

wengzhe commented Oct 29, 2024

Hi @SmartIotMaker , have you tried to enable CONFIG_NET_TCPBACKLOG? With backlog, the server won't need to accept immediately when client connects.

@SmartIotMaker
Copy link
Author

@wengzhe yes, everything is OK when enable CONFIG_NET_TCPBACKLOG, thank you.
but it is seemingly very strange because only enable log.

@wengzhe
Copy link
Contributor

wengzhe commented Oct 29, 2024

@SmartIotMaker Glad to see your problem solved. The "backlog" is not a "log", you may see it as the second parameter of listen on a socket, which "limit the number of outstanding connections in the socket's listen queue". Without CONFIG_NET_TCPBACKLOG enabled, we won't have a listen queue (which means backlog=0), so we cannot accept clients asynchronously, which causes your problem.

@SmartIotMaker
Copy link
Author

@wengzhe Thank you very much for your explanation. I got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: all Issues that apply to all architectures Area: Applications Issues related to Applications OS: Linux Issues related to Linux (building system, etc) Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants