summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2017-03-20 14:53:25 +0200
committerGordon Ross <gwr@nexenta.com>2017-04-02 19:35:11 -0400
commit7ee17e4e3475b9853902250ffd15561b2ab6780e (patch)
tree9004d4951a23e2e440d41b1987fa60a19425ac0b
parente4874eaac5b46e37d15ab25089733219a80a96e6 (diff)
downloadillumos-joyent-7ee17e4e3475b9853902250ffd15561b2ab6780e.tar.gz
7987 loader: pxeboot should avoid unnecessary DHCP request
Reviewed by: Yuri Pankov <yuri.pankov@gmail.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Dan McDonald <danmcd@omniti.com> Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/lib/libstand/bootp.c12
-rw-r--r--usr/src/boot/lib/libstand/bootp.h8
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/pxe.c28
4 files changed, 43 insertions, 7 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 0a3c013869..60ad7be601 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2017.3.26.1
+BOOT_VERSION = $(LOADER_VERSION)-2017.3.29.1
diff --git a/usr/src/boot/lib/libstand/bootp.c b/usr/src/boot/lib/libstand/bootp.c
index d1d4378bab..effe074dce 100644
--- a/usr/src/boot/lib/libstand/bootp.c
+++ b/usr/src/boot/lib/libstand/bootp.c
@@ -36,7 +36,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/limits.h>
@@ -336,6 +335,17 @@ bad:
return (-1);
}
+int
+dhcp_try_rfc1048(uint8_t *cp, size_t len)
+{
+
+ expected_dhcpmsgtype = DHCPACK;
+ if (bcmp(vm_rfc1048, cp, sizeof (vm_rfc1048)) == 0) {
+ return (vend_rfc1048(cp, len));
+ }
+ return (-1);
+}
+
static int
vend_rfc1048(u_char *cp, u_int len)
{
diff --git a/usr/src/boot/lib/libstand/bootp.h b/usr/src/boot/lib/libstand/bootp.h
index bdafefd8d2..6ed7032c0e 100644
--- a/usr/src/boot/lib/libstand/bootp.h
+++ b/usr/src/boot/lib/libstand/bootp.h
@@ -18,10 +18,10 @@
* University. Carnegie Mellon makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
- *
- * $FreeBSD$
*/
+#ifndef _BOOTP_H_
+#define _BOOTP_H_
struct bootp {
unsigned char bp_op; /* packet opcode type */
@@ -145,3 +145,7 @@ struct cmu_vend {
/* v_flags values */
#define VF_SMASK 1 /* Subnet mask field contains valid data */
+
+int dhcp_try_rfc1048(uint8_t *cp, size_t len);
+
+#endif /* _BOOTP_H_ */
diff --git a/usr/src/boot/sys/boot/i386/libi386/pxe.c b/usr/src/boot/sys/boot/i386/libi386/pxe.c
index 7069b83cd7..59d0cb5b30 100644
--- a/usr/src/boot/sys/boot/i386/libi386/pxe.c
+++ b/usr/src/boot/sys/boot/i386/libi386/pxe.c
@@ -96,6 +96,7 @@ extern void __bangpxeentry(void);
extern u_int16_t __pxenvseg;
extern u_int16_t __pxenvoff;
extern void __pxenventry(void);
+extern struct in_addr servip;
struct netif_dif pxe_ifs[] = {
/* dif_unit dif_nsel dif_stats dif_private */
@@ -256,7 +257,7 @@ pxe_open(struct open_file *f, ...)
char temp[FNAME_SIZE];
int error = 0;
int i;
-
+
va_start(args, f);
devname = va_arg(args, char*);
va_end(args);
@@ -272,17 +273,35 @@ pxe_open(struct open_file *f, ...)
}
if (pxe_debug)
printf("pxe_open: netif_open() succeeded\n");
+ if (socktodesc(pxe_sock) == NULL) {
+ printf("pxe_open: bad socket %d\n", pxe_sock);
+ return (ENXIO);
+ }
}
if (rootip.s_addr == 0) {
/*
- * Do a bootp/dhcp request to find out where our
+ * Try to extract the RFC1048 data from PXE.
+ * Otherwise do a bootp/dhcp request to find out where our
* NFS/TFTP server is. Even if we dont get back
* the proper information, fall back to the server
* which brought us to life and a default rootpath.
*/
- bootp(pxe_sock, BOOTP_PXE);
+ if (dhcp_try_rfc1048(bootplayer.vendor.d, BOOTP_DHCPVEND) < 0) {
+ if (pxe_debug)
+ printf("pxe_open: no RFC1048 data in PXE Cache\n");
+ bootp(pxe_sock, BOOTP_PXE);
+ } else if (pxe_debug) {
+ printf("pxe_open: loaded RFC1048 data from PXE Cache\n");
+ }
+
if (rootip.s_addr == 0)
rootip.s_addr = bootplayer.sip;
+ if (gateip.s_addr == 0)
+ gateip.s_addr = bootplayer.gip;
+ if (myip.s_addr == 0)
+ myip.s_addr = bootplayer.yip;
+ if (servip.s_addr == 0)
+ servip = rootip;
netproto = NET_NFS;
if (tftpip.s_addr != 0) {
@@ -320,6 +339,9 @@ pxe_open(struct open_file *f, ...)
printf("pxe_open: server addr: %s\n", inet_ntoa(rootip));
printf("pxe_open: server path: %s\n", rootpath);
printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip));
+ printf("pxe_open: my ip: %s\n", inet_ntoa(myip));
+ printf("pxe_open: netmask: %s\n", intoa(netmask));
+ printf("pxe_open: servip: %s\n", inet_ntoa(servip));
if (netproto == NET_TFTP) {
setenv("boot.tftproot.server", inet_ntoa(rootip), 1);