Commit a3d7813b authored by Josef Siemes's avatar Josef Siemes Committed by David S. Miller

net/ipv4/ipconfig.c: Add support for multiple nameservers.

parent a9799084
......@@ -26,6 +26,9 @@
*
* Merged changes from 2.2.19 into 2.4.3
* -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
*
* Multipe Nameservers in /proc/net/pnp
* -- Josef Siemes <jsiemes@web.de>, Aug 2002
*/
#include <linux/config.h>
......@@ -91,6 +94,8 @@
#define CONF_TIMEOUT_RANDOM (HZ) /* Maximum amount of randomization */
#define CONF_TIMEOUT_MULT *7/4 /* Rate of timeout growth */
#define CONF_TIMEOUT_MAX (HZ*30) /* Maximum allowed timeout */
#define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers
- '3' from resolv.h */
/*
......@@ -132,7 +137,7 @@ u8 root_server_path[256] __initdata = { 0, }; /* Path to mount as root */
/* Persistent data: */
int ic_proto_used; /* Protocol used, if any */
u32 ic_nameserver = INADDR_NONE; /* DNS Server IP address */
u32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
u8 ic_domain[64]; /* DNS (not NIS) domain name */
/*
......@@ -625,6 +630,11 @@ static void __init ic_bootp_init_ext(u8 *e)
*/
static inline void ic_bootp_init(void)
{
int i;
for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
ic_nameservers[i] = INADDR_NONE;
dev_add_pack(&bootp_packet_type);
}
......@@ -729,6 +739,9 @@ static int __init ic_bootp_string(char *dest, char *src, int len, int max)
*/
static void __init ic_do_bootp_ext(u8 *ext)
{
u8 servers;
int i;
#ifdef IPCONFIG_DEBUG
u8 *c;
......@@ -748,8 +761,13 @@ static void __init ic_do_bootp_ext(u8 *ext)
memcpy(&ic_gateway, ext+1, 4);
break;
case 6: /* DNS server */
if (ic_nameserver == INADDR_NONE)
memcpy(&ic_nameserver, ext+1, 4);
servers= *ext/4;
if (servers > CONF_NAMESERVERS_MAX)
servers = CONF_NAMESERVERS_MAX;
for (i = 0; i < servers; i++) {
if (ic_nameservers[i] == INADDR_NONE)
memcpy(&ic_nameservers[i], ext+1+4*i, 4);
}
break;
case 12: /* Host name */
ic_bootp_string(system_utsname.nodename, ext+1, *ext, __NEW_UTS_LEN);
......@@ -914,8 +932,8 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
ic_servaddr = b->server_ip;
if (ic_gateway == INADDR_NONE && b->relay_ip)
ic_gateway = b->relay_ip;
if (ic_nameserver == INADDR_NONE)
ic_nameserver = ic_servaddr;
if (ic_nameservers[0] == INADDR_NONE)
ic_nameservers[0] = ic_servaddr;
ic_got_reply = IC_BOOTP;
drop:
......@@ -1078,6 +1096,7 @@ static int pnp_get_info(char *buffer, char **start,
off_t offset, int length)
{
int len;
int i;
if (ic_proto_used & IC_PROTO)
sprintf(buffer, "#PROTO: %s\n",
......@@ -1090,9 +1109,12 @@ static int pnp_get_info(char *buffer, char **start,
if (ic_domain[0])
len += sprintf(buffer + len,
"domain %s\n", ic_domain);
if (ic_nameserver != INADDR_NONE)
for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
if (ic_nameservers[i] != INADDR_NONE)
len += sprintf(buffer + len,
"nameserver %u.%u.%u.%u\n", NIPQUAD(ic_nameserver));
"nameserver %u.%u.%u.%u\n",
NIPQUAD(ic_nameservers[i]));
}
if (offset > len)
offset = len;
......
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