From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 5 01:10:12 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A9D181065676 for ; Mon, 5 Mar 2012 01:10:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 80D968FC1A for ; Mon, 5 Mar 2012 01:10:12 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q251AC4F047907 for ; Mon, 5 Mar 2012 01:10:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q251ACSx047905; Mon, 5 Mar 2012 01:10:12 GMT (envelope-from gnats) Resent-Date: Mon, 5 Mar 2012 01:10:12 GMT Resent-Message-Id: <201203050110.q251ACSx047905@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Maciej Kazulak Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E1DC1065672 for ; Mon, 5 Mar 2012 01:06:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 616CF8FC18 for ; Mon, 5 Mar 2012 01:06:25 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q2516P1Q090183 for ; Mon, 5 Mar 2012 01:06:25 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q2516PhP090182; Mon, 5 Mar 2012 01:06:25 GMT (envelope-from nobody) Message-Id: <201203050106.q2516PhP090182@red.freebsd.org> Date: Mon, 5 Mar 2012 01:06:25 GMT From: Maciej Kazulak To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/165700: [libstand] pxeboot discards network mask assigned via DHCP on supernets X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Mar 2012 01:10:12 -0000 >Number: 165700 >Category: kern >Synopsis: [libstand] pxeboot discards network mask assigned via DHCP on supernets >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 05 01:10:12 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Maciej Kazulak >Release: 9.0-RELEASE >Organization: >Environment: FreeBSD gauss.local.spcsk.pl 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: pxeboot uses code in libstand to get information from DHCP. libstand in bootp.c contains logic which effectively breaks CIDR on supernets such as 192.168.0.0/23 and causes the network mask to be truncated to the native classfull mask (/24 in this case). This code is present at least since 3.0-RELEASE and is still in HEAD. Sample scenario: 1. Setup standard FreeBSD network booting on a supernet such as 192.168.0.0/23 2. Boot a client on the same network via PXE with root on NFS 3. pxeboot is loaded via TFTP as per dhcpd.conf 4. pxeboot performs a DHCP request 5. pxeboot keeps the assigned IP but discards network mask as "bogus" and uses /24 (gateway might also be discarded if it ends up being in the other C network) Case 1 - client and NFS server are on the same class C network 6. Client boots normally but after boot keeps the wrong netmask of /24 Case 2 - client and NFS server on different class C networks 6. Client hangs while trying to mount NFS root because it doesn't know how to contact the server No errors or warnings are logged unless debugging is enabled in libstand. I find that plainly misleading. Even if I configure wrong network mask in DHCP I still don't expect that a client will silently discard it and use another one. >How-To-Repeat: 1. Setup standard FreeBSD network booting on a supernet such as 192.168.0.0/23 2. PXE boot any machine on the same network >Fix: Expected behavior: pxeboot should respect network mask assigned via DHCP. Proposed patch attached. Successfully tested on 9.0-RELEASE. Patch attached with submission follows: --- /repo/freebsd/base/release/9.0.0/lib/libstand/bootp.c 2012-03-02 18:04:38.914462827 +0100 +++ lib/libstand/bootp.c 2012-03-02 20:59:33.705461804 +0100 @@ -223,15 +223,6 @@ printf("'native netmask' is %s\n", intoa(nmask)); #endif - /* Check subnet mask against net mask; toss if bogus */ - if ((nmask & smask) != nmask) { -#ifdef BOOTP_DEBUG - if (debug) - printf("subnet mask (%s) bad\n", intoa(smask)); -#endif - smask = 0; - } - /* Get subnet (or natural net) mask */ netmask = nmask; if (smask) >Release-Note: >Audit-Trail: >Unformatted: