Subject: Re: diskless booting
To: Dave Sainty <David.Sainty@MCS.VUW.AC.NZ>
From: enami tsugutomo <enami@cv.sony.co.jp>
List: current-users
Date: 05/13/1997 10:26:37
Dave Sainty <David.Sainty@MCS.VUW.AC.NZ> writes:

> The rpc stuff is a little tricky so I'm not sure if I'm missing
> something, is there a way to do this without resorting to bully
> tactics and using IPs that produce the right netmask implicitly, or
> patching the code?

Since I also couldn't find any way to set netmask other than default
mask during diskless booting, I've hard coded it, like below.  I want
to know if there is other clean way...

enami.

following line need to add to config file.
options		NFS_BOOT_NETMASK=IN_CLASSC_NET

Index: nfs_boot.c
===================================================================
RCS file: /cvsroot/NetBSD/src/sys/nfs/nfs_boot.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 nfs_boot.c
--- nfs_boot.c	1997/03/24 01:33:19	1.1.1.5
+++ nfs_boot.c	1997/05/13 01:12:09
@@ -116,6 +116,9 @@
 	struct proc *procp;
 {
 	struct ifreq ireq;
+#ifdef NFS_BOOT_NETMASK
+	struct ifaliasreq iareq;
+#endif
 	struct in_addr my_ip, gw_ip;
 	struct sockaddr_in bp_sin;
 	struct sockaddr_in *sin;
@@ -171,8 +174,22 @@
 
 	/*
 	 * Do enough of ifconfig(8) so that the chosen interface
-	 * can talk to the servers.  (just set the address)
+	 * can talk to the servers.  (just set the address and netmask)
+	 *
+	 * Must do SIOCSIFNETMASK before SIOCSIFADDR.
 	 */
+#ifdef NFS_BOOT_NETMASK
+	bcopy(ifp->if_xname, iareq.ifra_name, IFNAMSIZ);
+	sin = (struct sockaddr_in *)&iareq.ifra_addr;
+	bzero((caddr_t)sin, sizeof(*sin));
+	sin->sin_len = sizeof(*sin);
+	sin->sin_family = AF_INET;
+	sin->sin_addr.s_addr = NFS_BOOT_NETMASK;
+	error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)&iareq, procp);
+	if (error)
+		panic("nfs_boot: set if netmask, error=%d", error);
+#endif
+
 	sin = (struct sockaddr_in *)&ireq.ifr_addr;
 	bzero((caddr_t)sin, sizeof(*sin));
 	sin->sin_len = sizeof(*sin);