]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: bootp: Ignore packets whose yiaddr is 0
authorPeng Fan <peng.fan@nxp.com>
Thu, 7 Jan 2016 07:28:23 +0000 (15:28 +0800)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 28 Jan 2016 18:22:23 +0000 (12:22 -0600)
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 <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Wolfgang Denk <wd@denx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/bootp.c

index 8aeddb08ea83f0bf1094d9cb72938df4357801dc..8da2e9b8b43fd7aa8eb37b666d2aacbbb20720cc 100644 (file)
@@ -995,6 +995,9 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
        debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: "
              "%d\n", src, dest, len, dhcp_state);
 
+       if (net_read_ip(&bp->bp_yiaddr).s_addr == 0)
+               return;
+
        switch (dhcp_state) {
        case SELECTING:
                /*