BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001202 [BusyBox] Documentation major always 02-06-07 21:09 02-08-07 12:42
Reporter regunkov View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version 1.4.x
Summary 0001202: tftp not work
Description http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/networking/tftp.c?rev=17749&r1=16980&r2=17749&diff_format=h [^]
See Line 294 Line 273

#if ENABLE_FEATURE_IPV6
  if (from->sa_family == AF_INET6)
    if (((struct sockaddr_in6*)from)->sin6_port != port)
     goto recv_again;
#endif
  if (from->sa_family == AF_INET)
    if (((struct sockaddr_in*)from)->sin_port != port)
     goto recv_again;
  timeout = 0;

It is not equivalent

  if (sa.sin_port == port) {
    sa.sin_port = from.sin_port;
  }
  if (sa.sin_port == from.sin_port) {
    break;
  }

In exampe. 1474 != 69
Additional Information tftp client 10.0.54.254/8
tftp server 10.0.0.54/8

root@nsg tmp # tftp -g -r nftlroot-ppc.tar.gz 10.0.0.54
tftp: timeout
tftp: timeout
tftp: timeout
tftp: timeout
tftp: timeout
tftp: last timeout

roman ~ # tcpdump host 10.0.54.254 and \! port nfs
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
07:51:23.730535 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ nftlroot-ppc.tar.gz" octet
07:51:23.737704 IP roman.nsg.1474 > 10.0.54.254.1024: UDP, length 516
07:51:28.732612 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ "nftlroot-ppc.tar.gz" octet
07:51:28.735137 IP roman.nsg.1474 > 10.0.54.254.1024: UDP, length 516
07:51:28.735570 IP roman.nsg.1476 > 10.0.54.254.1024: UDP, length 516
07:51:33.729570 arp who-has roman.nsg tell 10.0.54.254
07:51:33.729591 arp reply roman.nsg is-at 00:10:dc:4f:ef:b8 (oui Unknown)
07:51:33.730894 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ "nftlroot-ppc.tar.gz" octet
07:51:33.732963 IP roman.nsg.1478 > 10.0.54.254.1024: UDP, length 516
07:51:33.738930 IP roman.nsg.1476 > 10.0.54.254.1024: UDP, length 516
07:51:38.731085 arp who-has 10.0.54.254 tell roman.nsg
07:51:38.731432 arp reply 10.0.54.254 is-at 00:09:56:12:00:06 (oui Unknown)
07:51:38.739121 IP roman.nsg.1478 > 10.0.54.254.1024: UDP, length 516
07:51:43.740591 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ "nftlroot-ppc.tar.gz" octet
07:51:43.743256 IP roman.nsg.1479 > 10.0.54.254.1024: UDP, length 516
07:51:48.740654 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ "nftlroot-ppc.tar.gz" octet
07:51:48.743262 IP roman.nsg.1480 > 10.0.54.254.1024: UDP, length 516
07:51:48.747518 IP roman.nsg.1479 > 10.0.54.254.1024: UDP, length 516
07:51:53.747728 IP roman.nsg.1480 > 10.0.54.254.1024: UDP, length 516

19 packets captured
38 packets received by filter
0 packets dropped by kernel
Attached Files  1.patch [^] (4,385 bytes) 02-07-07 13:19

- Relationships

- Notes
(0002130)
rockeychu
02-06-07 23:00

You are right. You can correct it with following patch:

Index: tftp.c
===================================================================
--- tftp.c (revision 17803)
+++ tftp.c (working copy)
@@ -132,7 +132,7 @@
 #if ENABLE_FEATURE_TFTP_GET && ENABLE_FEATURE_TFTP_PUT
                const int cmd,
 #endif
- const len_and_sockaddr *peer_lsa,
+ len_and_sockaddr *peer_lsa,
                const char *remotefile, const int localfd,
                unsigned port, int tftp_bufsize)
 {
@@ -265,7 +265,6 @@
                        }

                        /* receive packet */
- recv_again:
                        tv.tv_sec = TFTP_TIMEOUT;
                        tv.tv_usec = 0;

@@ -290,11 +289,11 @@
 #if ENABLE_FEATURE_IPV6
                                if (from->sa_family == AF_INET6)
                                        if (((struct sockaddr_in6*)from)->sin6_port != port)
- goto recv_again;
+ peer_lsa->sin6.sin6_port=((struct sockaddr_in6*)from)->sin6_port;
 #endif
                                if (from->sa_family == AF_INET)
                                        if (((struct sockaddr_in*)from)->sin_port != port)
- goto recv_again;
+ peer_lsa->sin.sin_port=((struct sockaddr_in*)from)->sin_port;
                                timeout = 0;
                                break;
                        case 0:
 
(0002131)
regunkov
02-07-07 00:03
edited on: 02-07-07 00:53

I'm aplay your patch on 1.4.1 manualy. And it's work right now.

ps: How I can fix "Category"? I'm forget change this, when create issue.

 
(0002132)
rockeychu
02-07-07 01:00

Good news.
You can ask the Manager to change "Category" as you wanted.
 
(0002135)
vda
02-07-07 12:49

I don't understand that tcpdump. We are sending a packet to tfpt port (69), but are getting replies from port 1474? Is this okay? wow...

07:51:23.730535 IP 10.0.54.254.1024 > roman.nsg.tftp: 28 RRQ nftlroot-ppc.tar.gz" octet
07:51:23.737704 IP roman.nsg.1474 > 10.0.54.254.1024: UDP, length 516
 
(0002136)
vda
02-07-07 13:20

Please test attached patch. Diffed agains current svn, but probably will apply to 1.4.1
 
(0002138)
rockeychu
02-07-07 18:03

vda's patch still can't work. With his patch, you'll get a port number as -1.

The following patch resovled this problem:

Index: networking/tftp.c
===================================================================
--- networking/tftp.c (revision 17809)
+++ networking/tftp.c (working copy)
@@ -280,7 +280,7 @@
                                unsigned from_port;
                        case 1:
                                from->len = peer_lsa->len;
- memset(from, 0, peer_lsa->len);
+ memset(&from->sa, 0, peer_lsa->len);
                                len = recvfrom(socketfd, rbuf, tftp_bufsize, 0,
                                                        &from->sa, &from->len);
                                if (len < 0) {
 
(0002141)
vda
02-08-07 12:42

Thanks rockeychu, fixed in rev 17823.
 

- Issue History
Date Modified Username Field Change
02-06-07 21:09 regunkov New Issue
02-06-07 21:09 regunkov Status new => assigned
02-06-07 21:09 regunkov Assigned To  => BusyBox
02-06-07 23:00 rockeychu Note Added: 0002130
02-07-07 00:03 regunkov Note Added: 0002131
02-07-07 00:53 regunkov Note Edited: 0002131
02-07-07 01:00 rockeychu Note Added: 0002132
02-07-07 12:49 vda Note Added: 0002135
02-07-07 13:19 vda File Added: 1.patch
02-07-07 13:20 vda Note Added: 0002136
02-07-07 18:03 rockeychu Note Added: 0002138
02-08-07 12:42 vda Status assigned => closed
02-08-07 12:42 vda Note Added: 0002141
02-08-07 12:42 vda Resolution open => fixed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker