mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] dhcp: fix request packet's requested IP option
@ 2015-01-28 23:37 Eric Bénard
  2015-01-28 23:37 ` [PATCH 2/3] dhcp: fix request packet Eric Bénard
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Eric Bénard @ 2015-01-28 23:37 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

In the request packet, we are supposed to copy the IP that the DHCP server
provided in the offer packet so that dhcp_extended can fill the option 50.
There is actually an error in barebox as the pointer to the packet currently
built is used as the source instead of the pointer to the offer packet.
With this patch, barebox now sends a request packet which includes the right
requested IP in option 50.

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 net/dhcp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 9551d60..78440dd 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -579,7 +579,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	/*
 	 * Copy options from OFFER packet if present
 	 */
-	net_copy_ip(&OfferedIP, &bp->bp_yiaddr);
+	net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip,
 				OfferedIP);
 
@@ -745,9 +745,7 @@ static int do_dhcp(int argc, char *argv[])
 	ret = net_udp_bind(dhcp_con, PORT_BOOTPC);
 	if (ret)
 		goto out1;
-
 	net_set_ip(0);
-
 	dhcp_start = get_time_ns();
 	ret = bootp_request(); /* Basically same as BOOTP */
 	if (ret)
-- 
1.9.3


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

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

* [PATCH 2/3] dhcp: fix request packet
  2015-01-28 23:37 [PATCH 1/3] dhcp: fix request packet's requested IP option Eric Bénard
@ 2015-01-28 23:37 ` Eric Bénard
  2015-01-28 23:37 ` [PATCH 3/3] dhcp: fix request packet's seconds elapsed Eric Bénard
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Eric Bénard @ 2015-01-28 23:37 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

we are not supposed to fill ciaddr, yiaddr and siaddr in the request packet.

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 net/dhcp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 78440dd..7f9b989 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -559,9 +559,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	bp->bp_hops = 0;
 	/* FIXME what is this? */
 //	bp->bp_secs = htons(get_timer(0) / CFG_HZ);
-	net_copy_ip(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
-	net_copy_ip(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
-	net_copy_ip(&bp->bp_siaddr, &bp_offer->bp_siaddr);
+
 	/*
 	 * RFC3046 requires Relay Agents to discard packets with
 	 * nonzero and offered giaddr
-- 
1.9.3


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

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

* [PATCH 3/3] dhcp: fix request packet's seconds elapsed
  2015-01-28 23:37 [PATCH 1/3] dhcp: fix request packet's requested IP option Eric Bénard
  2015-01-28 23:37 ` [PATCH 2/3] dhcp: fix request packet Eric Bénard
@ 2015-01-28 23:37 ` Eric Bénard
  2015-01-28 23:42 ` [PATCH v2 1/3] dhcp: fix request packet's requested IP option Eric Bénard
  2015-01-30  8:01 ` [PATCH " Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 0 replies; 7+ messages in thread
From: Eric Bénard @ 2015-01-28 23:37 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

it's done in the discover packet so let's do it also in the request packet.

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 net/dhcp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 7f9b989..2b469a9 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -557,8 +557,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	bp->bp_htype = HWT_ETHER;
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
-	/* FIXME what is this? */
-//	bp->bp_secs = htons(get_timer(0) / CFG_HZ);
+	bp->bp_secs = htons(get_time_ns() >> 30);
 
 	/*
 	 * RFC3046 requires Relay Agents to discard packets with
-- 
1.9.3


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

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

* [PATCH v2 1/3] dhcp: fix request packet's requested IP option
  2015-01-28 23:37 [PATCH 1/3] dhcp: fix request packet's requested IP option Eric Bénard
  2015-01-28 23:37 ` [PATCH 2/3] dhcp: fix request packet Eric Bénard
  2015-01-28 23:37 ` [PATCH 3/3] dhcp: fix request packet's seconds elapsed Eric Bénard
@ 2015-01-28 23:42 ` Eric Bénard
  2015-01-29  7:40   ` Sascha Hauer
  2015-01-30  8:01 ` [PATCH " Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 1 reply; 7+ messages in thread
From: Eric Bénard @ 2015-01-28 23:42 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

In the request packet, we are supposed to copy the IP that the DHCP server
provided in the offer packet so that dhcp_extended can fill the option 50.
There is actually an error in barebox as the pointer to the packet currently
built is used as the source instead of the pointer to the offer packet.
With this patch, barebox now sends a request packet which includes the right
requested IP in option 50.

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
v2 : remove 2 line suppressed by error.

 net/dhcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 9551d60..a22fad0 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -579,7 +579,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	/*
 	 * Copy options from OFFER packet if present
 	 */
-	net_copy_ip(&OfferedIP, &bp->bp_yiaddr);
+	net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip,
 				OfferedIP);
 
-- 
1.9.3


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

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

* Re: [PATCH v2 1/3] dhcp: fix request packet's requested IP option
  2015-01-28 23:42 ` [PATCH v2 1/3] dhcp: fix request packet's requested IP option Eric Bénard
@ 2015-01-29  7:40   ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2015-01-29  7:40 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

On Thu, Jan 29, 2015 at 12:42:18AM +0100, Eric Bénard wrote:
> In the request packet, we are supposed to copy the IP that the DHCP server
> provided in the offer packet so that dhcp_extended can fill the option 50.
> There is actually an error in barebox as the pointer to the packet currently
> built is used as the source instead of the pointer to the offer packet.
> With this patch, barebox now sends a request packet which includes the right
> requested IP in option 50.
> 
> Signed-off-by: Eric Bénard <eric@eukrea.com>

Applied all 3. 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] 7+ messages in thread

* Re: [PATCH 1/3] dhcp: fix request packet's requested IP option
  2015-01-28 23:37 [PATCH 1/3] dhcp: fix request packet's requested IP option Eric Bénard
                   ` (2 preceding siblings ...)
  2015-01-28 23:42 ` [PATCH v2 1/3] dhcp: fix request packet's requested IP option Eric Bénard
@ 2015-01-30  8:01 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-01-30  8:13   ` Eric Bénard
  3 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-30  8:01 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox


> On Jan 29, 2015, at 7:37 AM, Eric Bénard <eric@eukrea.com> wrote:
> 
> In the request packet, we are supposed to copy the IP that the DHCP server
> provided in the offer packet so that dhcp_extended can fill the option 50.
> There is actually an error in barebox as the pointer to the packet currently
> built is used as the source instead of the pointer to the offer packet.
> With this patch, barebox now sends a request packet which includes the right
> requested IP in option 50.
> 
> Signed-off-by: Eric Bénard <eric@eukrea.com>
> ---
> net/dhcp.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/dhcp.c b/net/dhcp.c
> index 9551d60..78440dd 100644
> --- a/net/dhcp.c
> +++ b/net/dhcp.c
> @@ -579,7 +579,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
> 	/*
> 	 * Copy options from OFFER packet if present
> 	 */
> -	net_copy_ip(&OfferedIP, &bp->bp_yiaddr);
> +	net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr);
> 	extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip,
> 				OfferedIP);
> 
> @@ -745,9 +745,7 @@ static int do_dhcp(int argc, char *argv[])
> 	ret = net_udp_bind(dhcp_con, PORT_BOOTPC);
> 	if (ret)
> 		goto out1;
> -
> 	net_set_ip(0);
> -

one fix at a time

I do prefer the empty it make the code more readable

Best Regards,
J.
> 	dhcp_start = get_time_ns();
> 	ret = bootp_request(); /* Basically same as BOOTP */
> 	if (ret)
> -- 
> 1.9.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


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

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

* Re: [PATCH 1/3] dhcp: fix request packet's requested IP option
  2015-01-30  8:01 ` [PATCH " Jean-Christophe PLAGNIOL-VILLARD
@ 2015-01-30  8:13   ` Eric Bénard
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Bénard @ 2015-01-30  8:13 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Le Fri, 30 Jan 2015 16:01:46 +0800,
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit :

> 
> > On Jan 29, 2015, at 7:37 AM, Eric Bénard <eric@eukrea.com> wrote:
> > 
> > In the request packet, we are supposed to copy the IP that the DHCP server
> > provided in the offer packet so that dhcp_extended can fill the option 50.
> > There is actually an error in barebox as the pointer to the packet currently
> > built is used as the source instead of the pointer to the offer packet.
> > With this patch, barebox now sends a request packet which includes the right
> > requested IP in option 50.
> > 
> > Signed-off-by: Eric Bénard <eric@eukrea.com>
> > ---
> > net/dhcp.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/net/dhcp.c b/net/dhcp.c
> > index 9551d60..78440dd 100644
> > --- a/net/dhcp.c
> > +++ b/net/dhcp.c
> > @@ -579,7 +579,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
> > 	/*
> > 	 * Copy options from OFFER packet if present
> > 	 */
> > -	net_copy_ip(&OfferedIP, &bp->bp_yiaddr);
> > +	net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr);
> > 	extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip,
> > 				OfferedIP);
> > 
> > @@ -745,9 +745,7 @@ static int do_dhcp(int argc, char *argv[])
> > 	ret = net_udp_bind(dhcp_con, PORT_BOOTPC);
> > 	if (ret)
> > 		goto out1;
> > -
> > 	net_set_ip(0);
> > -
> 
> one fix at a time
> 
> I do prefer the empty it make the code more readable
> 
then read v2 ;-)

Eric

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

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

end of thread, other threads:[~2015-01-30  8:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 23:37 [PATCH 1/3] dhcp: fix request packet's requested IP option Eric Bénard
2015-01-28 23:37 ` [PATCH 2/3] dhcp: fix request packet Eric Bénard
2015-01-28 23:37 ` [PATCH 3/3] dhcp: fix request packet's seconds elapsed Eric Bénard
2015-01-28 23:42 ` [PATCH v2 1/3] dhcp: fix request packet's requested IP option Eric Bénard
2015-01-29  7:40   ` Sascha Hauer
2015-01-30  8:01 ` [PATCH " Jean-Christophe PLAGNIOL-VILLARD
2015-01-30  8:13   ` Eric Bénard

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