MFC pxe fixes

Jose M Rodriguez josemi at freebsd.jazztel.es
Wed May 4 00:09:39 PDT 2005


El Jueves, 28 de Abril de 2005 15:42, Jose M Rodriguez escribió:
> Hi,
>
> I note that the long standing bug that prevents do a nfsroot mount
> after operate pxeloader in tftp mode is recent solved in -CURRENT
> pxe.c
>
> I think this can be missed for 5.4 REL, but I'll be glad to see this
> MFC as time permitting.
>

I pointing to changes in revs 1.21 and 1.22 of 
src/sys/boot/i386/libi386/pxe.c

In special, rev 1.21, from kan, 7 weeks ago.

I can't see this breaking any ABI, but making things work as documented.  
Tested on RELENG_5_4 as attached patch

--
  josemi

--- pxe.diff begins here ---
Index: pxe.c
===================================================================
RCS file: /home/cvs/freebsd/src/sys/boot/i386/libi386/pxe.c,v
retrieving revision 1.20
diff -u -r1.20 pxe.c
--- pxe.c	25 Aug 2003 23:28:31 -0000	1.20
+++ pxe.c	28 Apr 2005 17:49:35 -0000
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/pxe.c,v 1.20 2003/08/25 
23:28:31 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/pxe.c,v 1.22 2005/04/17 
21:38:22 wollman Exp $");
 
 #include <stand.h>
 #include <string.h>
@@ -308,6 +308,7 @@
 		}
 		setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
 		setenv("boot.nfsroot.path", rootpath, 1);
+		setenv("dhcp.host-name", hostname, 1);
 	}
     }
     pxe_opens++;
@@ -413,6 +414,22 @@
 	/* structure truncated here */
 };
 extern struct	nfs_iodesc nfs_root_node;
+extern int      rpc_port;
+
+static void
+pxe_rpcmountcall()
+{
+	struct	iodesc *d;
+	int     error;
+
+	if (!(d = socktodesc(pxe_sock)))
+		return;
+        d->myport = htons(--rpc_port);
+        d->destip = rootip;
+	if ((error = nfs_getrootfh(d, rootpath, nfs_root_node.fh)) != 0) 
+		printf("NFS MOUNT RPC error: %d\n", error);
+	nfs_root_node.iodesc = d;
+}
 
 static void
 pxe_setnfshandle(char *rootpath)
@@ -421,6 +438,14 @@
 	u_char	*fh;
 	char	buf[2 * NFS_FHSIZE + 3], *cp;
 
+	/*
+	 * If NFS files were never opened, we need to do mount call
+	 * ourselves. Use nfs_root_node.iodesc as flag indicating
+	 * previous NFS usage.
+	 */
+	if (nfs_root_node.iodesc == NULL)
+		pxe_rpcmountcall();
+
 	fh = &nfs_root_node.fh[0];
 	buf[0] = 'X';
 	cp = &buf[1];
--- pxe.diff ends here ---


More information about the freebsd-stable mailing list