diff mbox

[U-Boot,2/2] net: send RFC1542 compliant value for bootp requests

Message ID 8e171646-8aa5-491f-b273-217ee9be1480@HUB2.rwth-ad.de
State Accepted
Delegated to: Joe Hershberger
Headers show

Commit Message

Stefan Brüns Aug. 27, 2015, 9:57 p.m. UTC
RFC1542, 3.2:
"The 'secs' field of a BOOTREQUEST message SHOULD represent the
elapsed time, in seconds, since the client sent its first BOOTREQUEST
message.  Note that this implies that the 'secs' field of the first
BOOTREQUEST message SHOULD be set to zero."

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
 net/bootp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Joe Hershberger Sept. 3, 2015, 9:44 p.m. UTC | #1
Hi Stefan,

On Thu, Aug 27, 2015 at 4:57 PM, Stefan Brüns
<stefan.bruens@rwth-aachen.de> wrote:
> RFC1542, 3.2:
> "The 'secs' field of a BOOTREQUEST message SHOULD represent the
> elapsed time, in seconds, since the client sent its first BOOTREQUEST
> message.  Note that this implies that the 'secs' field of the first
> BOOTREQUEST message SHOULD be set to zero."
>
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Oct. 29, 2015, 7:25 p.m. UTC | #2
On Thu, Aug 27, 2015 at 4:57 PM, Stefan Brüns
<stefan.bruens@rwth-aachen.de> wrote:
> RFC1542, 3.2:
> "The 'secs' field of a BOOTREQUEST message SHOULD represent the
> elapsed time, in seconds, since the client sent its first BOOTREQUEST
> message.  Note that this implies that the 'secs' field of the first
> BOOTREQUEST message SHOULD be set to zero."
>
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>

Applied to u-boot-net/master, thanks!
-Joe
diff mbox

Patch

diff --git a/net/bootp.c b/net/bootp.c
index e6eba12..9700e95 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -709,7 +709,11 @@  void bootp_request(void)
 	bp->bp_htype = HWT_ETHER;
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
-	bp->bp_secs = htons(get_timer(0) / 1000);
+	/*
+	 * according to RFC1542, should be 0 on first request, secs since
+	 * first request otherwise
+	 */
+	bp->bp_secs = htons(get_timer(bootp_start) / 1000);
 	zero_ip.s_addr = 0;
 	net_write_ip(&bp->bp_ciaddr, zero_ip);
 	net_write_ip(&bp->bp_yiaddr, zero_ip);
@@ -903,7 +907,7 @@  static void dhcp_send_request_packet(struct bootp_hdr *bp_offer)
 	bp->bp_htype = HWT_ETHER;
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
-	bp->bp_secs = htons(get_timer(0) / 1000);
+	bp->bp_secs = htons(get_timer(bootp_start) / 1000);
 	/* Do not set the client IP, your IP, or server IP yet, since it
 	 * hasn't been ACK'ed by the server yet */