From patchwork Mon Jan 4 02:49:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 562227 X-Patchwork-Delegate: joe.hershberger@gmail.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 6520D1402DE for ; Mon, 4 Jan 2016 13:51:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=k7GcQCYs; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F2E194B7FB; Mon, 4 Jan 2016 03:51:21 +0100 (CET) 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 QwhEPn3GZThj; Mon, 4 Jan 2016 03:51:21 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C1694B7DF; Mon, 4 Jan 2016 03:51:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8CCBA4B7DF for ; Mon, 4 Jan 2016 03:51:19 +0100 (CET) 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 dAwkVj35dnu9 for ; Mon, 4 Jan 2016 03:51:19 +0100 (CET) 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-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by theia.denx.de (Postfix) with ESMTPS id 159734B7DE for ; Mon, 4 Jan 2016 03:51:14 +0100 (CET) Received: by mail-pa0-f51.google.com with SMTP id yy13so97217203pab.3 for ; Sun, 03 Jan 2016 18:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IxefsdtVWkce/8BlNl+0SQ4ey8OxMBL0XrIuw9eHV1I=; b=k7GcQCYs/yQ4UE4eq9Nk9HWhqViAwdYc0MaC1dcYU5y2z89GoZ/gdqcBIQ8oray2to NLxLEAllqMQJvYK/FGB6yzQpvHXMJ6fEPjJpt2PREycEE4cDAa11qK+dOKEZtsTUT+oG SjE5OaSclEZH5Hzk/UwdY4QkFKXCsKrlsEz7T2s7FSaxQ6YEFedOJDKqQ5vXwJ3JJpQt +jbBfPRA86KmjP7KjPbq/wDKSgLI4T4EYx2yS8lA9MnfkyjLJ8rT6Jq4S6hb2cANNTfn ct7RhsPd8MCCjtVhGpRs6W10VqWYWCRCNaQakieq/8XQbSaTbSgFlXjDCa8mWI/Z4XAe 6qSA== X-Received: by 10.66.233.73 with SMTP id tu9mr124005191pac.52.1451875872908; Sun, 03 Jan 2016 18:51:12 -0800 (PST) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 188sm8230345pfa.92.2016.01.03.18.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jan 2016 18:51:12 -0800 (PST) From: Peng Fan X-Google-Original-From: Peng Fan To: u-boot@lists.denx.de Date: Mon, 4 Jan 2016 10:49:56 +0800 Message-Id: <1451875796-15860-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.2 Cc: Joe Hershberger Subject: [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When doing `dhcp`, there is a bad dhcp server in my network which always reply dhcp request with yiaddr 0, which cause uboot can not successfully get ipaddr from the good dhcp server. But the Linux PC can get the ip address even if there is a bad dhcp server. This patch is to fix that even if there is a bad dhcp server, uboot can still get ipaddr and tftp work ok. The way is to ignore the packets from the bad dhcp server by filtering out the yiaddr whose value is 0. Signed-off-by: Peng Fan Cc: Joe Hershberger --- net/bootp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bootp.c b/net/bootp.c index 8aeddb0..ff2ebbe 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -992,6 +992,9 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip, if (check_reply_packet(pkt, dest, src, len)) return; + if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) + return; + debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: " "%d\n", src, dest, len, dhcp_state);