Skip to contentSkip to conversation

net: bootp: Ignore packets whose yiaddr is 0

PATCH Superseded Peng Fan 4 participants 5 messages Jan 7, 2016 – Jan 29, 2016 Networking

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/1 net: bootp: Ignore packets whose yiaddr is 0

From: Peng Fan <[email protected]>

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.

Cc Joe Hershberger <[email protected]>

---

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

 net/bootp.c | 3 +++
 1 file changed, 3 insertions(+)
net/bootp.c +3 -0
index 8aeddb0..8da2e9b 100644
@@ -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:
 		/*
Signature · 1 line
2.6.2
#1 lore raw

PATCH v2 1/1 net: bootp: Ignore packets whose yiaddr is 0

Dear Peng Fan,

Quoted 12 lines · In message <[email protected]> you wrote:

From: Peng Fan <[email protected]>

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.

Quoted 6 lines
Cc Joe Hershberger <[email protected]>

---

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

THanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
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
author
#2 lore raw

PATCH v2 1/1 net: bootp: Ignore packets whose yiaddr is 0

Gentle ping..

Regards,
Peng.

Quoted 37 lines · Wolfgang Denk

Dear Peng Fan,

Quoted 12 lines · In message <[email protected]> you wrote:

From: Peng Fan <[email protected]>

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.

Quoted 6 lines
Cc Joe Hershberger <[email protected]>

---

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

THanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
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
#3 lore raw

PATCH v2 1/1 net: bootp: Ignore packets whose yiaddr is 0

In reply to Peng Fan
Quoted 9 lines · Peng Fan

From: Peng Fan <[email protected]>

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.

Quoted 5 lines

The way is to ignore the packets from the bad dhcp server by filtering out the yiaddr whose value is 0.

Cc Joe Hershberger <[email protected]>