* [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0
@ 2016-01-04 2:49 Peng Fan
2016-01-06 23:49 ` Wolfgang Denk
0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan @ 2016-01-04 2:49 UTC (permalink / raw)
To: 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 <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
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);
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0
2016-01-04 2:49 [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
@ 2016-01-06 23:49 ` Wolfgang Denk
2016-01-07 5:46 ` Peng Fan
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2016-01-06 23:49 UTC (permalink / raw)
To: u-boot
Dear Peng Fan,
In message <1451875796-15860-1-git-send-email-peng.fan@nxp.com> you wrote:
> 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>
> ---
> 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);
I suggest the return should be done _after_ the debug message.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race is a race of cowards; and I am not only marching in
that procession but carrying a banner. - Mark Twain
^ permalink raw reply [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0
2016-01-06 23:49 ` Wolfgang Denk
@ 2016-01-07 5:46 ` Peng Fan
0 siblings, 0 replies; 3+ messages in thread
From: Peng Fan @ 2016-01-07 5:46 UTC (permalink / raw)
To: u-boot
Hi Wolfgang,
On Thu, Jan 07, 2016 at 12:49:42AM +0100, Wolfgang Denk wrote:
>Dear Peng Fan,
>
>In message <1451875796-15860-1-git-send-email-peng.fan@nxp.com> you wrote:
>> 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>
>> ---
>> 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);
>
>I suggest the return should be done _after_ the debug message.
Yeah. Good suggestion. Will do this in V2.
Thanks,
Peng.
>
>Best regards,
>
>Wolfgang Denk
>
>--
>DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
>HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
>The human race is a race of cowards; and I am not only marching in
>that procession but carrying a banner. - Mark Twain
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-07 5:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-04 2:49 [U-Boot] [PATCH] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
2016-01-06 23:49 ` Wolfgang Denk
2016-01-07 5:46 ` Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox