diff mbox

[U-Boot] Fix dns command

Message ID 1b4b9d1ea8013cd6e0cf73f83496e3e1.squirrel@www.inft.de
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Commit Message

Mathias Adam Nov. 23, 2011, 4:27 p.m. UTC
The dns command didn't perform an ARP query to get the MAC address of
the DNS server if a MAC address was already stored in NetServerEther.
In that case the stored address was used no matter what IP address it
belongs to.

With this patch, NetServerEther is being cleared before a DNS query to
force an ARP request.

Signed-off-by: Mathias Adam <m.adam--uboot at adamis.de>
---
 net/dns.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Comments

Graeme Russ Nov. 23, 2011, 8:59 p.m. UTC | #1
Hi Mathias,

On Thu, Nov 24, 2011 at 3:27 AM, Mathias Adam <m.adam--uboot@adamis.de> wrote:
> The dns command didn't perform an ARP query to get the MAC address of
> the DNS server if a MAC address was already stored in NetServerEther.
> In that case the stored address was used no matter what IP address it
> belongs to.
>
> With this patch, NetServerEther is being cleared before a DNS query to
> force an ARP request.
>
> Signed-off-by: Mathias Adam <m.adam--uboot at adamis.de>
> ---
>  net/dns.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/net/dns.c b/net/dns.c
> index 7a3f1f9..9d79d7d 100644
> --- a/net/dns.c
> +++ b/net/dns.c
> @@ -202,5 +202,8 @@ DnsStart(void)
>        NetSetTimeout(DNS_TIMEOUT, DnsTimeout);
>        NetSetHandler(DnsHandler);
>
> +       /* zero out server ether in case the server ip has changed */
> +       memset(NetServerEther, 0, 6);
> +
>        DnsSend();
>  }

Why not do this at the start of net-loop - It may introduce more ARP
requests, but at least any new protocols will autmatically avoid the
bug you are experiencing

You could cache the IP address which matches NetServerEther to avoid
the ARP when doing the same command repeatedly

Regards,

Graeme
diff mbox

Patch

diff --git a/net/dns.c b/net/dns.c
index 7a3f1f9..9d79d7d 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -202,5 +202,8 @@  DnsStart(void)
 	NetSetTimeout(DNS_TIMEOUT, DnsTimeout);
 	NetSetHandler(DnsHandler);

+	/* zero out server ether in case the server ip has changed */
+	memset(NetServerEther, 0, 6);
+
 	DnsSend();
 }