diff options
author | Ian Lepore <ian@FreeBSD.org> | 2016-03-21 14:51:51 +0000 |
---|---|---|
committer | Ian Lepore <ian@FreeBSD.org> | 2016-03-21 14:51:51 +0000 |
commit | a6c149080746c032e3ff99e49acd49efb0c52d8c (patch) | |
tree | 49de2a72070a6ebf9a2068634077c6af300405bc /sys/nfs | |
parent | 678849441d76825ad21db094455431a2905f3a6b (diff) | |
download | src-a6c149080746c032e3ff99e49acd49efb0c52d8c.tar.gz src-a6c149080746c032e3ff99e49acd49efb0c52d8c.zip |
If the dhcp server provides an interface-mtu option, parse the value and
set that mtu on the interface.
These changes are based on the patch submitted by Robert Blayzor in the
PR, but I changed things around a bit, so the blame for any mistakes
belongs to me.
PR: 187094
Notes
Notes:
svn path=/head/; revision=297149
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/bootp_subr.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index dd76d7ed90b2..7b32802b9183 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/jail.h> #include <sys/kernel.h> #include <sys/sockio.h> @@ -158,6 +159,7 @@ struct bootpc_ifcontext { int dhcpquerytype; /* dhcp type sent */ struct in_addr dhcpserver; int gotdhcpserver; + uint16_t mtu; }; #define TAG_MAXLEN 1024 @@ -199,6 +201,7 @@ struct bootpc_globalcontext { #define TAG_ROUTERS 3 /* Routers (in order of preference) */ #define TAG_HOSTNAME 12 /* Client host name */ #define TAG_ROOT 17 /* Root path */ +#define TAG_INTF_MTU 26 /* Interface MTU Size (RFC2132) */ /* DHCP specific tags */ #define TAG_OVERLOAD 52 /* Option Overload */ @@ -1034,7 +1037,19 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, return (0); } - printf("Adjusted interface %s\n", ifctx->ireq.ifr_name); + printf("Adjusted interface %s", ifctx->ireq.ifr_name); + + /* Do BOOTP interface options */ + if (ifctx->mtu != 0) { + printf(" (MTU=%d%s)", ifctx->mtu, + (ifctx->mtu > 1514) ? "/JUMBO" : ""); + ifr->ifr_mtu = ifctx->mtu; + error = ifioctl(bootp_so, SIOCSIFMTU, (caddr_t) ifr, td); + if (error != 0) + panic("%s: SIOCSIFMTU, error=%d", __func__, error); + } + printf("\n"); + /* * Do enough of ifconfig(8) so that the chosen interface * can talk to the servers. (just set the address) @@ -1522,6 +1537,11 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p[i] = '\0'; } + p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, + TAG_INTF_MTU); + if (p != NULL) { + ifctx->mtu = be16dec(p); + } printf("\n"); |