Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 May 2017 19:23:58 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317886 - in head: lib/libstand sys/boot/common sys/boot/i386/libi386
Message-ID:  <201705061923.v46JNwvG011568@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Sat May  6 19:23:58 2017
New Revision: 317886
URL: https://svnweb.freebsd.org/changeset/base/317886

Log:
  distinguish NFS versus TFTP boot by rootpath
  
  Don't use DHCP 150 option to decide which protocol use to netboot. When
  root-path includes ip address - go thru NFS, if ip address not exists in
  root-path - go thru TFTP from server which ip address is in next-server.  But
  there is one limitation - only one tftp server in network to provide loader and
  everything else.  Does enybody use more than only one?
  
  Submitted by:	kczekirda
  Sponsored by:	Oktawave
  MFC after:	3 weeks
  Relnote:	Yes
  Differential Revision:	https://reviews.freebsd.org/D8740

Modified:
  head/lib/libstand/bootp.c
  head/lib/libstand/bootp.h
  head/lib/libstand/globals.c
  head/lib/libstand/net.h
  head/sys/boot/common/dev_net.c
  head/sys/boot/i386/libi386/pxe.c

Modified: head/lib/libstand/bootp.c
==============================================================================
--- head/lib/libstand/bootp.c	Sat May  6 18:35:01 2017	(r317885)
+++ head/lib/libstand/bootp.c	Sat May  6 19:23:58 2017	(r317886)
@@ -148,16 +148,15 @@ bootp(sock, flag)
 		bp->bp_vend[8] = 9;
 		bcopy("PXEClient", &bp->bp_vend[9], 9);
 		bp->bp_vend[18] = TAG_PARAM_REQ;
-		bp->bp_vend[19] = 8;
+		bp->bp_vend[19] = 7;
 		bp->bp_vend[20] = TAG_ROOTPATH;
-		bp->bp_vend[21] = TAG_TFTP_SERVER;
-		bp->bp_vend[22] = TAG_HOSTNAME;
-		bp->bp_vend[23] = TAG_SWAPSERVER;
-		bp->bp_vend[24] = TAG_GATEWAY;
-		bp->bp_vend[25] = TAG_SUBNET_MASK;
-		bp->bp_vend[26] = TAG_INTF_MTU;
-		bp->bp_vend[27] = TAG_SERVERID;
-		bp->bp_vend[28] = TAG_END;
+		bp->bp_vend[21] = TAG_HOSTNAME;
+		bp->bp_vend[22] = TAG_SWAPSERVER;
+		bp->bp_vend[23] = TAG_GATEWAY;
+		bp->bp_vend[24] = TAG_SUBNET_MASK;
+		bp->bp_vend[25] = TAG_INTF_MTU;
+		bp->bp_vend[26] = TAG_SERVERID;
+		bp->bp_vend[27] = TAG_END;
 	} else
 		bp->bp_vend[7] = TAG_END;
 #else
@@ -438,10 +437,6 @@ vend_rfc1048(cp, len)
 			bcopy(cp, &dhcp_serverip.s_addr,
 			      sizeof(dhcp_serverip.s_addr));
 		}
-		if (tag == TAG_TFTP_SERVER) {
-			bcopy(cp, &tftpip.s_addr,
-			      sizeof(tftpip.s_addr));
-		}
 #endif
 		cp += size;
 	}

Modified: head/lib/libstand/bootp.h
==============================================================================
--- head/lib/libstand/bootp.h	Sat May  6 18:35:01 2017	(r317885)
+++ head/lib/libstand/bootp.h	Sat May  6 19:23:58 2017	(r317886)
@@ -108,7 +108,6 @@ struct bootp {
 #define TAG_T2			((unsigned char)  59)
 #define TAG_CLASSID		((unsigned char)  60)
 #define TAG_CLIENTID		((unsigned char)  61)
-#define TAG_TFTP_SERVER		((unsigned char) 150)
 #endif
 
 #define TAG_END			((unsigned char) 255)

Modified: head/lib/libstand/globals.c
==============================================================================
--- head/lib/libstand/globals.c	Sat May  6 18:35:01 2017	(r317885)
+++ head/lib/libstand/globals.c	Sat May  6 19:23:58 2017	(r317886)
@@ -32,7 +32,6 @@ struct	in_addr nameip;			/* DNS server i
 struct	in_addr rootip;			/* root ip address */
 struct	in_addr swapip;			/* swap ip address */
 struct	in_addr gateip;			/* gateway ip address */
-struct	in_addr tftpip;			/* TFTP ip address */
 n_long	netmask = 0xffffff00;		/* subnet or net mask */
 u_int	intf_mtu;			/* interface mtu from bootp/dhcp */
 int	errno;				/* our old friend */

Modified: head/lib/libstand/net.h
==============================================================================
--- head/lib/libstand/net.h	Sat May  6 18:35:01 2017	(r317885)
+++ head/lib/libstand/net.h	Sat May  6 19:23:58 2017	(r317886)
@@ -91,7 +91,6 @@ extern	struct in_addr rootip;
 extern	struct in_addr swapip;
 extern	struct in_addr gateip;
 extern	struct in_addr nameip;
-extern	struct in_addr tftpip;
 extern	n_long netmask;
 extern	u_int intf_mtu;
 

Modified: head/sys/boot/common/dev_net.c
==============================================================================
--- head/sys/boot/common/dev_net.c	Sat May  6 18:35:01 2017	(r317885)
+++ head/sys/boot/common/dev_net.c	Sat May  6 19:23:58 2017	(r317886)
@@ -312,8 +312,11 @@ net_getparams(int sock)
 		return (EIO);
 	}
 exit:
-	if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
+	netproto = NET_TFTP;
+	if ((rootaddr = net_parse_rootpath()) != INADDR_NONE) {
+		netproto = NET_NFS;
 		rootip.s_addr = rootaddr;
+	}
 
 #ifdef	NETIF_DEBUG
 	if (debug) {
@@ -365,13 +368,6 @@ net_parse_rootpath()
 	int i;
 	n_long addr = INADDR_NONE;
 
-	netproto = NET_NFS;
-
-	if (tftpip.s_addr != 0) {
-		netproto = NET_TFTP;
-		addr = tftpip.s_addr;
-	}
-
 	for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
 		if (rootpath[i] == ':')
 			break;

Modified: head/sys/boot/i386/libi386/pxe.c
==============================================================================
--- head/sys/boot/i386/libi386/pxe.c	Sat May  6 18:35:01 2017	(r317885)
+++ head/sys/boot/i386/libi386/pxe.c	Sat May  6 19:23:58 2017	(r317886)
@@ -309,13 +309,9 @@ pxe_open(struct open_file *f, ...)
 			if (servip.s_addr == 0)
 				servip = rootip;
 
-			netproto = NET_NFS;
-			if (tftpip.s_addr != 0) {
-				netproto = NET_TFTP;
-				rootip.s_addr = tftpip.s_addr;
-			}
+			netproto = NET_TFTP;
 
-			if (netproto == NET_NFS && !rootpath[0])
+			if (!rootpath[0])
 				strcpy(rootpath, PXENFSROOTPATH);
 
 			for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
@@ -323,8 +319,10 @@ pxe_open(struct open_file *f, ...)
 					break;
 			if (i && i != FNAME_SIZE && rootpath[i] == ':') {
 				rootpath[i++] = '\0';
-				if (inet_addr(&rootpath[0]) != INADDR_NONE)
+				if (inet_addr(&rootpath[0]) != INADDR_NONE) {
+					netproto = NET_NFS;
 					rootip.s_addr = inet_addr(&rootpath[0]);
+				}
 				bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i]) + 1);
 				bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i]) + 1);
 			}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705061923.v46JNwvG011568>