aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2016-03-21 14:58:12 +0000
committerIan Lepore <ian@FreeBSD.org>2016-03-21 14:58:12 +0000
commit00f66a52368ec96de809d1a7a1f73f0fbed9b817 (patch)
tree7fc4e90f878fc66ed2ccdfe2aa6cb6cc0d9f069e
parenta6c149080746c032e3ff99e49acd49efb0c52d8c (diff)
downloadsrc-00f66a52368ec96de809d1a7a1f73f0fbed9b817.tar.gz
src-00f66a52368ec96de809d1a7a1f73f0fbed9b817.zip
If the dhcp server delivers an interface-mtu option, parse it and store
the value in a new global intf_mtu for use by the application. These changes were inspired by the patch provided by Robert Blayzor in PR 187094, and will allow loader(8) to propagate the value to the kernel along with the other nfs_diskless parms delivered via environment vars.
Notes
Notes: svn path=/head/; revision=297150
-rw-r--r--lib/libstand/bootp.c8
-rw-r--r--lib/libstand/bootp.h1
-rw-r--r--lib/libstand/globals.c1
-rw-r--r--lib/libstand/net.h1
4 files changed, 11 insertions, 0 deletions
diff --git a/lib/libstand/bootp.c b/lib/libstand/bootp.c
index 1af7bd5da113..f3bc81697911 100644
--- a/lib/libstand/bootp.c
+++ b/lib/libstand/bootp.c
@@ -39,6 +39,7 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <sys/endian.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -393,6 +394,13 @@ vend_rfc1048(cp, len)
val = (const char *)cp;
strlcpy(hostname, val, sizeof(hostname));
}
+ if (tag == TAG_INTF_MTU) {
+ if ((val = getenv("dhcp.interface-mtu")) != NULL) {
+ intf_mtu = (u_int)strtoul(val, NULL, 0);
+ } else {
+ intf_mtu = be16dec(cp);
+ }
+ }
#ifdef SUPPORT_DHCP
if (tag == TAG_DHCP_MSGTYPE) {
if(*cp != expected_dhcpmsgtype)
diff --git a/lib/libstand/bootp.h b/lib/libstand/bootp.h
index ed9101f3ea89..47e5649ce9a0 100644
--- a/lib/libstand/bootp.h
+++ b/lib/libstand/bootp.h
@@ -91,6 +91,7 @@ struct bootp {
#define TAG_DOMAINNAME ((unsigned char) 15)
#define TAG_SWAPSERVER ((unsigned char) 16)
#define TAG_ROOTPATH ((unsigned char) 17)
+#define TAG_INTF_MTU ((unsigned char) 26)
#ifdef SUPPORT_DHCP
#define TAG_REQ_ADDR ((unsigned char) 50)
diff --git a/lib/libstand/globals.c b/lib/libstand/globals.c
index 03108232fff0..8284fae71d10 100644
--- a/lib/libstand/globals.c
+++ b/lib/libstand/globals.c
@@ -32,5 +32,6 @@ struct in_addr rootip; /* root ip address */
struct in_addr swapip; /* swap ip address */
struct in_addr gateip; /* swap ip address */
n_long netmask = 0xffffff00; /* subnet or net mask */
+u_int intf_mtu; /* interface mtu from bootp/dhcp */
int errno; /* our old friend */
diff --git a/lib/libstand/net.h b/lib/libstand/net.h
index 94f2aabf81e2..ce7df49f2de2 100644
--- a/lib/libstand/net.h
+++ b/lib/libstand/net.h
@@ -83,6 +83,7 @@ extern struct in_addr swapip;
extern struct in_addr gateip;
extern struct in_addr nameip;
extern n_long netmask;
+extern u_int intf_mtu;
extern int debug; /* defined in the machdep sources */