GideonZ / 1541ultimate

Official GIT archive of 1541 ultimate II sources
GNU General Public License v3.0
173 stars 45 forks source link

repeated cycles accessing telnet and FTP will fail #364

Open classilla opened 11 months ago

classilla commented 11 months ago

After 10 cycles of FTPing a file to the storage and then running it from the Telnet server, FTP will suddenly become unresponsive. You can trigger it by repeating a command line like

curl -T u2rtc.prg ftp://bil/Temp/u2rtc.prg ; echo x | nc bil 23

10 times. On the 11th time, the FTP portion will time out until the cartridge is powered off and back on. Ultimate-II Plus 3.10f (11D) on a U2+L.

Grrrolf commented 11 months ago

The latest version of the firmware is version 3.10j .

What happens if you do not do a 10-times consecutive overwrite of the same file but upload 11 different files?

GideonZ commented 10 months ago

I tried to replicate this by issuing wput commands from the command line, and was unable to reproduce it. However, there is always a bit of time between the commands given. Maybe I should try this in a batch file.

classilla commented 10 months ago

You have to alternate Telnet with FTP; repeated back-to-back FTP transactions work fine. The workflow here is uploading a file, then connecting with Telnet to make the Commodore run it.

The file doesn't matter, it can be different or the same. It also behaves the same whether writing to Usb0 or to Temp.

scjody commented 8 months ago

I can reproduce this with 3.10j on an U2+L without using ftp at all. The first 12 telnet connections succeed and show the usual menu. After that, the connection is established but is immediately closed by the U2. I haven't found a way out of this state other than power off / power on.

Looking at the packets in Wireshark, the first 12 connections appear normal. With the failing connection, the usual 3-way handshake happens, the client sends a packet with telnet options (or a \n in the nc example below), and the U2 responds with 2 or 3 RST packets, closing the connection.

Running this nc command 13 times will demonstrate the issue: echo | nc -v c64 23 For a oneliner:

for s in `seq 1 13` ; do echo | nc -v c64 23 ; done

I also tried adding a long sleep (e.g. sleep 60) to the for loop above and it still fails.

scjody commented 7 months ago

I'm unable to reproduce this with ftp at all. It seems to be just a telnet issue. 12 telnets, with or without ftp commands in between, will reliably break the network stack such that any new connections (ftp or telnet) result in 2-3 immediate RST packets rather than a successful connection.

GideonZ commented 7 months ago

Can confirm. It seems that the telnet port is not correctly closed. The 12th telnet connection fails. Always. (Tried with 3.10a) The 11th telnet connection fails. Always. (Tried with 3.11-alpha)

(Which is logical, as 3.11 has an additional listener on port 80.)

Message ID: @.***>

scjody commented 7 months ago

Using lwip_close() (which is what ftpd does) instead of shutdown() fixes the issue - see https://github.com/GideonZ/1541ultimate/pull/382