From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Novakovic Subject: [PATCH 4/8] ipconfig: BOOTP: Request CONF_NAMESERVERS_MAX name servers Date: Sat, 7 Apr 2018 05:08:59 +0100 Message-ID: <20180407040903.8997-5-chris@chrisn.me.uk> References: <20180407040903.8997-1-chris@chrisn.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Chris Novakovic To: "David S. Miller" , netdev@vger.kernel.org Return-path: Received: from mail-wm0-f68.google.com ([74.125.82.68]:52639 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbeDGEJj (ORCPT ); Sat, 7 Apr 2018 00:09:39 -0400 Received: by mail-wm0-f68.google.com with SMTP id g8so6837308wmd.2 for ; Fri, 06 Apr 2018 21:09:39 -0700 (PDT) In-Reply-To: <20180407040903.8997-1-chris@chrisn.me.uk> Sender: netdev-owner@vger.kernel.org List-ID: 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; -- 2.14.1