Commit 5e953778 authored by Christoph Fritz's avatar Christoph Fritz Committed by David S. Miller

ipconfig: add nameserver IPs to kernel-parameter ip=

On small systems (e.g. embedded ones) IP addresses are often configured
by bootloaders and get assigned to kernel via parameter "ip=".  If set to
"ip=dhcp", even nameserver entries from DHCP daemons are handled. These
entries exported in /proc/net/pnp are commonly linked by /etc/resolv.conf.

To configure nameservers for networks without DHCP, this patch adds option
<dns0-ip> and <dns1-ip> to kernel-parameter 'ip='.
Signed-off-by: default avatarChristoph Fritz <chf.fritz@googlemail.com>
Tested-by: default avatarJan Weitzel <j.weitzel@phytec.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42d94dcb
...@@ -78,7 +78,8 @@ nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] ...@@ -78,7 +78,8 @@ nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
flags = hard, nointr, noposix, cto, ac flags = hard, nointr, noposix, cto, ac
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf> ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:
<dns0-ip>:<dns1-ip>
This parameter tells the kernel how to configure IP addresses of devices 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 and also how to set up the IP routing table. It was originally called
...@@ -158,6 +159,13 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf> ...@@ -158,6 +159,13 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
Default: any Default: any
<dns0-ip> IP address of first nameserver.
Value gets exported by /proc/net/pnp which is often linked
on embedded systems by /etc/resolv.conf.
<dns1-ip> IP address of secound nameserver.
Same as above.
nfsrootdebug nfsrootdebug
......
...@@ -743,14 +743,22 @@ static void __init ic_bootp_init_ext(u8 *e) ...@@ -743,14 +743,22 @@ static void __init ic_bootp_init_ext(u8 *e)
/* /*
* Initialize the DHCP/BOOTP mechanism. * Predefine Nameservers
*/ */
static inline void __init ic_bootp_init(void) static inline void __init ic_nameservers_predef(void)
{ {
int i; int i;
for (i = 0; i < CONF_NAMESERVERS_MAX; i++) for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
ic_nameservers[i] = NONE; ic_nameservers[i] = NONE;
}
/*
* Initialize the DHCP/BOOTP mechanism.
*/
static inline void __init ic_bootp_init(void)
{
ic_nameservers_predef();
dev_add_pack(&bootp_packet_type); dev_add_pack(&bootp_packet_type);
} }
...@@ -1379,6 +1387,7 @@ static int __init ip_auto_config(void) ...@@ -1379,6 +1387,7 @@ static int __init ip_auto_config(void)
int retries = CONF_OPEN_RETRIES; int retries = CONF_OPEN_RETRIES;
#endif #endif
int err; int err;
unsigned int i;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops); proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops);
...@@ -1499,7 +1508,15 @@ static int __init ip_auto_config(void) ...@@ -1499,7 +1508,15 @@ static int __init ip_auto_config(void)
&ic_servaddr, &root_server_addr, root_server_path); &ic_servaddr, &root_server_addr, root_server_path);
if (ic_dev_mtu) if (ic_dev_mtu)
pr_cont(", mtu=%d", ic_dev_mtu); pr_cont(", mtu=%d", ic_dev_mtu);
pr_cont("\n"); for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
if (ic_nameservers[i] != NONE) {
pr_info(" nameserver%u=%pI4",
i, &ic_nameservers[i]);
break;
}
for (i++; i < CONF_NAMESERVERS_MAX; i++)
if (ic_nameservers[i] != NONE)
pr_cont(", nameserver%u=%pI4\n", i, &ic_nameservers[i]);
#endif /* !SILENT */ #endif /* !SILENT */
return 0; return 0;
...@@ -1570,6 +1587,8 @@ static int __init ip_auto_config_setup(char *addrs) ...@@ -1570,6 +1587,8 @@ static int __init ip_auto_config_setup(char *addrs)
return 1; return 1;
} }
ic_nameservers_predef();
/* Parse string for static IP assignment. */ /* Parse string for static IP assignment. */
ip = addrs; ip = addrs;
while (ip && *ip) { while (ip && *ip) {
...@@ -1613,6 +1632,20 @@ static int __init ip_auto_config_setup(char *addrs) ...@@ -1613,6 +1632,20 @@ static int __init ip_auto_config_setup(char *addrs)
ic_enable = 0; ic_enable = 0;
} }
break; break;
case 7:
if (CONF_NAMESERVERS_MAX >= 1) {
ic_nameservers[0] = in_aton(ip);
if (ic_nameservers[0] == ANY)
ic_nameservers[0] = NONE;
}
break;
case 8:
if (CONF_NAMESERVERS_MAX >= 2) {
ic_nameservers[1] = in_aton(ip);
if (ic_nameservers[1] == ANY)
ic_nameservers[1] = NONE;
}
break;
} }
} }
ip = cp; ip = cp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment