misc/187094: FreeBSD DHCP ignores dhcp option interface-mtu
Robert Blayzor
rblayzor at inoc.net
Thu Feb 27 19:30:01 UTC 2014
The following reply was made to PR misc/187094; it has been noted by GNATS.
From: Robert Blayzor <rblayzor at inoc.net>
To: "bug-followup at freebsd.org" <bug-followup at FreeBSD.org>
Cc:
Subject: Re: misc/187094: FreeBSD DHCP ignores dhcp option interface-mtu
Date: Thu, 27 Feb 2014 13:24:11 -0500
I would like to submit the following patch that corrects two major issues:
- Look for and set MTU according to DHCP option tag 26 for Interface MTU.
This allows booting interface to be used on a jumbo frame enabled network.
Currently this is broken and cannot be overridden or set later.
- Remove ancient proxy ARP setting. Currently it is more of a problem that
a host is multi-homed and booting interface network may not have a router.
(ie: default route is on another interface/network)
The default today is to use DHCP router tag and if no router tag is
supplied by DHCP, default route will be set to hosts self. Not supplying
a route is a completely valid option, especially since many hosts
multi-homed.
Patch is against 10.0-RELEASE
Index: bootp_subr.c
===================================================================
--- bootp_subr.c (revision 261846)
+++ bootp_subr.c (working copy)
@@ -196,6 +196,8 @@
#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 */
#define TAG_MAXMSGSIZE 57 /* Maximum DHCP Message Size */
@@ -229,6 +231,8 @@
#endif
static char bootp_cookie[128];
+static unsigned int bootp_ifmtu = 0;
+
static struct socket *bootp_so;
SYSCTL_STRING(_kern, OID_AUTO, bootp_cookie, CTLFLAG_RD,
bootp_cookie, 0, "Cookie (T134) supplied by bootp server");
@@ -1030,7 +1034,22 @@
return (0);
}
- printf("Adjusted interface %s\n", ifctx->ireq.ifr_name);
+ printf("Adjusted interface %s", ifctx->ireq.ifr_name);
+
+ /* Do BOOTP interface options */
+ if (bootp_ifmtu != 0) {
+ printf(" (MTU=%d", bootp_ifmtu);
+ if (bootp_ifmtu > 1514)
+ printf("/JUMBO");
+ printf(")");
+
+ ifr->ifr_mtu = bootp_ifmtu;
+ 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)
@@ -1053,7 +1072,12 @@
/* Add new default route */
- if (ifctx->gotgw != 0 || gctx->gotgw == 0) {
+ /* Only set default route if we received one in the request.
+ Proxy ARP considered obsolete. More valid to NOT set
+ a router in request as the host may be multi-homed and
+ gateway may not be on this interface.
+ */
+ if (ifctx->gotgw != 0 || gctx->gotgw != 0) {
clear_sinaddr(&defdst);
clear_sinaddr(&defmask);
/* XXX MRT just table 0 */
@@ -1518,6 +1542,11 @@
p[i] = '\0';
}
+ p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen,
+ TAG_INTF_MTU);
+ if (p != NULL) {
+ bootp_ifmtu = (((unsigned char)p[0] << 8) + (unsigned char)p[1]);
+ }
printf("\n");
More information about the freebsd-bugs
mailing list