All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0
@ 2016-01-07  7:28 Peng Fan
  2016-01-07 16:09 ` Wolfgang Denk
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Peng Fan @ 2016-01-07  7:28 UTC (permalink / raw)
  To: u-boot

From: Peng Fan <peng.fan@nxp.com>

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>
---

Changes V2:
 Take Wolfgang's suggestion, move the code after debug message.

 net/bootp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bootp.c b/net/bootp.c
index 8aeddb0..8da2e9b 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -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:
 		/*
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0
  2016-01-07  7:28 [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
@ 2016-01-07 16:09 ` Wolfgang Denk
  2016-01-25  1:50   ` Peng Fan
  2016-01-25 14:59 ` Joe Hershberger
  2016-01-29 21:26 ` [U-Boot] " Joe Hershberger
  2 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2016-01-07 16:09 UTC (permalink / raw)
  To: u-boot

Dear Peng Fan,

In message <1452151703-30647-1-git-send-email-van.freenix@gmail.com> you wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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>
> ---
> 
> Changes V2:
>  Take Wolfgang's suggestion, move the code after debug message.

THanks.

Reviewed-by: Wolfgang Denk <wd@denx.de>

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
About the use of language: it is impossible to sharpen a pencil  with
a  blunt  ax.  It is equally vain to try to do it with ten blunt axes
instead.                                           -- Edsger Dijkstra

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0
  2016-01-07 16:09 ` Wolfgang Denk
@ 2016-01-25  1:50   ` Peng Fan
  0 siblings, 0 replies; 5+ messages in thread
From: Peng Fan @ 2016-01-25  1:50 UTC (permalink / raw)
  To: u-boot

Gentle ping..

Regards,
Peng.

On Thu, Jan 07, 2016 at 05:09:04PM +0100, Wolfgang Denk wrote:
>Dear Peng Fan,
>
>In message <1452151703-30647-1-git-send-email-van.freenix@gmail.com> you wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>> 
>> 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>
>> ---
>> 
>> Changes V2:
>>  Take Wolfgang's suggestion, move the code after debug message.
>
>THanks.
>
>Reviewed-by: Wolfgang Denk <wd@denx.de>
>
>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
>About the use of language: it is impossible to sharpen a pencil  with
>a  blunt  ax.  It is equally vain to try to do it with ten blunt axes
>instead.                                           -- Edsger Dijkstra

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0
  2016-01-07  7:28 [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
  2016-01-07 16:09 ` Wolfgang Denk
@ 2016-01-25 14:59 ` Joe Hershberger
  2016-01-29 21:26 ` [U-Boot] " Joe Hershberger
  2 siblings, 0 replies; 5+ messages in thread
From: Joe Hershberger @ 2016-01-25 14:59 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 7, 2016 at 1:28 AM, Peng Fan <van.freenix@gmail.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> 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>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] net: bootp: Ignore packets whose yiaddr is 0
  2016-01-07  7:28 [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
  2016-01-07 16:09 ` Wolfgang Denk
  2016-01-25 14:59 ` Joe Hershberger
@ 2016-01-29 21:26 ` Joe Hershberger
  2 siblings, 0 replies; 5+ messages in thread
From: Joe Hershberger @ 2016-01-29 21:26 UTC (permalink / raw)
  To: u-boot

Hi Peng,

https://patchwork.ozlabs.org/patch/564188/ was applied to u-boot-net.git.

Thanks!
-Joe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-29 21:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07  7:28 [U-Boot] [PATCH V2] net: bootp: Ignore packets whose yiaddr is 0 Peng Fan
2016-01-07 16:09 ` Wolfgang Denk
2016-01-25  1:50   ` Peng Fan
2016-01-25 14:59 ` Joe Hershberger
2016-01-29 21:26 ` [U-Boot] " Joe Hershberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.