Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Feb 2014 09:38:38 -0500
From:      Robert Blayzor <rblayzor.bulk@inoc.net>
To:        freebsd-stable@freebsd.org
Subject:   [patch] bootp_subr.c support for jumbo frames on BOOTP intf
Message-ID:  <36E8D129-6D5B-4C69-834E-85D3F243B756@inoc.net>

next in thread | raw e-mail | index | archive | help

--Apple-Mail=_665FA1C9-BEA3-4176-A01B-836975C24DE4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

I am attaching a patch for those that wish to test or provide feedback.  =
Currently there is no support for adjusting the MTU on an interface a =
diskless client boots from.  Additionally if you attempt to adjust the =
MTU on the interface with ifconfig after the system comes up, the result =
is only cosmetic and the booting interface still cannot pass frames =
larger than 1500 bytes.

There is a RFC standard DHCP TAG to provide a hit to a client what =
interface MTU should be set to.  The attached patch will use this DHCP =
option in bootp and set the interface MTU accordingly.  This allows =
diskless clients to be booted on a jumbo frame enabled network. =20

Before using this, make sure your network and NIC is jumbo frame =
enabled/capable.

Additionally the attached patch removes the client from setting itself =
as the gateway (proxy-arp) if there is no router provided from DHCP.  =
The reasoning behind this is that it is more common for hosts to be =
multi-homed and that the booting interface may not necissarily be the =
interface a gateway is to be installed on.  My erroneously setting =
gateway to hosts self, a default route cannot be easily changed at boot =
time.  If the host needs to set itself as the gateway, return that in an =
option in DHCP.


For tracking:

PR:  http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dmisc/187094
     (should probably be moved from misc to kern)


Patch is against: 10.0-RELEASE r261846

--
Robert Blayzor
Network Architect & Engineer
CCIE 42148 (SP)
rblayzor@inoc.net
INOC, LLC
80 State Street, 7th Flr
Albany, NY  12207
USA



--Apple-Mail=_665FA1C9-BEA3-4176-A01B-836975C24DE4
Content-Disposition: attachment;
	filename=bootp_subr.diff
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="bootp_subr.diff"
Content-Transfer-Encoding: 7bit

Index: sys/nfs/bootp_subr.c
===================================================================
--- sys/nfs/bootp_subr.c	(revision 261846)
+++ sys/nfs/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");
 

--Apple-Mail=_665FA1C9-BEA3-4176-A01B-836975C24DE4--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36E8D129-6D5B-4C69-834E-85D3F243B756>