From patchwork Tue Apr 24 02:56:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903251 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="IA4I9kOQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSfg616hz9ryr for ; Tue, 24 Apr 2018 12:57:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932888AbeDXC5N (ORCPT ); Mon, 23 Apr 2018 22:57:13 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:41307 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932864AbeDXC5A (ORCPT ); Mon, 23 Apr 2018 22:57:00 -0400 Received: by mail-wr0-f195.google.com with SMTP id g21-v6so18919822wrb.8 for ; Mon, 23 Apr 2018 19:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ctZgxHojiSP5oWjc9VUVrlUVYe+0282syMQIAs9HvF8=; b=IA4I9kOQQ0zuIFoUYwQ3ja0f3Y+n1Pm9n8o9027eFmj8fBHAx3ZAXsOIwKl8/p9q/K IrTEJDqUj6LOERPzx28RzAKSd301nCutGmXzQlXqpH7+drpVI2OnfjGa+P1K40uJ3L5x 27nDUPC3HRGmtOviFeQTBfnh4lnpYMLw7xlZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ctZgxHojiSP5oWjc9VUVrlUVYe+0282syMQIAs9HvF8=; b=R468wZAqKTqQ1j4BdXYtvKm6zpSFtzZWRv9HTkA+AsWqKUGgVfn/ynymW31uDRgfN5 wFG9BGoPC/WpOHBZwjZaO+gMqqJEmzhF00Myg7V8sf1NuJQBFCylyK7BrcrvE68byQKJ k/D1YWMIXBPC9Dy31rJtIyy5rH3cY1XttE6oBfzuCNytM/FilGJQRNh1QLipg0OEVUxI Otljc9PQQDasYWNfqtvU8nrG2MdgdHhLaw/Nh5lzryAGW/K/sUhjJvdyKkUtAh2vBaW1 r16y9iEdZs/PodnUnFCDqde8PgJMoiD0ZEI9IblRzQ07QKNMCiRNAVqcfM22wZAMdYBV NeiQ== X-Gm-Message-State: ALQs6tDSb9M53vqB/XLTAHPVrc9jeVaP4L/BIdcpfCG1GK/cYeerIonS mc78aX8WFXEpdtkMWKUWV1TeUyj1 X-Google-Smtp-Source: AIpwx49TjYiROollKor0jfcG8X6hpUiTPf+pqCmgDDMEe/Hvpf6VKY3ySuS7UwOoUNq7MFpFnTYFkg== X-Received: by 10.28.156.4 with SMTP id f4mr11377276wme.79.1524538619220; Mon, 23 Apr 2018 19:56:59 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.56.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:56:58 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 1/8] ipconfig: Document setting of NIS domain name Date: Tue, 24 Apr 2018 03:56:32 +0100 Message-Id: <20180424025639.2228-2-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ic_do_bootp_ext() is responsible for parsing the "ip=" and "nfsaddrs=" kernel parameters. If a "." character is found in parameter 4 (the client's hostname), everything before the first "." is used as the hostname, and everything after it is used as the NIS domain name (but not necessarily the DNS domain name). Document this behaviour in Documentation/filesystems/nfs/nfsroot.txt, as it is not made explicit. Signed-off-by: Chris Novakovic --- Documentation/filesystems/nfs/nfsroot.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/nfs/nfsroot.txt b/Documentation/filesystems/nfs/nfsroot.txt index 5efae00f6c7f..1513e5d663fd 100644 --- a/Documentation/filesystems/nfs/nfsroot.txt +++ b/Documentation/filesystems/nfs/nfsroot.txt @@ -123,10 +123,13 @@ ip=::::::: Default: Determined using autoconfiguration. - Name of the client. May be supplied by autoconfiguration, - but its absence will not trigger autoconfiguration. - If specified and DHCP is used, the user provided hostname will - be carried in the DHCP request to hopefully update DNS record. + Name of the client. If a '.' character is present, anything + before the first '.' is used as the client's hostname, and anything + after it is used as its NIS domain name. May be supplied by + autoconfiguration, but its absence will not trigger autoconfiguration. + If specified and DHCP is used, the user-provided hostname (and NIS + domain name, if present) will be carried in the DHCP request; this + may cause a DNS record to be created or updated for the client. Default: Client IP address is used in ASCII notation. From patchwork Tue Apr 24 02:56:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903253 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="a1ZY5Zay"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSfm6tkFz9rx7 for ; Tue, 24 Apr 2018 12:57:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932897AbeDXC5T (ORCPT ); Mon, 23 Apr 2018 22:57:19 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39986 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932812AbeDXC5B (ORCPT ); Mon, 23 Apr 2018 22:57:01 -0400 Received: by mail-wr0-f194.google.com with SMTP id v60-v6so46376929wrc.7 for ; Mon, 23 Apr 2018 19:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TKTHawpwf7Jl1Fnmu5z46cj14vKsODh6eYMbHpsMzT8=; b=a1ZY5ZayLxxViFj7vdcgRgJxfwoyVp4OMDGDRBsI39Ws5hto4bZ4LQbGdpkx685pLV lvd6grbYwFWeXgw3Lr+Jm05ZuPm1xaa4LX1Zyl0AWX2EI6WFlxU+mKtE2kjSE87If2/4 iuTpATnb6dN5oD7tsPxkkmGQQnDQvbShsdbk0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TKTHawpwf7Jl1Fnmu5z46cj14vKsODh6eYMbHpsMzT8=; b=gcIMUqv6Nvj/sivcJwhSeO6B98l9h7VmrJap5PuahDFGYE134OJRtjz1mnWc/NuSf/ vPXDHaFPB9aFIsee35qViUADr6PRCrOKxAO2TNnv9zkBFRgyXOXEaU7OolzDAWa4f15B VpZfdFCqm9VCDlb8Csor1bzuD708LjPFaizP/2L5Ay2dqJ5NUBYQIDq0Pz0IYIGkOX0X yKJ1P5nRbFGutQE4C18IxpHTFw+AtJCJkhW/ckGA++U9n3cfcvzAJBbsEDXX6aEIMUPV 8h7pWkb1iJ07I2llxUQmM+AlaU8sgcfxI8C7XeA8Erv5yUZZwbruIbgoU8bWpYL3qrtn AdEA== X-Gm-Message-State: ALQs6tA555lc44+SfD9c84JrUFd3Y86GHC4/uhw55z8DmC+9vEBsLoMS 9ypkhVw7zCP72iecey9RCdbFFq0U X-Google-Smtp-Source: AIpwx48sOBd6iq0BP7ajskvjx5SeLC8IR8YsvJUnNQ3QpXkIfLDP5Iqhm4uNCek5lygLHk9ARczpcQ== X-Received: by 10.28.44.86 with SMTP id s83mr10453485wms.30.1524538620093; Mon, 23 Apr 2018 19:57:00 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.56.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:56:59 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 2/8] ipconfig: Tidy up reporting of name servers Date: Tue, 24 Apr 2018 03:56:33 +0100 Message-Id: <20180424025639.2228-3-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 5e953778a2aab04929a5e7b69f53dc26e39b079e ("ipconfig: add nameserver IPs to kernel-parameter ip=") adds the IP addresses of discovered name servers to the summary printed by ipconfig when configuration is complete. It appears the intention in ip_auto_config() was to print the name servers on a new line (especially given the spacing and lack of comma before "nameserver0="), but they're actually printed on the same line as the NFS root filesystem configuration summary: [ 0.686186] IP-Config: Complete: [ 0.686226] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1 [ 0.686328] host=test, domain=example.com, nis-domain=(none) [ 0.686386] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath= nameserver0=10.0.0.1 This makes it harder to read and parse ipconfig's output. Instead, print the name servers on a separate line: [ 0.791250] IP-Config: Complete: [ 0.791289] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1 [ 0.791407] host=test, domain=example.com, nis-domain=(none) [ 0.791475] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath= [ 0.791476] nameserver0=10.0.0.1 Signed-off-by: Chris Novakovic --- net/ipv4/ipconfig.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 43f620feb1c4..d0ea0ecc9008 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1481,16 +1481,19 @@ static int __init ip_auto_config(void) &ic_servaddr, &root_server_addr, root_server_path); if (ic_dev_mtu) pr_cont(", mtu=%d", ic_dev_mtu); - for (i = 0; i < CONF_NAMESERVERS_MAX; i++) + /* Name servers (if any): */ + for (i = 0; i < CONF_NAMESERVERS_MAX; i++) { if (ic_nameservers[i] != NONE) { - pr_cont(" nameserver%u=%pI4", - i, &ic_nameservers[i]); - break; + if (i == 0) + pr_info(" nameserver%u=%pI4", + i, &ic_nameservers[i]); + else + pr_cont(", nameserver%u=%pI4", + i, &ic_nameservers[i]); } - for (i++; i < CONF_NAMESERVERS_MAX; i++) - if (ic_nameservers[i] != NONE) - pr_cont(", nameserver%u=%pI4", i, &ic_nameservers[i]); - pr_cont("\n"); + if (i + 1 == CONF_NAMESERVERS_MAX) + pr_cont("\n"); + } #endif /* !SILENT */ /* From patchwork Tue Apr 24 02:56:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903250 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="V0sGEOTm"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSfb3Fghz9rx7 for ; Tue, 24 Apr 2018 12:57:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932881AbeDXC5I (ORCPT ); Mon, 23 Apr 2018 22:57:08 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:38496 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932858AbeDXC5C (ORCPT ); Mon, 23 Apr 2018 22:57:02 -0400 Received: by mail-wr0-f196.google.com with SMTP id h3-v6so46419057wrh.5 for ; Mon, 23 Apr 2018 19:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AztiGRJ9j2ldpxHhKGzMveqA6iJBG5mE+AprskQ0gIY=; b=V0sGEOTmwXHSiS6uaFsv0Y+SK8ORwHipoVXTwmdoHJnsSUdX6tVFmZkaumK1LjMZSt vgHFR912EJZX7EB2j3JStkhs8apI6xhFHxByjTdeBDI3DExhJ/RZE3KXL4TjonUCD3uK 1y8xJUKz/NDjA7EqltjvFQ5P+EmKK9F2sfy3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AztiGRJ9j2ldpxHhKGzMveqA6iJBG5mE+AprskQ0gIY=; b=jxx1M50xLPIf6xEqTldjBcL+ihxgluCc4pXjf3G9lWk0YIfuO2Bwdm/p060ajxcUtq IZTiM1bY4P4cuigyAKb7g6vvqTveSOQ//M7CnfD3+SJ3R0BuH1EyjKNIxVULqMO7IANZ KwFHba1BCb6QcU0LLmG0LAnrUsncLMrv5BwA8ztOga/bsEbNgGGCwMg4NIcYOHRRyLuA eV0VrhoRXzR8BJrqfIUv0Giql6V2MX/icw5HpAM8mYXn9wdbU2VneF4dq2X/inYlc9av v7hL7PdK6O2TMQYj0qAkgx44RQBb2usdx0j/h2avEd6VU8cjy/r0EpC6kDwCuOa/DW8B 2rvg== X-Gm-Message-State: ALQs6tAjQ44xjmt3IHZ5Re5vyry6lWWnRW/a1XIHXzWoosImKsmG+Sq+ Hbi6oB9CJb7VJYwk+MDQ5uJ3GfBL X-Google-Smtp-Source: AIpwx4/Hi/IRp+x8dDLDAjFJD7yKIdWeZUmFqwOInsTA95Y4mTce9AQlKMy0PLzJIJrD6Vlv9s3rQg== X-Received: by 10.28.47.74 with SMTP id v71mr11656634wmv.59.1524538620924; Mon, 23 Apr 2018 19:57:00 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:00 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 3/8] ipconfig: BOOTP: Don't request IEN-116 name servers Date: Tue, 24 Apr 2018 03:56:34 +0100 Message-Id: <20180424025639.2228-4-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When ipconfig is autoconfigured via BOOTP, the request packet initialised by ic_bootp_init_ext() allocates 8 bytes for tag 5 ("Name Server" [1, §3.7]), but tag 5 in the response isn't processed by ic_do_bootp_ext(). Instead, allocate the 8 bytes to tag 6 ("Domain Name Server" [1, §3.8]), which is processed by ic_do_bootp_ext(), and appears to have been the intended tag to request. This won't cause any breakage for existing users, as tag 5 responses provided by BOOTP servers weren't being processed anyway. [1] RFC 2132, "DHCP Options and BOOTP Vendor Extensions": https://tools.ietf.org/rfc/rfc2132.txt Signed-off-by: Chris Novakovic --- net/ipv4/ipconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index d0ea0ecc9008..bcf3c4f9882d 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -721,7 +721,7 @@ static void __init ic_bootp_init_ext(u8 *e) *e++ = 3; /* Default gateway request */ *e++ = 4; e += 4; - *e++ = 5; /* Name server request */ + *e++ = 6; /* (DNS) name server request */ *e++ = 8; e += 8; *e++ = 12; /* Host name request */ From patchwork Tue Apr 24 02:56:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903254 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="C1De7Rxg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSft2dCkz9rx7 for ; Tue, 24 Apr 2018 12:57:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932798AbeDXC5Y (ORCPT ); Mon, 23 Apr 2018 22:57:24 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:39990 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932865AbeDXC5C (ORCPT ); Mon, 23 Apr 2018 22:57:02 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so46377016wrc.7 for ; Mon, 23 Apr 2018 19:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w5e8UjDIjOCJpg7obJ+IGA97bDxo0mQJqpEl0Wl8AZg=; b=C1De7RxgI3aNTYIFrjQlMJLNNpCKcTjPjWwb/xExC9n+iyYeJ4IA3goVd2xFWOkMLp Ic07WuTUTGLSt4M0qb/3zSBQ+yEYP9S0gf30lXueFoh/JvcaRSPHp3DNtV2SiigOuK6+ nAYQA2aTedOrrQCo59CfxqgOxRaOOkOABDw2o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w5e8UjDIjOCJpg7obJ+IGA97bDxo0mQJqpEl0Wl8AZg=; b=qByQjoKuFjC4ICOzDs1ki0hgVhfrVG2gwxBrcUBGpP/jO7xejB7WUu2TvkeCrrpCBF 7qRuvSel5PlvfxQAudEPQOXIFvM/I5SugayoR5EKUpHPcY3r1YWQBOw0wUtDPmfzf31S JuESBN2aYjJ/LxY7YZa30ywiyN9Xmdrzt3NRMy392e4YTY3h+8pym04UqApf04N3IbQj tT+gXuFD2NSEBosvMvFlJWs1TMTQvRqIyPdDJXGkjl3bkjFKNrGppFPsa44F16wXVF8m +4uuVSbxcW4n+CMg5Wf7VqpyH9l6Cx4Vl/JGEWX8/hKO2c7dwRYCa/YtxG8mCcC/4/8k GzUA== X-Gm-Message-State: ALQs6tBrsgkd9cQj0gvUzcmqE9qzr3vHCDJpmqdBY5l+9u3rdyUiuTw2 TTdmM+GKVaCmhzPFERNHDq8+AA== X-Google-Smtp-Source: AB8JxZpCX6Ds+9GCqG/1ViJobDfxW3zNYf5FlZdtekVIgT3PhCnMi5CjCsaJ+BvxipWFh+yExsesyg== X-Received: by 10.28.191.215 with SMTP id o84mr7940380wmi.157.1524538621764; Mon, 23 Apr 2018 19:57:01 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:01 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 4/8] ipconfig: BOOTP: Request CONF_NAMESERVERS_MAX name servers Date: Tue, 24 Apr 2018 03:56:35 +0100 Message-Id: <20180424025639.2228-5-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When ipconfig is autoconfigured via BOOTP, the request packet initialised by ic_bootp_init_ext() always allocates 8 bytes for the name server option, limiting the BOOTP server to responding with at most 2 name servers even though ipconfig in fact supports an arbitrary number of name servers (as defined by CONF_NAMESERVERS_MAX, which is currently 3). Only request name servers in the request packet if CONF_NAMESERVERS_MAX is positive (to comply with [1, §3.8]), and allocate enough space in the packet for CONF_NAMESERVERS_MAX name servers to indicate the maximum number we can accept in response. [1] RFC 2132, "DHCP Options and BOOTP Vendor Extensions": https://tools.ietf.org/rfc/rfc2132.txt Signed-off-by: Chris Novakovic --- net/ipv4/ipconfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index bcf3c4f9882d..0f460d6d3cce 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -721,9 +721,11 @@ static void __init ic_bootp_init_ext(u8 *e) *e++ = 3; /* Default gateway request */ *e++ = 4; e += 4; +#if CONF_NAMESERVERS_MAX > 0 *e++ = 6; /* (DNS) name server request */ - *e++ = 8; - e += 8; + *e++ = 4 * CONF_NAMESERVERS_MAX; + e += 4 * CONF_NAMESERVERS_MAX; +#endif *e++ = 12; /* Host name request */ *e++ = 32; e += 32; From patchwork Tue Apr 24 02:56:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903255 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="FD9X4rZX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSfy5ZJKz9rx7 for ; Tue, 24 Apr 2018 12:57:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932870AbeDXC52 (ORCPT ); Mon, 23 Apr 2018 22:57:28 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:36779 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932722AbeDXC5D (ORCPT ); Mon, 23 Apr 2018 22:57:03 -0400 Received: by mail-wr0-f174.google.com with SMTP id u18-v6so19128418wrg.3 for ; Mon, 23 Apr 2018 19:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P8/EV6JnrY/2N+1LsimdI0irACHvSsoVadlHSi81sfU=; b=FD9X4rZXFq4FizbY4DZACEulkAw+oXV7R4rW+u3Ar+Xz88NZzolB40Q5TD8Z728KrC 6VquPrRKlkvPoZ9uwcSLfEmWdecHDo1tXWX7sFgEzm6LPcm7FsxEz+MdLta2M61jeoms 9QwhcBVrk8bW8QQcpcwwq2yLWjU/gCOkBucfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P8/EV6JnrY/2N+1LsimdI0irACHvSsoVadlHSi81sfU=; b=ZYpFora3dyuKYGmrT3AnrSKUzG4GgM6rdVwrW4ZbpX74vz+2sLxlWNXLb0frtQdd7e HuXFMyf7jGUhopUC+F+khjVtHm8pp4mWEm+MpJoir3hyOXGPMgpksOPE1tbWwvcR7nKP s/q8Amcr96SR0XndhsCuvPd/0dPAt/CQSgqTWBuZcrQEYqVvcTd+S5KHdbRj8VqcCydQ N0yzh/2d6TFVVmDMu9nPc7J6mz01woOChBcWBFaWCVTcho6Bxn6j/6trnRraGKQhlBpv xr6kK8NE1h+tRO/8zl/TezO3umiztPPhvfPtNEH78cuHNznI29eMaQdA4kG7Iv8/38I1 mTqw== X-Gm-Message-State: ALQs6tC6qc/TgAHPt17U+UT/wL9sG4Hn860mpnALhCZdJk9T2sxkJciF xwBWqTmruO+TIvg61mjIi/CVBlm6 X-Google-Smtp-Source: AB8JxZoXrMfOMtNT/cql3MOVSzv1nUpXqoys4G2gtd64khrMbxaMDNnxCtEvE+0KHlTY8BNRGsJdRw== X-Received: by 10.28.85.129 with SMTP id j123mr11565407wmb.124.1524538622567; Mon, 23 Apr 2018 19:57:02 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:02 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 5/8] ipconfig: Document /proc/net/pnp Date: Tue, 24 Apr 2018 03:56:36 +0100 Message-Id: <20180424025639.2228-6-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fully document the format used by the /proc/net/pnp file written by ipconfig, explain where its values originate from, and clarify that the tertiary name server IP and DNS domain name are only written to the file when autoconfiguration is used. Signed-off-by: Chris Novakovic --- Documentation/filesystems/nfs/nfsroot.txt | 34 ++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/nfs/nfsroot.txt b/Documentation/filesystems/nfs/nfsroot.txt index 1513e5d663fd..a1030bea60d3 100644 --- a/Documentation/filesystems/nfs/nfsroot.txt +++ b/Documentation/filesystems/nfs/nfsroot.txt @@ -110,6 +110,9 @@ ip=::::::: will not be triggered if it is missing and NFS root is not in operation. + Value is exported to /proc/net/pnp with the prefix "bootserver " + (see below). + Default: Determined using autoconfiguration. The address of the autoconfiguration server is used. @@ -165,12 +168,33 @@ ip=::::::: Default: any - IP address of first nameserver. - Value gets exported by /proc/net/pnp which is often linked - on embedded systems by /etc/resolv.conf. + IP address of primary nameserver. + Value is exported to /proc/net/pnp with the prefix "nameserver " + (see below). + + Default: None if not using autoconfiguration; determined + automatically if using autoconfiguration. + + IP address of secondary nameserver. + See . + + After configuration (whether manual or automatic) is complete, a file is + created at /proc/net/pnp in the following format; lines are omitted if + their respective value is empty following configuration. + + #PROTO: (depending on configuration method) + domain (if autoconfigured, the DNS domain) + nameserver (primary name server IP) + nameserver (secondary name server IP) + nameserver (tertiary name server IP) + bootserver (NFS server IP) + + and are requested during autoconfiguration; they + cannot be specified as part of the "ip=" kernel command line parameter. - IP address of second nameserver. - Same as above. + Because the "domain" and "nameserver" options are recognised by DNS + resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems + that use an NFS root filesystem. nfsrootdebug From patchwork Tue Apr 24 02:56:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903256 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="XwA8sQTx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSg11H7cz9rx7 for ; Tue, 24 Apr 2018 12:57:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932900AbeDXC5b (ORCPT ); Mon, 23 Apr 2018 22:57:31 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:39995 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932860AbeDXC5E (ORCPT ); Mon, 23 Apr 2018 22:57:04 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so46377099wrc.7 for ; Mon, 23 Apr 2018 19:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/NxENTrHyxbkLEr9C98qFDDZf/IgRQsBfwv+wUjm4pI=; b=XwA8sQTx1g5TToTcsiPuqw4jGNNctg1CiXYBrbjfBvGJSZkUZ9DlIXuSJvQ1xRzX1V AcnlY5B1wL9BLAIeZq03rNRBnUtiQQJemtxS/n7MUraFvZEFToNfY/GybmPzKChMnjgP msmRgMBIcGHGlppI5EU8C9a4uEqyw0AB3rxSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/NxENTrHyxbkLEr9C98qFDDZf/IgRQsBfwv+wUjm4pI=; b=W6jX9HtgslqwSO06cN0tG+b5FFl2zskecYrm4NG3bNhWOm/RSpnWcIuMUOHrPhrXtU g3S3COu5X91QI4UZ2nkHXwtBxKUu17Wc5m4uc9bRhoDLNFz3VDgwNDWPtLhRpnTTvLyo xt6J4+lYifA/YJYb74t+sRX8aJTfcHuJSZOmbLP5pbuYrG8sqDIb4vEULLKH2m9p59UB VSj1g3MzcvJ0L9FbsQVAvGWx7mpVNf0M0pN87/1WzV13Quxg/44fLGKmzKBOeQbuWpYu YQHG5WP2k99rkBKlA6PUkBxFKUEVcry//Z+6maoF3xGm63hHtV4J1TR+qph+aFsVryQV FpJQ== X-Gm-Message-State: ALQs6tCw6hacfTeihCwNpEZkGNQZjp8LpPlixmxEBLWEOZEaV3TG/YEX AadFO9mICFQzj/y+NaMhhEm9OQ== X-Google-Smtp-Source: AIpwx4+fOlS7uwtzZ0K+bfeHwXS9KjrRV5/5sX2a5qNuNBoisOWzaALGcGQDzDBvBlYzv0D48GulTQ== X-Received: by 2002:adf:e249:: with SMTP id n9-v6mr13083214wri.270.1524538623426; Mon, 23 Apr 2018 19:57:03 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:02 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 6/8] ipconfig: Correctly initialise ic_nameservers Date: Tue, 24 Apr 2018 03:56:37 +0100 Message-Id: <20180424025639.2228-7-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ic_nameservers, which stores the list of name servers discovered by ipconfig, is initialised (i.e. has all of its elements set to NONE, or 0xffffffff) by ic_nameservers_predef() in the following scenarios: - before the "ip=" and "nfsaddrs=" kernel command line parameters are parsed (in ip_auto_config_setup()); - before autoconfiguring via DHCP or BOOTP (in ic_bootp_init()), in order to clear any values that may have been set after parsing "ip=" or "nfsaddrs=" and are no longer needed. This means that ic_nameservers_predef() is not called when neither "ip=" nor "nfsaddrs=" is specified on the kernel command line. In this scenario, every element in ic_nameservers remains set to 0x00000000, which is indistinguishable from ANY and causes pnp_seq_show() to write the following (bogus) information to /proc/net/pnp: #MANUAL nameserver 0.0.0.0 nameserver 0.0.0.0 nameserver 0.0.0.0 This is potentially problematic for systems that blindly link /etc/resolv.conf to /proc/net/pnp. Ensure that ic_nameservers is also initialised when neither "ip=" nor "nfsaddrs=" are specified by calling ic_nameservers_predef() in ip_auto_config(), but only when ip_auto_config_setup() was not called earlier. This causes the following to be written to /proc/net/pnp, and is consistent with what gets written when ipconfig is configured manually but no name servers are specified on the kernel command line: #MANUAL Signed-off-by: Chris Novakovic --- net/ipv4/ipconfig.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 0f460d6d3cce..e11dfd29a929 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -750,6 +750,11 @@ static void __init ic_bootp_init_ext(u8 *e) */ static inline void __init ic_bootp_init(void) { + /* Re-initialise all name servers to NONE, in case any were set via the + * "ip=" or "nfsaddrs=" kernel command line parameters: any IP addresses + * specified there will already have been decoded but are no longer + * needed + */ ic_nameservers_predef(); dev_add_pack(&bootp_packet_type); @@ -1370,6 +1375,13 @@ static int __init ip_auto_config(void) int err; unsigned int i; + /* Initialise all name servers to NONE (but only if the "ip=" or + * "nfsaddrs=" kernel command line parameters weren't decoded, otherwise + * we'll overwrite the IP addresses specified there) + */ + if (ic_set_manually == 0) + ic_nameservers_predef(); + #ifdef CONFIG_PROC_FS proc_create("pnp", 0444, init_net.proc_net, &pnp_seq_fops); #endif /* CONFIG_PROC_FS */ @@ -1593,6 +1605,7 @@ static int __init ip_auto_config_setup(char *addrs) return 1; } + /* Initialise all name servers to NONE */ ic_nameservers_predef(); /* Parse string for static IP assignment. */ From patchwork Tue Apr 24 02:56:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903257 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="eN7jF9a9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSgH07QXz9rx7 for ; Tue, 24 Apr 2018 12:57:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932901AbeDXC5n (ORCPT ); Mon, 23 Apr 2018 22:57:43 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:39998 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932861AbeDXC5F (ORCPT ); Mon, 23 Apr 2018 22:57:05 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so46377141wrc.7 for ; Mon, 23 Apr 2018 19:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q/V76x6GK89/SuPYv+3BTd0bX4LQa0w7M3vFMxrC2+w=; b=eN7jF9a9neQmQLSdo4Wzj0Bb1tNsSS2yRWa1IOeyfWSllmUtU/M3UlJRjUz4aazO4G A8MeWtWhFZonJV5QGXlvASAGImWWAx/XWga0ghHlTrDeQ1u4f11xhAmBzZHgnXiSjEKy Jq2aJCPwZaU0seJvNpP7quB0yHYfzFBHA5cwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q/V76x6GK89/SuPYv+3BTd0bX4LQa0w7M3vFMxrC2+w=; b=BFZTiY6m6nhJYfIT3CSeB6GnjbqPD0VaOUVwj5v7jKTnEr8+QbiNRij/em/lKrA+gh 3eI/JokEBgB+Gza23ptG5u/8bXY5+LVodczL+uvffBLOPWwLu0st2xjom4Iklcqmz4o9 j83VJw1ikf/jHVipqj0s/xUqCiIIuyMqLgWjRYBTXxv5MauaDG/CL/vm3m4u9DnkJK4T xYTdI4z4LNjcB90LL2I0kLrZbz1pbMLRb2mDJFXz9UaaiPGMb5gc3E+BV7rvQUpWqMZN U1ThXQxiQGMhxhvxkz3ENX6lewUrYIyKhwq/3U6UcAvtpsmvlTfQ2Gk+CplutYBG0Yi3 sS8g== X-Gm-Message-State: ALQs6tDZ52zWvzjYjLDEOIt8FQoHSabNWU6KyqpJuYd8t7Ei8FJ6OqNX Dd/zUL7sthstIgAGvfqflxAoWA== X-Google-Smtp-Source: AIpwx4/n6A+7UK7dYA26sqa4hfhmeACvFUDqoPXC1fD8Hep2W3wOofGYM3t2CQ2ICFBax/ksQx9EHA== X-Received: by 2002:adf:e28c:: with SMTP id v12-v6mr17517518wri.188.1524538624210; Mon, 23 Apr 2018 19:57:04 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:03 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 7/8] ipconfig: Create /proc/net/ipconfig directory Date: Tue, 24 Apr 2018 03:56:38 +0100 Message-Id: <20180424025639.2228-8-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org To allow ipconfig to report IP configuration details to user space processes without cluttering /proc/net, create a new subdirectory /proc/net/ipconfig. All files containing IP configuration details should be written to this directory. Signed-off-by: Chris Novakovic --- net/ipv4/ipconfig.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index e11dfd29a929..9abf833f3a99 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -158,6 +158,9 @@ static u8 ic_domain[64]; /* DNS (not NIS) domain name */ * Private state. */ +/* proc_dir_entry for /proc/net/ipconfig */ +static struct proc_dir_entry *ipconfig_dir; + /* Name of user-selected boot device */ static char user_dev_name[IFNAMSIZ] __initdata = { 0, }; @@ -1301,6 +1304,16 @@ static const struct file_operations pnp_seq_fops = { .llseek = seq_lseek, .release = single_release, }; + +/* Create the /proc/net/ipconfig directory */ +static int ipconfig_proc_net_init(void) +{ + ipconfig_dir = proc_net_mkdir(&init_net, "ipconfig", init_net.proc_net); + if (!ipconfig_dir) + return -ENOMEM; + + return 0; +} #endif /* CONFIG_PROC_FS */ /* @@ -1384,6 +1397,8 @@ static int __init ip_auto_config(void) #ifdef CONFIG_PROC_FS proc_create("pnp", 0444, init_net.proc_net, &pnp_seq_fops); + + ipconfig_proc_net_init(); #endif /* CONFIG_PROC_FS */ if (!ic_enable) From patchwork Tue Apr 24 02:56:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Novakovic X-Patchwork-Id: 903258 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chrisn.me.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chrisn.me.uk header.i=@chrisn.me.uk header.b="ARQwOrQh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VSgK2dzSz9rx7 for ; Tue, 24 Apr 2018 12:57:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932858AbeDXC5m (ORCPT ); Mon, 23 Apr 2018 22:57:42 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:41258 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932871AbeDXC5G (ORCPT ); Mon, 23 Apr 2018 22:57:06 -0400 Received: by mail-wr0-f172.google.com with SMTP id g21-v6so18920114wrb.8 for ; Mon, 23 Apr 2018 19:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisn.me.uk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+c+SfV+zFiolS9ElLwxTGmd0MwGQFjZVaNbKRy6imDM=; b=ARQwOrQhLtnIPZFdyBhfZ8tD9ZT5g8M/gX6jBUaPtcuosr2zh3MEOHVkz5nT5j/AZj +dgQd4J7UpeSGoy4hEgNhdOc7SKHDXVZkTXtY6/p+6sbpU5zaDbUIzufk1MwhEWsBDGO p73DtEKiFGmJlBZlQYShDQ7zdAVeqhPAER4b4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+c+SfV+zFiolS9ElLwxTGmd0MwGQFjZVaNbKRy6imDM=; b=T4tY2vWUaQbtQ/bM89v/Br1/35fdjRkPwsMhC65GB6K/I2y+Wx1of5wSFHRSJummVQ 4YnTIyGkNwSkhWqnkhCMKapXwrN8oObpD9cOUFTL8aj1wctoXzyTzLiNeYqDUU7dtJ9a iSi50RMTwOBSepRd41zN22ClCH844Qx9sbp9t9xDd1QesIUGQ014TvIA0D3027RlOMgv hkTWPwUyPnBAkCDPN+BM+ph/ZaZ3p4zVC3xnu2T365ch4qqvUnkrC7zgExdaHgdZ7yRp J7WxwCPh5ebbBgbJHRiTKSwy687a1ajgrG+ikps87L0wzx6/CNaPXdIjZVrM1v10vgHj zNKg== X-Gm-Message-State: ALQs6tCKf0RdBHI2rh7HvhuSOvtFO/LvHC3yxVaS54TDnJYF93qgOdOp CduFM/ittpvSaH6uFjmnSuZHhn39 X-Google-Smtp-Source: AIpwx4/CtIhvJ+ypJAcxtT7u9Vc7h0/DeNuTgAwhhzPhTPswd4Squ8hVsvHxJX6r/yXphwRRhTNuaw== X-Received: by 10.28.213.10 with SMTP id m10mr10071813wmg.72.1524538625033; Mon, 23 Apr 2018 19:57:05 -0700 (PDT) Received: from stronghold.base.iphq.net (cpc83449-wolv18-2-0-cust181.16-1.cable.virginm.net. [82.32.71.182]) by smtp.gmail.com with ESMTPSA id b18-v6sm17407241wrb.55.2018.04.23.19.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 19:57:04 -0700 (PDT) From: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Cc: Chris Novakovic Subject: [PATCH v2 8/8] ipconfig: Write NTP server IPs to /proc/net/ipconfig/ntp_servers Date: Tue, 24 Apr 2018 03:56:39 +0100 Message-Id: <20180424025639.2228-9-chris@chrisn.me.uk> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424025639.2228-1-chris@chrisn.me.uk> References: <20180424025639.2228-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Distributed filesystems are most effective when the server and client clocks are synchronised. Embedded devices often use NFS for their root filesystem but typically do not contain an RTC, so the clocks of the NFS server and the embedded device will be out-of-sync when the root filesystem is mounted (and may not be synchronised until late in the boot process). Extend ipconfig with the ability to export IP addresses of NTP servers it discovers to /proc/net/ipconfig/ntp_servers. They can be supplied as follows: - If ipconfig is configured manually via the "ip=" or "nfsaddrs=" kernel command line parameters, one NTP server can be specified in the new "" parameter. - If ipconfig is autoconfigured via DHCP, request DHCP option 42 in the DHCPDISCOVER message, and record the IP addresses of up to three NTP servers sent by the responding DHCP server in the subsequent DHCPOFFER message. ipconfig will only write the NTP server IP addresses it discovers to /proc/net/ipconfig/ntp_servers, one per line (in the order received from the DHCP server, if DHCP autoconfiguration is used); making use of these NTP servers is the responsibility of a user space process (e.g. an initrd/initram script that invokes an NTP client before mounting an NFS root filesystem). Signed-off-by: Chris Novakovic --- Documentation/filesystems/nfs/nfsroot.txt | 35 +++++++-- net/ipv4/ipconfig.c | 118 +++++++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 17 deletions(-) diff --git a/Documentation/filesystems/nfs/nfsroot.txt b/Documentation/filesystems/nfs/nfsroot.txt index a1030bea60d3..d2963123eb1c 100644 --- a/Documentation/filesystems/nfs/nfsroot.txt +++ b/Documentation/filesystems/nfs/nfsroot.txt @@ -5,6 +5,7 @@ Written 1996 by Gero Kuhlmann Updated 1997 by Martin Mares Updated 2006 by Nico Schottelius Updated 2006 by Horms +Updated 2018 by Chris Novakovic @@ -79,7 +80,7 @@ nfsroot=[:][,] ip=::::::: - : + :: This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It was originally called @@ -178,9 +179,18 @@ ip=::::::: IP address of secondary nameserver. See . - After configuration (whether manual or automatic) is complete, a file is - created at /proc/net/pnp in the following format; lines are omitted if - their respective value is empty following configuration. + IP address of a Network Time Protocol (NTP) server. + Value is exported to /proc/net/ipconfig/ntp_servers, but is + otherwise unused (see below). + + Default: None if not using autoconfiguration; determined + automatically if using autoconfiguration. + + After configuration (whether manual or automatic) is complete, two files + are created in the following format; lines are omitted if their respective + value is empty following configuration: + + - /proc/net/pnp: #PROTO: (depending on configuration method) domain (if autoconfigured, the DNS domain) @@ -189,13 +199,26 @@ ip=::::::: nameserver (tertiary name server IP) bootserver (NFS server IP) - and are requested during autoconfiguration; they - cannot be specified as part of the "ip=" kernel command line parameter. + - /proc/net/ipconfig/ntp_servers: + + (NTP server IP) + (NTP server IP) + (NTP server IP) + + and (in /proc/net/pnp) and and + (in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration; + they cannot be specified as part of the "ip=" kernel command line parameter. Because the "domain" and "nameserver" options are recognised by DNS resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems that use an NFS root filesystem. + Note that the kernel will not synchronise the system time with any NTP + servers it discovers; this is the responsibility of a user space process + (e.g. an initrd/initramfs script that passes the IP addresses listed in + /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real + root filesystem if it is on NFS). + nfsrootdebug diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 9abf833f3a99..d839d74853fc 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -28,6 +28,9 @@ * * Multiple Nameservers in /proc/net/pnp * -- Josef Siemes , Aug 2002 + * + * NTP servers in /proc/net/ipconfig/ntp_servers + * -- Chris Novakovic , April 2018 */ #include @@ -93,6 +96,7 @@ #define CONF_TIMEOUT_MAX (HZ*30) /* Maximum allowed timeout */ #define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers - '3' from resolv.h */ +#define CONF_NTP_SERVERS_MAX 3 /* Maximum number of NTP servers */ #define NONE cpu_to_be32(INADDR_NONE) #define ANY cpu_to_be32(INADDR_ANY) @@ -152,6 +156,7 @@ static int ic_proto_used; /* Protocol used, if any */ #define ic_proto_used 0 #endif static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */ +static __be32 ic_ntp_servers[CONF_NTP_SERVERS_MAX]; /* NTP server IP addresses */ static u8 ic_domain[64]; /* DNS (not NIS) domain name */ /* @@ -579,6 +584,15 @@ static inline void __init ic_nameservers_predef(void) ic_nameservers[i] = NONE; } +/* Predefine NTP servers */ +static inline void __init ic_ntp_servers_predef(void) +{ + int i; + + for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) + ic_ntp_servers[i] = NONE; +} + /* * DHCP/BOOTP support. */ @@ -674,6 +688,7 @@ ic_dhcp_init_options(u8 *options, struct ic_device *d) 17, /* Boot path */ 26, /* MTU */ 40, /* NIS domain name */ + 42, /* NTP servers */ }; *e++ = 55; /* Parameter request list */ @@ -753,12 +768,13 @@ static void __init ic_bootp_init_ext(u8 *e) */ static inline void __init ic_bootp_init(void) { - /* Re-initialise all name servers to NONE, in case any were set via the - * "ip=" or "nfsaddrs=" kernel command line parameters: any IP addresses - * specified there will already have been decoded but are no longer - * needed + /* Re-initialise all name servers and NTP servers to NONE, in case any + * were set via the "ip=" or "nfsaddrs=" kernel command line parameters: + * any IP addresses specified there will already have been decoded but + * are no longer needed */ ic_nameservers_predef(); + ic_ntp_servers_predef(); dev_add_pack(&bootp_packet_type); } @@ -922,6 +938,15 @@ static void __init ic_do_bootp_ext(u8 *ext) ic_bootp_string(utsname()->domainname, ext+1, *ext, __NEW_UTS_LEN); break; + case 42: /* NTP servers */ + servers = *ext / 4; + if (servers > CONF_NTP_SERVERS_MAX) + servers = CONF_NTP_SERVERS_MAX; + for (i = 0; i < servers; i++) { + if (ic_ntp_servers[i] == NONE) + memcpy(&ic_ntp_servers[i], ext+1+4*i, 4); + } + break; } } @@ -1268,6 +1293,7 @@ static int __init ic_dynamic(void) #ifdef CONFIG_PROC_FS +/* Name servers: */ static int pnp_seq_show(struct seq_file *seq, void *v) { int i; @@ -1306,7 +1332,7 @@ static const struct file_operations pnp_seq_fops = { }; /* Create the /proc/net/ipconfig directory */ -static int ipconfig_proc_net_init(void) +static int __init ipconfig_proc_net_init(void) { ipconfig_dir = proc_net_mkdir(&init_net, "ipconfig", init_net.proc_net); if (!ipconfig_dir) @@ -1314,6 +1340,52 @@ static int ipconfig_proc_net_init(void) return 0; } + +/* Create a new file under /proc/net/ipconfig */ +static int ipconfig_proc_net_create(const char *name, + const struct file_operations *fops) +{ + char *pname; + struct proc_dir_entry *p; + + if (!ipconfig_dir) + return -ENOMEM; + + pname = kasprintf(GFP_KERNEL, "%s%s", "ipconfig/", name); + if (!pname) + return -ENOMEM; + + p = proc_create(pname, 0444, init_net.proc_net, fops); + kfree(pname); + if (!p) + return -ENOMEM; + + return 0; +} + +/* Write NTP server IP addresses to /proc/net/ipconfig/ntp_servers */ +static int ntp_servers_seq_show(struct seq_file *seq, void *v) +{ + int i; + + for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) { + if (ic_ntp_servers[i] != NONE) + seq_printf(seq, "%pI4\n", &ic_ntp_servers[i]); + } + return 0; +} + +static int ntp_servers_seq_open(struct inode *inode, struct file *file) +{ + return single_open(file, ntp_servers_seq_show, NULL); +} + +static const struct file_operations ntp_servers_seq_fops = { + .open = ntp_servers_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; #endif /* CONFIG_PROC_FS */ /* @@ -1388,17 +1460,20 @@ static int __init ip_auto_config(void) int err; unsigned int i; - /* Initialise all name servers to NONE (but only if the "ip=" or - * "nfsaddrs=" kernel command line parameters weren't decoded, otherwise - * we'll overwrite the IP addresses specified there) + /* Initialise all name servers and NTP servers to NONE (but only if the + * "ip=" or "nfsaddrs=" kernel command line parameters weren't decoded, + * otherwise we'll overwrite the IP addresses specified there) */ - if (ic_set_manually == 0) + if (ic_set_manually == 0) { ic_nameservers_predef(); + ic_ntp_servers_predef(); + } #ifdef CONFIG_PROC_FS proc_create("pnp", 0444, init_net.proc_net, &pnp_seq_fops); - ipconfig_proc_net_init(); + if (ipconfig_proc_net_init() == 0) + ipconfig_proc_net_create("ntp_servers", &ntp_servers_seq_fops); #endif /* CONFIG_PROC_FS */ if (!ic_enable) @@ -1523,6 +1598,19 @@ static int __init ip_auto_config(void) if (i + 1 == CONF_NAMESERVERS_MAX) pr_cont("\n"); } + /* NTP servers (if any): */ + for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) { + if (ic_ntp_servers[i] != NONE) { + if (i == 0) + pr_info(" ntpserver%u=%pI4", + i, &ic_ntp_servers[i]); + else + pr_cont(", ntpserver%u=%pI4", + i, &ic_ntp_servers[i]); + } + if (i + 1 == CONF_NTP_SERVERS_MAX) + pr_cont("\n"); + } #endif /* !SILENT */ /* @@ -1620,8 +1708,9 @@ static int __init ip_auto_config_setup(char *addrs) return 1; } - /* Initialise all name servers to NONE */ + /* Initialise all name servers and NTP servers to NONE */ ic_nameservers_predef(); + ic_ntp_servers_predef(); /* Parse string for static IP assignment. */ ip = addrs; @@ -1680,6 +1769,13 @@ static int __init ip_auto_config_setup(char *addrs) ic_nameservers[1] = NONE; } break; + case 9: + if (CONF_NTP_SERVERS_MAX >= 1) { + ic_ntp_servers[0] = in_aton(ip); + if (ic_ntp_servers[0] == ANY) + ic_ntp_servers[0] = NONE; + } + break; } } ip = cp;