From a6c149080746c032e3ff99e49acd49efb0c52d8c Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Mon, 21 Mar 2016 14:51:51 +0000 Subject: [PATCH] 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 --- sys/nfs/bootp_subr.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 #include +#include #include #include #include @@ -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");