summaryrefslogtreecommitdiffstats
path: root/net/dhcp.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-05-14 11:51:22 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-05-14 11:51:24 +0200
commit66691793b091356f4dc081ffe2e942dee7c1cc04 (patch)
tree6f63295203b724759032026148e26dd9b82d6396 /net/dhcp.c
parent37b0cce64dc07c8c266bd2ef4613e0c9069e8aaa (diff)
downloadbarebox-66691793b091356f4dc081ffe2e942dee7c1cc04.tar.gz
barebox-66691793b091356f4dc081ffe2e942dee7c1cc04.tar.xz
net: dhcp: Fix tftp servername handling
When the dhcp code discovered the tftp-server-name option it immediately tries to resolve the name. This can't succeed since the we are somewhere in the dhcp processing and the nameserver may not even be known. Fix this by resolving the name when dhcp is completed. While at it, do this in a way that net_set_serverip is only called when resolv() returns something useful. Otherwise we may end up overwriting a previously configured serverip which came from the bootp bp_siaddr field. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net/dhcp.c')
-rw-r--r--net/dhcp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/dhcp.c b/net/dhcp.c
index 7324c94838..1261b2d73a 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -527,9 +527,6 @@ static void dhcp_options_process(unsigned char *popt, struct bootp *bp)
popt += oplen + 2; /* Process next option */
}
-
- if (dhcp_tftpname[0] != 0)
- net_set_serverip(resolv(dhcp_tftpname));
}
static int dhcp_message_type(unsigned char *popt)
@@ -787,6 +784,12 @@ static int do_dhcp(int argc, char *argv[])
}
}
+ if (dhcp_tftpname[0] != 0) {
+ IPaddr_t tftpserver = resolv(dhcp_tftpname);
+ if (tftpserver)
+ net_set_serverip(tftpserver);
+ }
+
out1:
net_unregister(dhcp_con);
out: