./net/net.c - make Microsoft dns servers happy with random_port() numbers
PATCH 1/1 ./net/net.c - make Microsoft dns servers happy with random_port() numbers
For some reason, (which I can't find any documentation on), if U-Boot gives a port number higher than 17500 to a Microsoft DNS server, the server will reply to port 17500, and U-Boot will ignore things (since that isn't the port it asked the DNS server to reply to).
This fixes that by ensuring the random port number is less than 17500.
--- net/net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/net.c +0 -0
@@ -1872,11 +1872,13 @@ void copy_filename (char *dst, char *src, int size) #if defined(CONFIG_CMD_NFS) || defined(CONFIG_CMD_SNTP) ||
defined(CONFIG_CMD_DNS)
/*
- * make port a little random, but use something trivial to compute
+ * make port a little random (1024-17407)
+ * This keeps the math somewhat trivial to compute, and seems to work with
+ * all supported protocols/clients/servers
*/
unsigned int random_port(void)
{
- return 1024 + (get_timer(0) % 0x8000);;
+ return 1024 + (get_timer(0) % 0x4000);
}
#endif
PATCH 1/1 ./net/net.c - make Microsoft dns servers happy with random_port() numbers
Hi Robin,
Quoted 6 lines
For some reason, (which I can't find any documentation on), if U-Boot gives a port number higher than 17500 to a Microsoft DNS server, the server will reply to port 17500, and U-Boot will ignore things (since that isn't the port it asked the DNS server to reply to).
This fixes that by ensuring the random port number is less than 17500.
Can you please put such a comment also in the code? I believe this to be useful information when studying the code and not only when going through changelogs.
Thanks
Detlev
Signature · 5 lines
Microsoft gives you windows, Linux gives you the whole house. -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Ben Warren
AppliedPATCH 1/1 ./net/net.c - make Microsoft dns servers happy with random_port() numbers
In reply to Robin GetzHi Robin,
Quoted 25 lines · Robin Getz
For some reason, (which I can't find any documentation on), if U-Boot gives a port number higher than 17500 to a Microsoft DNS server, the server will reply to port 17500, and U-Boot will ignore things (since that isn't the port it asked the DNS server to reply to).
This fixes that by ensuring the random port number is less than 17500.
Signed-off-by Robin Getz<[email protected]>--- net/net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/net.c +0
-1@@ -1872,11 +1872,13 @@ void copy_filename (char *dst, char *src, int size)#if defined(CONFIG_CMD_NFS ) || defined(CONFIG_CMD_SNTP ) || defined(CONFIG_CMD_DNS )/* -* make port a little random, but use something trivial to compute
net/net.c void copy_filename (char *dst, char *src, int size) · line 1884
Quoted 10 lines
net/net.c +4
-1+* make port a little random (1024-17407) +* This keeps the math somewhat trivial to compute, and seems to work with +* all supported protocols/clients/servers */ unsigned int random_port (void ) { -return 1024 + (get_timer (0 ) %0x8000 );; +return 1024 + (get_timer (0 ) %0x4000 ); }#endif
Applied to net repo.
thanks,
Ben