From patchwork Fri Sep 12 06:48:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Sittig X-Patchwork-Id: 388519 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 69161140141 for ; Fri, 12 Sep 2014 19:13:26 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7891DA7742; Fri, 12 Sep 2014 11:13:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PfPPQ9GMCAgz; Fri, 12 Sep 2014 11:13:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 94E26A7721; Fri, 12 Sep 2014 11:13:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA83BA7704 for ; Fri, 12 Sep 2014 08:48:41 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IgDuk1Qq6ASy for ; Fri, 12 Sep 2014 08:48:35 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id E1403A7702 for ; Fri, 12 Sep 2014 08:48:30 +0200 (CEST) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3hvSGk3Fm4z3hj1h; Fri, 12 Sep 2014 08:48:30 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3hvSGk2SvFzvjMl; Fri, 12 Sep 2014 08:48:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id ehV3atqkddUT; Fri, 12 Sep 2014 08:48:29 +0200 (CEST) X-Auth-Info: OdD2DMDh/5jPzOG94v3eEJ9uayxJVcZ6GAX0kJ3JR6M= Received: from localhost (kons-4d03e464.pool.mediaWays.net [77.3.228.100]) by mail.mnet-online.de (Postfix) with ESMTPA; Fri, 12 Sep 2014 08:48:29 +0200 (CEST) From: Gerhard Sittig To: u-boot@lists.denx.de Date: Fri, 12 Sep 2014 08:48:15 +0200 Message-Id: <1410504495-13118-1-git-send-email-gsi@denx.de> X-Mailer: git-send-email 1.7.10.4 X-Mailman-Approved-At: Fri, 12 Sep 2014 11:13:18 +0200 Cc: Gerhard Sittig Subject: [U-Boot] [PATCH v2 1/1] net: dns: fix for DNS queries sent to the wrong MAC address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Signed-off-by: Gerhard Sittig --- This patch suffers from a checkpatch warning about CamelCase, which cannot get resolved, as it is a consequence of established identifier names in the network part of the code base. changes in v2: - adjust the recipients lists to include the network custodian - drop an obvious/redundant comment as recommended by Joe Hershberger --- net/dns.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/dns.c b/net/dns.c index ff9ddffc9d0a..dd4532015045 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(); }