mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: dhcp: Fix return value on ctrl-c
@ 2013-05-14  9:58 Sascha Hauer
  2013-05-14  9:58 ` [PATCH 2/2] net: dhcp: Fix tftp servername handling Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2013-05-14  9:58 UTC (permalink / raw)
  To: barebox

the dhcp command will return with 0 when ctrl-c is pressed. Fix this to
-EINTR instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 net/dhcp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 8233ec3..7324c94 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -767,8 +767,10 @@ static int do_dhcp(int argc, char *argv[])
 		goto out1;
 
 	while (dhcp_state != BOUND) {
-		if (ctrlc())
-			break;
+		if (ctrlc()) {
+			ret = -EINTR;
+			goto out1;
+		}
 		if (!retries) {
 			ret = -ETIMEDOUT;
 			goto out1;
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] net: dhcp: Fix tftp servername handling
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-05-14  9:58 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-14  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-14  9:58 [PATCH 1/2] net: dhcp: Fix return value on ctrl-c Sascha Hauer
2013-05-14  9:58 ` [PATCH 2/2] net: dhcp: Fix tftp servername handling Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox