summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorGerhard Sittig <gsi@denx.de>2014-09-12 08:48:15 +0200
committerTom Rini <trini@ti.com>2014-09-16 12:24:00 -0400
commitf395e75e27323cc1ef060f640d0d535ed50e705d (patch)
tree0c514fa5927a04787543e78ccf148734714c7905 /net
parent11b5db67879c1ac0f1c358fb9b791896af189b0a (diff)
net: dns: fix for DNS queries sent to the wrong MAC address
When a DNS query is sent out, the ethernet packet can get directed to the MAC address of a server that was communicated to before. This is wrong when the previously stored MAC address corresponds to a different server's IP address, i.e. when the IP address of the previous and the current communication are different. The error can get reproduced by running a sequence of e.g. a TFTP download and a DNS query, where the TFTP and DNS servers reside on individual machines. The fix is to clear the server's MAC address that might be left from a previous operation, and to fetch the peer's MAC address in a new ARP lookup, before the DNS query is sent. This is the approach taken in other network services, like 8e52533d1095 ("net: tftpsrv: Get correct client MAC address"). Reported-by: Dirk Zimoch <dirk.zimoch@psi.ch> Signed-off-by: Gerhard Sittig <gsi@denx.de>
Diffstat (limited to 'net')
-rw-r--r--net/dns.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/dns.c b/net/dns.c
index ff9ddffc9d0..dd453201504 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -202,5 +202,8 @@ DnsStart(void)
NetSetTimeout(DNS_TIMEOUT, DnsTimeout);
net_set_udp_handler(DnsHandler);
+ /* Clear a previous MAC address, the server IP might have changed. */
+ memset(NetServerEther, 0, sizeof(NetServerEther));
+
DnsSend();
}