mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: dhcp: fix option 54
@ 2018-10-23 13:15 Marcin Niestroj
  2018-10-26  9:44 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Marcin Niestroj @ 2018-10-23 13:15 UTC (permalink / raw)
  To: barebox; +Cc: Marcin Niestroj

Option 54 (Server Identifier) is something different than
SIADDR (Server IP address). Currently they are used
interchangeably. This causes DHCPNAK with DHCP servers that
have configured different values for each field.

Create new 'dhcp_serverip' field in 'struct dhcp_result', so we treat
option 54 separately. This fixes DHCP requests for servers that send
two different values for SIADDR and option 54 in DHCPOFFER.

Fixes: 528298b702a0 ("net: dhcp: rework")
Fixes: e18cc5b7e9ce ("DHCP: fix option 54 passing")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
 include/dhcp.h | 1 +
 net/dhcp.c     | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/dhcp.h b/include/dhcp.h
index ce5ed61c6..0dced8e9f 100644
--- a/include/dhcp.h
+++ b/include/dhcp.h
@@ -28,6 +28,7 @@ struct dhcp_result {
 	IPaddr_t gateway;
 	IPaddr_t nameserver;
 	IPaddr_t serverip;
+	IPaddr_t dhcp_serverip;
 	char *hostname;
 	char *domainname;
 	char *rootpath;
diff --git a/net/dhcp.c b/net/dhcp.c
index 427d80a5a..79aa75d87 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -300,7 +300,7 @@ static void dhcp_options_handle(unsigned char option, void *popt,
 			net_copy_uint32(&dhcp_result->leasetime, popt);
 			break;
 		case 54:
-			dhcp_result->serverip = net_read_ip(popt);
+			dhcp_result->dhcp_serverip = net_read_ip(popt);
 			break;
 		case 66:
 			dhcp_result->tftp_server_name = xstrndup(popt, optlen);
@@ -378,8 +378,8 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	/*
 	 * Copy options from OFFER packet if present
 	 */
-	extlen = dhcp_extended(bp->bp_vend, DHCP_REQUEST, dhcp_result->serverip,
-				dhcp_result->ip);
+	extlen = dhcp_extended(bp->bp_vend, DHCP_REQUEST,
+			dhcp_result->dhcp_serverip, dhcp_result->ip);
 
 	debug("Transmitting DHCPREQUEST packet\n");
 	net_udp_send(dhcp_con, sizeof(*bp) + extlen);
-- 
2.19.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] net: dhcp: fix option 54
  2018-10-23 13:15 [PATCH] net: dhcp: fix option 54 Marcin Niestroj
@ 2018-10-26  9:44 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-10-26  9:44 UTC (permalink / raw)
  To: Marcin Niestroj; +Cc: barebox

On Tue, Oct 23, 2018 at 03:15:31PM +0200, Marcin Niestroj wrote:
> Option 54 (Server Identifier) is something different than
> SIADDR (Server IP address). Currently they are used
> interchangeably. This causes DHCPNAK with DHCP servers that
> have configured different values for each field.
> 
> Create new 'dhcp_serverip' field in 'struct dhcp_result', so we treat
> option 54 separately. This fixes DHCP requests for servers that send
> two different values for SIADDR and option 54 in DHCPOFFER.
> 
> Fixes: 528298b702a0 ("net: dhcp: rework")
> Fixes: e18cc5b7e9ce ("DHCP: fix option 54 passing")
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
> ---
>  include/dhcp.h | 1 +
>  net/dhcp.c     | 6 +++---
>  2 files changed, 4 insertions(+), 3 deletions(-)

Tested here, still works for me. Other than that I must say I do not
fully overview the impact of this patch, so I just hope for the best ;)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-10-26  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 13:15 [PATCH] net: dhcp: fix option 54 Marcin Niestroj
2018-10-26  9:44 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox