mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 11/11] net: dhcp: introduce global serverip variable
Date: Mon, 26 Sep 2011 11:57:34 +0200	[thread overview]
Message-ID: <20110926095734.GQ31404@pengutronix.de> (raw)
In-Reply-To: <1316984054-31295-12-git-send-email-w.sang@pengutronix.de>

On Sun, Sep 25, 2011 at 10:54:14PM +0200, Wolfram Sang wrote:
> Sometimes, the TFTP/NFS server is different from the DHCP server. To handle
> such situations, a global 'serverip' variable is introduced. If present and set
> with a valid IP address, it will be used instead of the address returned by the
> DHCP server.

Just had some offline discussion with Wolfram. We came to agree that
it's not a good idea to introduce a global 'serverip' variable in C
code. That said we have problems in this area. We currently use
eth0.serverip for several ips which should be really different ones.
In case of dhcp eth0.serverip is set to the ip the dhcp server
returns which is then used as tftp server and rootnfs server. This
does not match setups where you don't have control over the dhcp
server.

So we really should have tftp_serverip, rootfs_serverip and the ip
returned from the dhcp server. Throw multiple ethernet devices into
the mix and things even get more complicated. We need to do something
about it but I feel that we should do a more complete solution instead
of a quick hack to solve the problem. I have no good idea what to do
though :(

Sascha

> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
>  defaultenv/config |    3 ++-
>  net/dhcp.c        |    7 +++++--
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/defaultenv/config b/defaultenv/config
> index 0aaead5..235deca 100644
> --- a/defaultenv/config
> +++ b/defaultenv/config
> @@ -9,11 +9,12 @@ machine=FIXME
>  # use 'dhcp' to do dhcp in barebox and in kernel
>  # use 'none' if you want to skip kernel ip autoconfiguration
>  ip=dhcp
> +# IP of the TFTP/NFS-server. If empty (or invalid), DHCP server will be used
> +#serverip=a.b.c.d
>  
>  # or set your networking parameters here
>  #eth0.ipaddr=a.b.c.d
>  #eth0.netmask=a.b.c.d
> -#eth0.serverip=a.b.c.d
>  #eth0.gateway=a.b.c.d
>  
>  # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
> diff --git a/net/dhcp.c b/net/dhcp.c
> index d1781bc..899c873 100644
> --- a/net/dhcp.c
> +++ b/net/dhcp.c
> @@ -113,8 +113,11 @@ static void bootp_copy_net_params(struct bootp *bp)
>  	tmp_ip = net_read_ip(&bp->bp_yiaddr);
>  	net_set_ip(tmp_ip);
>  
> -	tmp_ip = net_read_ip(&bp->bp_siaddr);
> -	if (tmp_ip != 0)
> +	tmp_ip = getenv_ip("serverip");
> +	if (!tmp_ip)
> +		tmp_ip = net_read_ip(&bp->bp_siaddr);
> +
> +	if (tmp_ip)
>  		net_set_serverip(tmp_ip);
>  
>  	if (strlen(bp->bp_file) > 0)
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

      reply	other threads:[~2011-09-26  9:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
2011-09-25 20:54 ` [PATCH 01/11] defaultenv: simplify scripting Wolfram Sang
2011-09-25 20:54 ` [PATCH 02/11] defaultenv: boot: add backwards compatibility for kernel_loc=net Wolfram Sang
2011-09-25 20:54 ` [PATCH 03/11] defaultenv: boot: add eth0 to ip configuration Wolfram Sang
2011-09-25 20:54 ` [PATCH 04/11] defaultenv: boot: add serverip to static " Wolfram Sang
2011-09-25 20:54 ` [PATCH 05/11] defaultenv: boot: add support to boot from disk Wolfram Sang
2011-09-25 20:54 ` [PATCH 06/11] defaultenv: update: add support to update kernel on disk Wolfram Sang
2011-09-25 20:54 ` [PATCH 07/11] defaultenv: add config template Wolfram Sang
2011-09-25 20:54 ` [PATCH 08/11] net: string_to_ip: add sanity check for > 255 Wolfram Sang
2011-09-25 20:54 ` [PATCH 09/11] net: getenv_ip: check return value of string_to_ip Wolfram Sang
2011-09-25 20:54 ` [PATCH 10/11] defaultenv: place eth0.ethaddr more visibly Wolfram Sang
2011-09-25 20:54 ` [PATCH 11/11] net: dhcp: introduce global serverip variable Wolfram Sang
2011-09-26  9:57   ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110926095734.GQ31404@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=w.sang@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox