mpetazzoni/ptftpd

PXE boot - WARNING(tftpd): Error packet received!

robertpenz opened this issue · 6 comments

I've just tried to boot a PC (in this case a virtual one with Intel UNDI, PXE-2.1) from the tftpserver.py and got following output on the server:

WARNING(tftpd): Error packet received!

The client just hang. You can download the Wireshark trace from:

http://robert.penz.name/files/pxeboot_error_packet_received.pcapng

Transferring the packet fails after 12 blocks ... using a tftp Linux client does not give that error

Just redid it with Debugging enabled:

INFO(tftpd): Serving TFTP requests on eth0:69 in /home/robert/tmp/tftp/tftpboot
INFO(tftpd): Serving file pxeboot.0 to host 10.12.138.11...
WARNING(tftpd): Error packet received!
INFO(tftpd): Serving file pxeboot.0 to host 10.12.138.11...
DEBUG(tftpd):   >  DATA: 12 data packet(s) sent.
DEBUG(tftpd):   <   ACK: Transfer complete, 16756 byte(s).
INFO(tftpd): Transfer of file pxeboot.0 completed.

If I start the server with "-r" I also get the error, but 33 packets are delivered, client still hangs.

INFO(tftpd): Serving file pxeboot.0 to host 10.12.138.11...
WARNING(tftpd): Error packet received!
INFO(tftpd): Serving file pxeboot.0 to host 10.12.138.11...
DEBUG(tftpd):   >  DATA: 33 data packet(s) sent.
DEBUG(tftpd):   <   ACK: Transfer complete, 16756 byte(s).
INFO(tftpd): Transfer of file pxeboot.0 completed.

Following URL shows a working PXE boot from the same client with an other TFTP Server (which is not in Python, which is what I need ;-) )

http://robert.penz.name/files/pxeboot_working.pcapng

The problem does not seem to be the "Error packet received!" but that the tftpd sends an malformed packet at the end - at least if Wireshark is correct. not sure why that packet is sent at all, as the working tftpd server does not send it.

I found the bug which leads to the empty packet. That's a bug in the DatagramRequestHandler. Here is the Workaround:

class TFTPServerHandler(SocketServer.DatagramRequestHandler):
...
    def finish(self):
        """ Workaround for following bug: http://bugs.python.org/issue1767511 """
        wdata = self.wfile.getvalue()
        if wdata:
            self.socket.sendto(wdata, self.client_address)

but the client still hangs and I don't know ... here is the new trace:

http://robert.penz.name/files/pxeboot_stillnotworking.pcapng

Ok this last error was on my side ... damaged the file while testing. now it worked for the first file of the boot process and its looking for the next.

Could you send a pull request for the fix to the finish() method if it's required? Thanks!

I've created the pull request. It also contains some improvements to the serveRRQ handler