From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] net: dhcp: Fix tftp servername handling
Date: Tue, 14 May 2013 11:58:17 +0200 [thread overview]
Message-ID: <1368525497-4413-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1368525497-4413-1-git-send-email-s.hauer@pengutronix.de>
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>
---
net/dhcp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/dhcp.c b/net/dhcp.c
index 7324c94..1261b2d 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:
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2013-05-14 9:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 9:58 [PATCH 1/2] net: dhcp: Fix return value on ctrl-c Sascha Hauer
2013-05-14 9:58 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368525497-4413-2-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox