Module Name:    src
Committed By:   roy
Date:           Thu May  7 00:01:31 UTC 2009

Modified Files:
        src/sys/arch/sparc/stand/ofwboot: net.c version

Log Message:
Make 3 attempts at bootp before trying bootparams which allows slow
bridges a chance to work.
Clear variables when changing bootp/bootparams.
Displayed variables are cleaned up so they don't overflow the right of
the screen.

ok: martin


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc/stand/ofwboot/net.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/stand/ofwboot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc/stand/ofwboot/net.c
diff -u src/sys/arch/sparc/stand/ofwboot/net.c:1.4 src/sys/arch/sparc/stand/ofwboot/net.c:1.5
--- src/sys/arch/sparc/stand/ofwboot/net.c:1.4	Mon May 12 11:16:31 2008
+++ src/sys/arch/sparc/stand/ofwboot/net.c	Thu May  7 00:01:31 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: net.c,v 1.4 2008/05/12 11:16:31 mlelstv Exp $	*/
+/*	$NetBSD: net.c,v 1.5 2009/05/07 00:01:31 roy Exp $	*/
 
 /*
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -116,24 +116,31 @@
 		}
 }
 
+static void
+net_clear_params(void)
+{
+	
+	myip.s_addr = 0;
+	netmask = 0;
+	gateip.s_addr = 0;
+	*hostname = '\0';
+	rootip.s_addr = 0;
+	*rootpath = '\0';
+}
+
 int
 net_mountroot_bootparams(void)
 {
 
+	net_clear_params();
+
 	/* Get our IP address.  (rarp.c) */
 	if (rarp_getipaddress(netdev_sock) == -1)
 		return (errno);
-
-	printf("Using BOOTPARAMS protocol: ");
-	printf("ip address: %s", inet_ntoa(myip));
-
-	/* Get our hostname, server IP address. */
+	printf("Using BOOTPARAMS protocol:\n  ip addr=%s\n", inet_ntoa(myip));
 	if (bp_whoami(netdev_sock))
 		return (errno);
-
-	printf(", hostname: %s\n", hostname);
-
-	/* Get the root pathname. */
+	printf("  hostname=%s\n", hostname);
 	if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
 		return (errno);
 
@@ -143,22 +150,27 @@
 int
 net_mountroot_bootp(void)
 {
+	int attempts;
 
-	bootp(netdev_sock);
-
+	/* We need a few attempts here as some DHCP servers
+	 * require >1 packet and my wireless bridge is always
+	 * in learning mode until the 2nd attempt ... */
+	for (attempts = 0; attempts < 3; attempts++) {
+		net_clear_params();
+		bootp(netdev_sock);
+		if (myip.s_addr != 0)
+			break;
+	}
 	if (myip.s_addr == 0)
 		return(ENOENT);
 
-	printf("Using BOOTP protocol: ");
-	printf("ip address: %s", inet_ntoa(myip));
-
+	printf("Using BOOTP protocol:\n ip addr=%s\n", inet_ntoa(myip));
 	if (hostname[0])
-		printf(", hostname: %s", hostname);
+		printf("  hostname=%s\n", hostname);
 	if (netmask)
-		printf(", netmask: %s", intoa(netmask));
+		printf("  netmask=%s\n", intoa(netmask));
 	if (gateip.s_addr)
-		printf(", gateway: %s", inet_ntoa(gateip));
-	printf("\n");
+		printf("  gateway=%s\n", inet_ntoa(gateip));
 
 	return (0);
 }
@@ -167,22 +179,10 @@
 net_tftp_bootp(int **sock)
 {
 
-	bootp(netdev_sock);
-
+	net_mountroot_bootp();
 	if (myip.s_addr == 0)
 		return(ENOENT);
 
-	printf("Using BOOTP protocol: ");
-	printf("ip address: %s", inet_ntoa(myip));
-
-	if (hostname[0])
-		printf(", hostname: %s", hostname);
-	if (netmask)
-		printf(", netmask: %s", intoa(netmask));
-	if (gateip.s_addr)
-		printf(", gateway: %s", inet_ntoa(gateip));
-	printf("\n");
-
 	*sock = &netdev_sock;
 	return (0);
 }
@@ -211,7 +211,7 @@
 	if (error != 0)
 		return (error);
 
-	printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
+	printf("  root addr=%s\n  path=%s\n", inet_ntoa(rootip), rootpath);
 
 	/* Get the NFS file handle (mount). */
 	if (nfs_mount(netdev_sock, rootip, rootpath) != 0)

Index: src/sys/arch/sparc/stand/ofwboot/version
diff -u src/sys/arch/sparc/stand/ofwboot/version:1.16 src/sys/arch/sparc/stand/ofwboot/version:1.17
--- src/sys/arch/sparc/stand/ofwboot/version:1.16	Mon Aug 25 22:31:12 2008
+++ src/sys/arch/sparc/stand/ofwboot/version	Thu May  7 00:01:31 2009
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.16 2008/08/25 22:31:12 martin Exp $
+$NetBSD: version,v 1.17 2009/05/07 00:01:31 roy Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -17,3 +17,4 @@
 1.11:	Improve partition handling and allow changing the device at the boot prompt
 1.12:	Add support to boot from newer Solaris UFS partitions
 1.13:	Deal with kernels missing a separate read-only text segment
+1.14:	Make 3 attempts at BOOTP/DHCP for to allow for bridges and clear prior data read

Reply via email to