Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp199082pxj; Tue, 1 Jun 2021 19:13:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0NN9vdTXl0xSb/cY6byhPUTvuMBV8W/MkuILQQXbsgy09qyFThzU2KuNlrJvEawrmM05y X-Received: by 2002:a05:6602:38d:: with SMTP id f13mr2231409iov.109.1622600034025; Tue, 01 Jun 2021 19:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622600034; cv=none; d=google.com; s=arc-20160816; b=T/HJOFdKCI5ZaC2A1I8ljHy/mIMa80//SZfZJ4v2FYLn51Lmwh+PS8KPF0Ea64PSc6 wc3C1UPd6cEV69MM+QnKXcZD9t3uJYaYBcMa+dY1t8MSlfLyoaR3EoiONxbyYNb9doTb 6SJUvcnMKQ73tKh8BJjYVAXavoPsI5v+TmrD2iT2kpA7bqtIN6wqoxW9sUbal/KnWyhL W9ayNrx4QX1GIiAa5wfBNugsmjdltMIFjLChAwO8CxN/vNcbmVcgreIbQrO+Y32bRm/x k4nQIl2ELVNYZJxCA7jbFN9uahGysaZjTPjGFM+Jk7qpSYfq/SDCBRuJByntfbwwScyE drsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=+sdEHRTaAb+hGgKu30zmgeRU6nmtgsa2U5Hh67q9LUQ=; b=CdRUkhggiRBfOHWR3smA95x5FGxpW0bOTyPN5ovL8u8ZiVC0hEDZHGUT0gN8Fpk5yQ H4E2yzhwXgbhMgbAbP/DDBuOOtR8aiXfOP2Jmi0GPcfezSsKzyFhbpFtHxaYHwtn5dWg tlYtA3d+3XFrLPJGogwORdaMU3lNsXQG3QSHfoVD4byjyh1gfg/U542w/TqB7W3SjEKG 14M/hNzsz97qFZLf2uAxzGBDxHF5Gvoj5YhGvNMtAHYFTpG0ORvAA22c48m4B6R3OiT5 X2p7/kpQMRuN0VaZ7Gsa6E86luqop4X/60gNIsU/++qXNcKYK3cqkIKV4Bn62LWUo/hq a5qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si20418346jan.91.2021.06.01.19.13.39; Tue, 01 Jun 2021 19:13:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbhFBBka (ORCPT + 99 others); Tue, 1 Jun 2021 21:40:30 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46593 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbhFBBk3 (ORCPT ); Tue, 1 Jun 2021 21:40:29 -0400 Received: (Authenticated sender: josh@joshtriplett.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id BC56420003; Wed, 2 Jun 2021 01:38:43 +0000 (UTC) Date: Tue, 1 Jun 2021 18:38:41 -0700 From: Josh Triplett To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski Subject: [PATCH] net: ipconfig: Don't override command-line hostnames or domains Message-ID: <3914b427de4886dee28dedbfc1fdf7aa64b612e9.1622597775.git.josh@joshtriplett.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the user specifies a hostname or domain name as part of the ip= command-line option, preserve it and don't overwrite it with one supplied by DHCP/BOOTP. For instance, ip=::::myhostname::dhcp will use "myhostname" rather than ignoring and overwriting it. Fix the comment on ic_bootp_string that suggests it only copies a string "if not already set"; it doesn't have any such logic. Signed-off-by: Josh Triplett --- net/ipv4/ipconfig.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index bc2f6ca97152..816d8aad5a68 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -886,7 +886,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d /* - * Copy BOOTP-supplied string if not already set. + * Copy BOOTP-supplied string */ static int __init ic_bootp_string(char *dest, char *src, int len, int max) { @@ -935,12 +935,15 @@ static void __init ic_do_bootp_ext(u8 *ext) } break; case 12: /* Host name */ - ic_bootp_string(utsname()->nodename, ext+1, *ext, - __NEW_UTS_LEN); - ic_host_name_set = 1; + if (!ic_host_name_set) { + ic_bootp_string(utsname()->nodename, ext+1, *ext, + __NEW_UTS_LEN); + ic_host_name_set = 1; + } break; case 15: /* Domain name (DNS) */ - ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); + if (!ic_domain[0]) + ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); break; case 17: /* Root path */ if (!root_server_path[0]) -- 2.32.0.rc0