mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: add nameserver IPs to kernel-parameter ip=
@ 2012-09-22 10:58 Christoph Fritz
  2012-09-22 11:43 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2012-09-22 10:58 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Kernel-parameter "ip=" is used to assign network configuration.
With linux kernel 3.7 it is also possible to set nameserver IPs.

This patch adds two new options (nameserver0 and nameserver1) to
ethernet device parameter. It also updates defaultenv version 1.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 defaultenv/bin/boot |    4 +++-
 defaultenv/config   |    2 ++
 net/eth.c           |    2 ++
 3 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 4e2056e..d5b5844 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -61,7 +61,9 @@ if [ x$ip = xdhcp -o ]; then
 elif [ x$ip = xnone ]; then
 	bootargs="$bootargs ip=none"
 else
-	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
+	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:"
+	bootargs="$bootargs$eth0.netmask::eth0::"
+	bootargs="$bootargs$eth0.nameserver0:$eth0.nameserver1"
 fi
 
 
diff --git a/defaultenv/config b/defaultenv/config
index 391ba47..6596753 100644
--- a/defaultenv/config
+++ b/defaultenv/config
@@ -18,6 +18,8 @@ global.dhcp.vendor_id=barebox
 #eth0.netmask=a.b.c.d
 #eth0.serverip=a.b.c.d
 #eth0.gateway=a.b.c.d
+#eth0.nameserver0=a.b.c.d
+#eth0.nameserver1=a.b.c.d
 
 # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
 kernel_loc=tftp
diff --git a/net/eth.c b/net/eth.c
index d42a72d..bb8157b 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -229,6 +229,8 @@ int eth_register(struct eth_device *edev)
 	dev_add_param(dev, "gateway", eth_set_ipaddr, NULL, 0);
 	dev_add_param(dev, "netmask", eth_set_ipaddr, NULL, 0);
 	dev_add_param(dev, "serverip", eth_set_ipaddr, NULL, 0);
+	dev_add_param(dev, "nameserver0", eth_set_ipaddr, NULL, 0);
+	dev_add_param(dev, "nameserver1", eth_set_ipaddr, NULL, 0);
 
 	edev->init(edev);
 
-- 
1.7.2.5




_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] net: add nameserver IPs to kernel-parameter ip=
  2012-09-22 10:58 [PATCH 1/2] net: add nameserver IPs to kernel-parameter ip= Christoph Fritz
@ 2012-09-22 11:43 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-22 15:41   ` [PATCH 1/2][v2] " Christoph Fritz
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-22 11:43 UTC (permalink / raw)
  To: Christoph Fritz; +Cc: barebox

On 12:58 Sat 22 Sep     , Christoph Fritz wrote:
> Kernel-parameter "ip=" is used to assign network configuration.
> With linux kernel 3.7 it is also possible to set nameserver IPs.
> 
> This patch adds two new options (nameserver0 and nameserver1) to
> ethernet device parameter. It also updates defaultenv version 1.
defaultenv-2 mandatory

v1 is for fix only


> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  defaultenv/bin/boot |    4 +++-
>  defaultenv/config   |    2 ++
>  net/eth.c           |    2 ++
>  3 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
> index 4e2056e..d5b5844 100644
> --- a/defaultenv/bin/boot
> +++ b/defaultenv/bin/boot
> @@ -61,7 +61,9 @@ if [ x$ip = xdhcp -o ]; then
>  elif [ x$ip = xnone ]; then
>  	bootargs="$bootargs ip=none"
>  else
> -	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
> +	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:"
> +	bootargs="$bootargs$eth0.netmask::eth0::"
> +	bootargs="$bootargs$eth0.nameserver0:$eth0.nameserver1"
>  fi
>  
>  
> diff --git a/defaultenv/config b/defaultenv/config
> index 391ba47..6596753 100644
> --- a/defaultenv/config
> +++ b/defaultenv/config
> @@ -18,6 +18,8 @@ global.dhcp.vendor_id=barebox
>  #eth0.netmask=a.b.c.d
>  #eth0.serverip=a.b.c.d
>  #eth0.gateway=a.b.c.d
> +#eth0.nameserver0=a.b.c.d
> +#eth0.nameserver1=a.b.c.d
>  
>  # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
>  kernel_loc=tftp
> diff --git a/net/eth.c b/net/eth.c
> index d42a72d..bb8157b 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -229,6 +229,8 @@ int eth_register(struct eth_device *edev)
>  	dev_add_param(dev, "gateway", eth_set_ipaddr, NULL, 0);
>  	dev_add_param(dev, "netmask", eth_set_ipaddr, NULL, 0);
>  	dev_add_param(dev, "serverip", eth_set_ipaddr, NULL, 0);
> +	dev_add_param(dev, "nameserver0", eth_set_ipaddr, NULL, 0);
> +	dev_add_param(dev, "nameserver1", eth_set_ipaddr, NULL, 0);
this is done via net as the nameserver is not interface specific

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2][v2] net: add nameserver IPs to kernel-parameter ip=
  2012-09-22 11:43 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-22 15:41   ` Christoph Fritz
  2012-09-22 18:24     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-22 18:27     ` [PATCH 1/1] net: add multiple nameserver support Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 11+ messages in thread
From: Christoph Fritz @ 2012-09-22 15:41 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Kernel-parameter "ip=" is used to assign network configuration.
With linux kernel 3.7 it is also possible to set nameserver IPs.

This patch adds two new variables (nameserver0 and nameserver1) to
barebox's $net configuration.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 net/dhcp.c |    2 +-
 net/dns.c  |    4 ++--
 net/net.c  |   18 +++++++++++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 768255e..118a5a6 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -211,7 +211,7 @@ struct dhcp_opt dhcp_options[] = {
 	}, {
 		.option = 6,
 		.handle = env_ip_handle,
-		.barebox_var_name = "net.nameserver",
+		.barebox_var_name = "net.nameserver0",
 	}, {
 		.option = 12,
 		.copy_only_if_valid = 1,
diff --git a/net/dns.c b/net/dns.c
index eb96c57..e832f97 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -206,9 +206,9 @@ IPaddr_t resolv(char *host)
 
 	dns_state = STATE_INIT;
 
-	ns = getenv("net.nameserver");
+	ns = getenv("net.nameserver0");
 	if (!ns || !*ns) {
-		printk("%s: no nameserver specified in $net.nameserver\n",
+		printk("%s: no nameserver specified in $net.nameserver0\n",
 				__func__);
 		return 0;
 	}
diff --git a/net/net.c b/net/net.c
index 3ac098f..171e644 100644
--- a/net/net.c
+++ b/net/net.c
@@ -669,6 +669,21 @@ static struct device_d net_device = {
 	.id = DEVICE_ID_SINGLE,
 };
 
+static int net_set_namesrv(struct device_d *dev, struct param_d *param, const char *val)
+{
+	IPaddr_t ip;
+
+	if (!val)
+		return -EINVAL;
+
+	if (string_to_ip(val, &ip))
+		return -EINVAL;
+
+	dev_param_set_generic(dev, param, val);
+
+	return 0;
+}
+
 static int net_init(void)
 {
 	int i;
@@ -677,7 +692,8 @@ static int net_init(void)
 		NetRxPackets[i] = net_alloc_packet();
 
 	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver0", net_set_namesrv, NULL, 0);
+	dev_add_param(&net_device, "nameserver1", net_set_namesrv, NULL, 0);
 	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
 
 	return 0;
-- 
1.7.2.5




_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2][v2] net: add nameserver IPs to kernel-parameter ip=
  2012-09-22 15:41   ` [PATCH 1/2][v2] " Christoph Fritz
@ 2012-09-22 18:24     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-22 18:27     ` [PATCH 1/1] net: add multiple nameserver support Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-22 18:24 UTC (permalink / raw)
  To: Christoph Fritz; +Cc: barebox

On 17:41 Sat 22 Sep     , Christoph Fritz wrote:
> Kernel-parameter "ip=" is used to assign network configuration.
> With linux kernel 3.7 it is also possible to set nameserver IPs.
> 
> This patch adds two new variables (nameserver0 and nameserver1) to
> barebox's $net configuration.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
this is not the right way to handle this the option 6 of the DHCP allow a dhcp
server to provide n nameserver

so we need to use tehm if provided and if you add nameserver1 we need to use
it for resolve too

patch in reply

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/1] net: add multiple nameserver support
  2012-09-22 15:41   ` [PATCH 1/2][v2] " Christoph Fritz
  2012-09-22 18:24     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-22 18:27     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-22 19:25       ` Christoph Fritz
  1 sibling, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-22 18:27 UTC (permalink / raw)
  To: barebox

Today limit it to 2

Update dhcp support as option 6 allow to get n nameserver
If more than 2 nameserver are provided by the DHCP server ignore them.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 net/dhcp.c |   22 ++++++++++++++++++----
 net/dns.c  |   19 +++++++++++++++----
 net/net.c  |    3 ++-
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 768255e..91d436f 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -137,12 +137,24 @@ static void gateway_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 	net_set_gateway(ip);
 }
 
-static void env_ip_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
+static void env_ip_multiple_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
 {
+	char *var_name;
 	IPaddr_t ip;
+	int i;
+	int max = (int)opt->data;
 
-	ip = net_read_ip(popt);
-	setenv_ip(opt->barebox_var_name, ip);
+	for (i = 0 ; optlen > 0 && i < max; i++) {
+		var_name = asprintf("%s%d", opt->barebox_var_name, i);
+		if (!var_name)
+			return;
+
+		ip = net_read_ip(popt);
+		setenv_ip(var_name, ip);
+		optlen -= 4;
+		popt += 4;
+		free(var_name);
+	}
 }
 
 static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
@@ -210,8 +222,10 @@ struct dhcp_opt dhcp_options[] = {
 		.handle = gateway_handle,
 	}, {
 		.option = 6,
-		.handle = env_ip_handle,
+		.handle = env_ip_multiple_handle,
 		.barebox_var_name = "net.nameserver",
+		/* max today supported, ignore if more */
+		.data = (void*)2,
 	}, {
 		.option = 12,
 		.copy_only_if_valid = 1,
diff --git a/net/dns.c b/net/dns.c
index eb96c57..5cd29a5 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -194,7 +194,7 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
 	}
 }
 
-IPaddr_t resolv(char *host)
+static IPaddr_t resolv_on(char *host, const char* nameserver)
 {
 	IPaddr_t ip;
 	const char *ns;
@@ -206,10 +206,10 @@ IPaddr_t resolv(char *host)
 
 	dns_state = STATE_INIT;
 
-	ns = getenv("net.nameserver");
+	ns = getenv(nameserver);
 	if (!ns || !*ns) {
-		printk("%s: no nameserver specified in $net.nameserver\n",
-				__func__);
+		printk("%s: no nameserver specified in $%s\n",
+				__func__, nameserver);
 		return 0;
 	}
 
@@ -241,6 +241,17 @@ IPaddr_t resolv(char *host)
 	return dns_ip;
 }
 
+IPaddr_t resolv(char *host)
+{
+	IPaddr_t ip;
+
+	ip = resolv_on(host, "net.nameserver0");
+	if (ip == 0)
+		ip = resolv_on(host, "net.nameserver1");
+
+	return ip;
+}
+
 static int do_host(int argc, char *argv[])
 {
 	IPaddr_t ip;
diff --git a/net/net.c b/net/net.c
index 3ac098f..edadf51 100644
--- a/net/net.c
+++ b/net/net.c
@@ -677,7 +677,8 @@ static int net_init(void)
 		NetRxPackets[i] = net_alloc_packet();
 
 	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver0", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver1", NULL, NULL, 0);
 	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
 
 	return 0;
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] net: add multiple nameserver support
  2012-09-22 18:27     ` [PATCH 1/1] net: add multiple nameserver support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-22 19:25       ` Christoph Fritz
  2012-09-22 20:16         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2012-09-22 19:25 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sat, 2012-09-22 at 20:27 +0200, Jean-Christophe PLAGNIOL-VILLARD
wrote:

> +
>  static int do_host(int argc, char *argv[])
>  {
>  	IPaddr_t ip;
> diff --git a/net/net.c b/net/net.c
> index 3ac098f..edadf51 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -677,7 +677,8 @@ static int net_init(void)
>  		NetRxPackets[i] = net_alloc_packet();
>  
>  	register_device(&net_device);
> -	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
> +	dev_add_param(&net_device, "nameserver0", NULL, NULL, 0);
> +	dev_add_param(&net_device, "nameserver1", NULL, NULL, 0);

What do you think about a function that checks if nameserver0/1 is
really an IP, like this:

+static int net_set_namesrv(struct device_d *dev, struct param_d *param, const char *val)
+{
+	IPaddr_t ip;
+
+	if (!val)
+		return -EINVAL;
+
+	if (string_to_ip(val, &ip))
+		return -EINVAL;
+
+	dev_param_set_generic(dev, param, val);
+
+	return 0;
+}
+
 static int net_init(void)
 {
 	int i;
@@ -677,7 +692,8 @@ static int net_init(void)
 		NetRxPackets[i] = net_alloc_packet();
 
 	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver0", net_set_namesrv, NULL, 0);
+	dev_add_param(&net_device, "nameserver1", net_set_namesrv, NULL, 0);
 	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
 
 	return 0;
---

It has the benefit that you get an error message ("set parameter:
Invalid argument") if it's defined wrong.

Thanks,
 -- Christoph


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] net: add multiple nameserver support
  2012-09-22 19:25       ` Christoph Fritz
@ 2012-09-22 20:16         ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-23 12:11           ` [PATCH] " Christoph Fritz
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-22 20:16 UTC (permalink / raw)
  To: Christoph Fritz; +Cc: barebox

On 21:25 Sat 22 Sep     , Christoph Fritz wrote:
> On Sat, 2012-09-22 at 20:27 +0200, Jean-Christophe PLAGNIOL-VILLARD
> wrote:
> 
> > +
> >  static int do_host(int argc, char *argv[])
> >  {
> >  	IPaddr_t ip;
> > diff --git a/net/net.c b/net/net.c
> > index 3ac098f..edadf51 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -677,7 +677,8 @@ static int net_init(void)
> >  		NetRxPackets[i] = net_alloc_packet();
> >  
> >  	register_device(&net_device);
> > -	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
> > +	dev_add_param(&net_device, "nameserver0", NULL, NULL, 0);
> > +	dev_add_param(&net_device, "nameserver1", NULL, NULL, 0);
> 
> What do you think about a function that checks if nameserver0/1 is
> really an IP, like this:
why not I've not strong felling about it

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] net: add multiple nameserver support
  2012-09-22 20:16         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-23 12:11           ` Christoph Fritz
  2012-09-23 13:29             ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2012-09-23 12:11 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD, Sascha Hauer; +Cc: barebox

Today limit it to 2

Update dhcp support as option 6 allow to get n nameserver
If more than 2 nameserver are provided by the DHCP server ignore them.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 net/dhcp.c |   24 +++++++++++++++++++-----
 net/dns.c  |   19 +++++++++++++++----
 net/net.c  |   18 +++++++++++++++++-
 3 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 768255e..91d436f 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -137,12 +137,24 @@ static void gateway_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 	net_set_gateway(ip);
 }
 
-static void env_ip_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
+static void env_ip_multiple_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
 {
+	char *var_name;
 	IPaddr_t ip;
+	int i;
+	int max = (int)opt->data;
 
-	ip = net_read_ip(popt);
-	setenv_ip(opt->barebox_var_name, ip);
+	for (i = 0 ; optlen > 0 && i < max; i++) {
+		var_name = asprintf("%s%d", opt->barebox_var_name, i);
+		if (!var_name)
+			return;
+
+		ip = net_read_ip(popt);
+		setenv_ip(var_name, ip);
+		optlen -= 4;
+		popt += 4;
+		free(var_name);
+	}
 }
 
 static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
@@ -210,8 +222,10 @@ struct dhcp_opt dhcp_options[] = {
 		.handle = gateway_handle,
 	}, {
 		.option = 6,
-		.handle = env_ip_handle,
+		.handle = env_ip_multiple_handle,
 		.barebox_var_name = "net.nameserver",
+		/* max today supported, ignore if more */
+		.data = (void*)2,
 	}, {
 		.option = 12,
 		.copy_only_if_valid = 1,
diff --git a/net/dns.c b/net/dns.c
index eb96c57..5cd29a5 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -194,7 +194,7 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
 	}
 }
 
-IPaddr_t resolv(char *host)
+static IPaddr_t resolv_on(char *host, const char* nameserver)
 {
 	IPaddr_t ip;
 	const char *ns;
@@ -206,10 +206,10 @@ IPaddr_t resolv(char *host)
 
 	dns_state = STATE_INIT;
 
-	ns = getenv("net.nameserver");
+	ns = getenv(nameserver);
 	if (!ns || !*ns) {
-		printk("%s: no nameserver specified in $net.nameserver\n",
-				__func__);
+		printk("%s: no nameserver specified in $%s\n",
+				__func__, nameserver);
 		return 0;
 	}
 
@@ -241,6 +241,17 @@ IPaddr_t resolv(char *host)
 	return dns_ip;
 }
 
+IPaddr_t resolv(char *host)
+{
+	IPaddr_t ip;
+
+	ip = resolv_on(host, "net.nameserver0");
+	if (ip == 0)
+		ip = resolv_on(host, "net.nameserver1");
+
+	return ip;
+}
+
 static int do_host(int argc, char *argv[])
 {
 	IPaddr_t ip;
diff --git a/net/net.c b/net/net.c
index 3ac098f..171e644 100644
--- a/net/net.c
+++ b/net/net.c
@@ -669,6 +669,21 @@ static struct device_d net_device = {
 	.id = DEVICE_ID_SINGLE,
 };
 
+static int net_set_namesrv(struct device_d *dev, struct param_d *param, const char *val)
+{
+	IPaddr_t ip;
+
+	if (!val)
+		return -EINVAL;
+
+	if (string_to_ip(val, &ip))
+		return -EINVAL;
+
+	dev_param_set_generic(dev, param, val);
+
+	return 0;
+}
+
 static int net_init(void)
 {
 	int i;
@@ -677,7 +692,8 @@ static int net_init(void)
 		NetRxPackets[i] = net_alloc_packet();
 
 	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver0", net_set_namesrv, NULL, 0);
+	dev_add_param(&net_device, "nameserver1", net_set_namesrv, NULL, 0);
 	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
 
 	return 0;
-- 
1.7.2.5



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] net: add multiple nameserver support
  2012-09-23 12:11           ` [PATCH] " Christoph Fritz
@ 2012-09-23 13:29             ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-23 13:57               ` Christoph Fritz
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-23 13:29 UTC (permalink / raw)
  To: Christoph Fritz; +Cc: barebox

On 14:11 Sun 23 Sep     , Christoph Fritz wrote:
> Today limit it to 2
> 
> Update dhcp support as option 6 allow to get n nameserver
> If more than 2 nameserver are provided by the DHCP server ignore them.
I rethink about it and no I do not want wo check it the format here

as I plan to make the globalvar more commoon and swtich net to it too

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] net: add multiple nameserver support
  2012-09-23 13:29             ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-23 13:57               ` Christoph Fritz
  2012-12-10 11:23                 ` Christoph Fritz
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2012-09-23 13:57 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sun, 2012-09-23 at 15:29 +0200, Jean-Christophe PLAGNIOL-VILLARD
wrote:
> On 14:11 Sun 23 Sep     , Christoph Fritz wrote:
> > Today limit it to 2
> > 
> > Update dhcp support as option 6 allow to get n nameserver
> > If more than 2 nameserver are provided by the DHCP server ignore them.
> I rethink about it and no I do not want wo check it the format here
> 
> as I plan to make the globalvar more commoon and swtich net to it too
> 

I'm fine when the not modified version gets applied.

You can add a
Tested-by: Christoph Fritz <chf.fritz@googlemail.com>

 Thanks,
   -- Christoph


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] net: add multiple nameserver support
  2012-09-23 13:57               ` Christoph Fritz
@ 2012-12-10 11:23                 ` Christoph Fritz
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Fritz @ 2012-12-10 11:23 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sun, 2012-09-23 at 15:57 +0200, Christoph Fritz wrote:
> On Sun, 2012-09-23 at 15:29 +0200, Jean-Christophe PLAGNIOL-VILLARD
> wrote:
> > On 14:11 Sun 23 Sep     , Christoph Fritz wrote:
> > > Today limit it to 2
> > > 
> > > Update dhcp support as option 6 allow to get n nameserver
> > > If more than 2 nameserver are provided by the DHCP server ignore them.
> > I rethink about it and no I do not want wo check it the format here
> > 
> > as I plan to make the globalvar more commoon and swtich net to it too
> > 
> 
> I'm fine when the not modified version gets applied.
> 
> You can add a
> Tested-by: Christoph Fritz <chf.fritz@googlemail.com>

*ping*, has this patch gotten lost?



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-12-10 11:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-22 10:58 [PATCH 1/2] net: add nameserver IPs to kernel-parameter ip= Christoph Fritz
2012-09-22 11:43 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 15:41   ` [PATCH 1/2][v2] " Christoph Fritz
2012-09-22 18:24     ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 18:27     ` [PATCH 1/1] net: add multiple nameserver support Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 19:25       ` Christoph Fritz
2012-09-22 20:16         ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-23 12:11           ` [PATCH] " Christoph Fritz
2012-09-23 13:29             ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-23 13:57               ` Christoph Fritz
2012-12-10 11:23                 ` Christoph Fritz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox