From owner-freebsd-questions@FreeBSD.ORG Sun Jun 1 02:23:36 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA54DBCE; Sun, 1 Jun 2014 02:23:36 +0000 (UTC) Received: from remote.thehowies.com (50-197-91-217-static.hfc.comcastbusiness.net [50.197.91.217]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "remote.thehowies.com", Issuer "RapidSSL CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7656D233C; Sun, 1 Jun 2014 02:23:35 +0000 (UTC) Received: from PRIMARY.thehowies.local ([fe80::967:7eb6:ee49:3820]) by PRIMARY.thehowies.local ([fe80::967:7eb6:ee49:3820%11]) with mapi id 14.01.0438.000; Sat, 31 May 2014 19:22:27 -0700 From: John Howie To: "freebsd-arm@freebsd.org" , "freebsd-net@freebsd.org" , "freebsd-questions@freebsd.org" Subject: Patches for BOOTP/DHCP code to support Windows Server DHCP Thread-Topic: Patches for BOOTP/DHCP code to support Windows Server DHCP Thread-Index: AQHPfUBUW2MQdiTIGUuysOzuLv/2xg== Date: Sun, 1 Jun 2014 02:22:26 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.2.140509 x-originating-ip: [203.147.52.194] Content-Type: multipart/mixed; boundary="_003_CFB0A140426CBjohnthehowiescom_" MIME-Version: 1.0 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jun 2014 02:23:36 -0000 --_003_CFB0A140426CBjohnthehowiescom_ Content-Type: text/plain; charset="Windows-1252" Content-ID: <07D53905702BB74B9802B9E3C82B70C7@thehowies.local> Content-Transfer-Encoding: quoted-printable Hi all, I apologize for the cross posting of this email, but I believe it will be of interest to people across all three groups. Please feel free to forward to additional groups if you feel they would benefit. I have seen a few posts on and off over the years about Windows Server DHCP not working with FreeBSD. Specifically, the Windows Server DHCP would not return the boot host name/IP address and the root path. The typical response to =B3why won=B9t it work" has typically been that there is a flaw= in Windows Server DHCP code. I did a little digging and found that the problem actually lies in code in FreeBSD. Section 3.5 of RFC 2131 (the DHCP RFC) states that =B3...Second, in its initial DHCPDISCOVER or DHCPREQUEST message, a client may provide the server with a list of specific parameters the client is interested in=8A=B2 and =B3...The client can inform the server which configuration parameters the client is interested in by including the 'parameter request list' option. The data portion of this option explicitly lists the options requested by tag number=8A=B2. A DHCP Server is not required to return any parameter that a client does not ask for. It appears that the ISC-DHCP server, which is recommended by most, will return configured options regardless of whether or not the client asks for them. There are two places in the FreeBSD codebase that DHCP is used to boot the system over a network. The first is in the boot loader, which uses code in lib/libstand. The second is in the NFS code, in sys/nfs. The code is sys/nfs is not always used if the boot loader sets up the environment for the NFS code, either by passing parameters to the kernel (as PXEBOOT appears to do), or information is configured in the boot loader configuration files, e.g. /boot/loader.rc. I have attached two unified diff files which I ask people to test, before I submit them for inclusion into the codebase as fixes. The first, bootp.c.diff fixes the code in lib/libstand/bootp.c to request the boot host (option 12, aka TAG_HOSTNAME) and the NFS root path (option 17, aka TAG_ROOTPATH). This fix has been tested with PXEBOOT on an amd64 box and ubldr on an ARM/RaspberryPI system. The second, bootp_subr.c.diff, fixes code in sys/nfs/bootp_subr.c to request the same options and also to fix bugs that erroneously reported the IP address of the BOOTP/DHCP server. The code assumed that the BOOTP/DHCP server was also the boot host. Please send me all feedback directly. The diff files work with 10.0-RELEASE through 10.0-RELEASE-p3, but will likely work with 9.0 and also CURRENT and STABLE, including 11.0, as the code is old code that does not appear to have changed in a while. If you want to try it on those systems please, please make sure you have backup copies just in case. If you do not have experience configuring Windows Server DHCP just drop me an email, and I will send you a cheat sheet to get you up and running. I am going to grab the latest ubldr code to see if I can get it to work more like PXEBOOT, that appears to pass parameters to the kernel to avoid the need for the NFS BOOTP/DHCP process. If you test on an ARM system with ubldr in RELEASE you will see a lot of unnecessary network activity going on, that we should be able to fix. Regards, John john@thehowies.com (personal) | jhowie@email.arizona.edu (academic) | j.howie@napier.ac.uk (academic) | jhowie@cloudsecurityalliance.org (work) --_003_CFB0A140426CBjohnthehowiescom_ Content-Type: application/octet-stream; name="bootp_subr.c.diff" Content-Description: bootp_subr.c.diff Content-Disposition: attachment; filename="bootp_subr.c.diff"; size=2626; creation-date="Sun, 01 Jun 2014 02:22:26 GMT"; modification-date="Sun, 01 Jun 2014 02:22:26 GMT" Content-ID: <48E8CD1FA2F5FF40B7454A0D1B2A8C6F@thehowies.local> Content-Transfer-Encoding: base64 LS0tIHN5cy9uZnMvYm9vdHBfc3Vici5jCTIwMTQtMDEtMjYgMTU6NTU6NDIuMDAwMDAwMDAwIC0w ODAwCisrKyAvaG9tZS9qb2huL3RtcC9ib290cF9zdWJyLmMJMjAxNC0wNS0yNCAxOTowMzo1OS4w MDAwMDAwMDAgLTA3MDAKQEAgLTE5OCw2ICsxOTgsNyBAQAogCiAvKiBESENQIHNwZWNpZmljIHRh Z3MgKi8KICNkZWZpbmUgVEFHX09WRVJMT0FECSA1MiAgLyogT3B0aW9uIE92ZXJsb2FkICovCisj ZGVmaW5lIFRBR19QQVJBTV9SRVEgICAgNTUgIC8qIFRhZyBkZW5vdGluZyBvcHRpb25hbCB0YWdz IGluIERIQ1AgY2xpZW50IG1lc3NhZ2UsIHJlcXVlc3RpbmcgZGF0YSBmcm9tIERIQ1Agc2VydmVy ICovCiAjZGVmaW5lIFRBR19NQVhNU0dTSVpFICAgNTcgIC8qIE1heGltdW0gREhDUCBNZXNzYWdl IFNpemUgKi8KIAogI2RlZmluZSBUQUdfRU5ECQkyNTUgIC8qIEVuZCBPcHRpb24gKGkuZS4gbm8g bW9yZSBvcHRpb25zKSAqLwpAQCAtNTczLDcgKzU3NCw3IEBACiBzdGF0aWMgaW50CiBib290cGNf Y2FsbChzdHJ1Y3QgYm9vdHBjX2dsb2JhbGNvbnRleHQgKmdjdHgsIHN0cnVjdCB0aHJlYWQgKnRk KQogewotCXN0cnVjdCBzb2NrYWRkcl9pbiAqc2luLCBkc3Q7CisJc3RydWN0IHNvY2thZGRyX2lu ICpzaW4sIGRzdCwgKmZyb207CiAJc3RydWN0IHVpbyBhdWlvOwogCXN0cnVjdCBzb2Nrb3B0IHNv cHQ7CiAJc3RydWN0IGlvdmVjIGFpbzsKQEAgLTU4Nyw2ICs1ODgsNyBAQAogCWludCByZXRyeTsK IAljb25zdCBjaGFyICpzOwogCisgICAgZnJvbSA9IChzdHJ1Y3Qgc29ja2FkZHJfaW4gKikgMDsK IAl0di50dl9zZWMgPSAxOwogCXR2LnR2X3VzZWMgPSAwOwogCWJ6ZXJvKCZzb3B0LCBzaXplb2Yo c29wdCkpOwpAQCAtNzYwLDkgKzc2MiwxNCBAQAogCQlpZiAodGltbyA8IE1BWF9SRVNFTkRfREVM QVkpCiAJCQl0aW1vKys7CiAJCWVsc2UgewotCQkJcHJpbnRmKCJESENQL0JPT1RQIHRpbWVvdXQg Zm9yIHNlcnZlciAiKTsKLQkJCXByaW50X3Npbl9hZGRyKCZkc3QpOwotCQkJcHJpbnRmKCJcbiIp OworICAgICAgICAgICAgaWYgKGZyb20gIT0gKHN0cnVjdCBzb2NrYWRkcl9pbiAqKSAwKSB7Cisg ICAgICAgICAgICAgICAgcHJpbnRmKCJESENQL0JPT1RQIHRpbWVvdXQgZm9yIHNlcnZlciAiKTsK KyAgICAgICAgICAgICAgICBwcmludF9zaW5fYWRkcihmcm9tKTsKKyAgICAgICAgICAgICAgICBw cmludGYoIlxuIik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAg ICAgICAgICBwcmludGYgKCJESENQL0JPT1RQIHRpbWVvdXRcbiIpOworICAgICAgICAgICAgfQog CQl9Ci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ICAgICAgZnJlZSAoZnJvbSwgTV9TT05BTUUp OworICAgICAgICBmcm9tID0gKHN0cnVjdCBzb2NrYWRkcl9pbiAqKSAwOworICAgIH0KIAlyZXR1 cm4gKGVycm9yKTsKIH0KIApAQCAtMTI3Nyw2ICsxMjkyLDE1IEBACiAJCWxlYXNldGltZSA9IGh0 b25sKDMwMCk7CiAJCW1lbWNweSh2ZW5kcCwgJmxlYXNldGltZSwgNCk7CiAJCXZlbmRwICs9IDQ7 CisgICAgICAgICAgICAKKyAgICAgICAgLyoKKyAgICAgICAgICogUmVxdWVzdCBob3N0IGFuZCBw YXRoIG9mIHJvb3QgZGlzayAocmVxdWlyZWQgZm9yIFdpbmRvd3MgU2VydmVyIERIQ1ApCisgICAg ICAgICAqLworICAgICAgICAgICAgCisgICAgICAgICp2ZW5kcCsrID0gVEFHX1BBUkFNX1JFUTsK KyAgICAgICAgKnZlbmRwKysgPSAyOworICAgICAgICAqdmVuZHArKyA9IFRBR19IT1NUTkFNRTsK KyAgICAgICAgKnZlbmRwKysgPSBUQUdfUk9PVDsKIAkJYnJlYWs7CiAJZGVmYXVsdDoKIAkJYnJl YWs7Cg== --_003_CFB0A140426CBjohnthehowiescom_ Content-Type: application/octet-stream; name="bootp.c.diff" Content-Description: bootp.c.diff Content-Disposition: attachment; filename="bootp.c.diff"; size=907; creation-date="Sun, 01 Jun 2014 02:22:26 GMT"; modification-date="Sun, 01 Jun 2014 02:22:26 GMT" Content-ID: <257902279A9442499AC0B670B2BC93E1@thehowies.local> Content-Transfer-Encoding: base64 LS0tIGxpYi9saWJzdGFuZC9ib290cC5jCTIwMTQtMDQtMDQgMTI6MTg6NDAuMDAwMDAwMDAwIC0w NzAwCisrKyAvaG9tZS9qb2huL3RtcC9ib290cC5jCTIwMTQtMDUtMTEgMjA6MDA6NDQuMDAwMDAw MDAwIC0wNzAwCkBAIC0xODYsMTMgKzE4NiwyMiBAQAogCQlicC0+YnBfdmVuZFsyMF0gPSA0Owog CQlsZWFzZXR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