From owner-svn-src-head@freebsd.org Thu Mar 23 22:17:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AABECD1B51F; Thu, 23 Mar 2017 22:17:06 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6CD1915DF; Thu, 23 Mar 2017 22:17:05 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id v2NMGoo4082408; Thu, 23 Mar 2017 15:16:50 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id v2NMGoHV082407; Thu, 23 Mar 2017 15:16:50 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201703232216.v2NMGoHV082407@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r315653 - in head: lib/libstand sys/boot/common sys/boot/i386/libi386 In-Reply-To: <978b5e59-97f5-459e-5a8e-00848fe2dab1@FreeBSD.org> To: lidl@freebsd.org Date: Thu, 23 Mar 2017 15:16:50 -0700 (PDT) CC: Toomas Soome , Ian Lepore , Slawa Olhovchenkov , Toomas Soome , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 22:17:06 -0000 > On 3/21/17 11:53 AM, Toomas Soome wrote: > > > >> On 21. m?rts 2017, at 17:15, Ian Lepore wrote: > >> > >> On Tue, 2017-03-21 at 15:35 +0300, Slawa Olhovchenkov wrote: > >>> On Mon, Mar 20, 2017 at 10:20:17PM +0000, Toomas Soome wrote: > >>> > >>>> > >>>> Author: tsoome > >>>> Date: Mon Mar 20 22:20:17 2017 > >>>> New Revision: 315653 > >>>> URL: https://svnweb.freebsd.org/changeset/base/315653 > >>>> > >>>> Log: > >>>> loader: verify the value from dhcp.interface-mtu and use snprintf > >>>> to set mtu > >>>> > >>>> Since the uset can set dhcp.interface-mtu, we need to try to > >>>> validate the > >>>> value. So we verify if the conversion to int is successful and we > >>>> will not > >>>> allow to set value greater than max IPv4 packet size. > >>>> > >>>> + tmp > USHRT_MAX) { > >>>> + printf("%s: bad value: > >>>> \"%s\", " > >>>> + "ignoring\n", > >>>> + "dhcp.interface-mtu", > >>>> val); > >>> === > >>> USHRT_MAX Maximum value for an object of type unsigned short > >>> int > >>> 65535 (216-1) or greater* > >>> > >>> * the actual value depends on the particular system and library > >>> implementation, but shall reflect the limits of these types in the > >>> target platform. > >>> === > >>> > >>> I mean IF_MAXMTU more correct. > >>> > >> > >> The context here is libstand; because it is standalone by design, the > >> code doesn't have access to IF_MAXMTU or other kernel/userland > >> constants. There is also no question that a short is 16 bits or that > >> USHRT_MAX will be anything other than 65535 in that environment. If > >> some platform did appear that had a different-sized short by default, > >> we would add whatever flags are necessary to force it back to 16 bits > >> in src/share/mk/bsd.stand.mk. > >> > > > > > > Also note the ?upper? value is entirely fictional - we felt we need > > to pick some ?sane? default, with current (common 1Gb/s) ethernet hardware > > you will be in trouble long before reaching that value;) > > All the world is not an VAX, nor is every network Ethernet. > > HIPPI, not that you see much of it nowadays, had a MTU for > switched networks of 65280 (64K - 216 bytes of overhead). > Using USHRT_MAX is exactly the right thing here. USHRT_MAX _could_ easily be >16 bits in the not too distant future, though this code doesnt seem to be able to include the proper header to get to a proper define it should probably just localally #define it to be 65535 to avoid the breakage 10 years from now. > -Kurt -- Rod Grimes rgrimes@freebsd.org