Commit c72955f7 authored by Josh Triplett's avatar Josh Triplett Committed by Yang Yingliang
Browse files

net: ipconfig: Don't override command-line hostnames or domains



stable inclusion
from linux-4.19.196
commit 51c0007f4c6b88f22c2a5bfb099d7654f0db973c

--------------------------------

[ Upstream commit b508d5fb ]

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: default avatarJosh Triplett <josh@joshtriplett.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 64f9baad
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -866,7 +866,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)
static int __init ic_bootp_string(char *dest, char *src, int len, int max)
{
{
@@ -915,11 +915,14 @@ static void __init ic_do_bootp_ext(u8 *ext)
		}
		}
		break;
		break;
	case 12:	/* Host name */
	case 12:	/* Host name */
		if (!ic_host_name_set) {
			ic_bootp_string(utsname()->nodename, ext+1, *ext,
			ic_bootp_string(utsname()->nodename, ext+1, *ext,
					__NEW_UTS_LEN);
					__NEW_UTS_LEN);
			ic_host_name_set = 1;
			ic_host_name_set = 1;
		}
		break;
		break;
	case 15:	/* Domain name (DNS) */
	case 15:	/* Domain name (DNS) */
		if (!ic_domain[0])
			ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
			ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
		break;
		break;
	case 17:	/* Root path */
	case 17:	/* Root path */