Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Mar 2018 17:41:54 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331251 - stable/11/stand/libsa
Message-ID:  <201803201741.w2KHfs2N053180@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Tue Mar 20 17:41:54 2018
New Revision: 331251
URL: https://svnweb.freebsd.org/changeset/base/331251

Log:
  MFC r330023, r330028: Add MAXWAIT for configuring pxeboot timeout
  
  r330023: libsa: Add MAXWAIT to net for establishing max total timeout
  
  Current timeout behavior is to progress in timeout values from MINTMO to
  MAXTMO in MINTMO steps before finally timing out. This results in a fairly
  long time before operations finally timeout, which may not be ideal for some
  use-cases.
  
  Add MAXWAIT that may be configured along with MINTMO/MAXTMO. If we attempt
  to start our send/recv cycle over again but MAXWAIT > 0 and MAXWAIT seconds
  have already passed, then go ahead and timeout.
  
  This is intended for those that just want to say "timeout after 180 seconds"
  rather than calculate and tweak MINTMO/MAXTMO to get their desired timeout.
  The default is 0, or "progress from MINTMO to MAXTMO with no exception."
  
  This has been modified since review to allow for it to be defined via CFLAGS
  and doing appropriate error checking. Future work may add some Makefile foo
  to respect LOADER_NET_MAXWAIT if it's specified in the environment and pass
  it in as MAXWAIT accordingly.
  
  r330028: libsa: Partially revert r330023
  
  The removal of tmo >= MAXTMO check should not have been done; this is
  specifically what handles timeout if MAXWAIT == 0.

Modified:
  stable/11/stand/libsa/net.c
  stable/11/stand/libsa/net.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/stand/libsa/net.c
==============================================================================
--- stable/11/stand/libsa/net.c	Tue Mar 20 17:39:50 2018	(r331250)
+++ stable/11/stand/libsa/net.c	Tue Mar 20 17:41:54 2018	(r331251)
@@ -77,6 +77,7 @@ sendrecv(struct iodesc *d,
 {
 	ssize_t cc;
 	time_t t, tmo, tlast;
+	time_t tref;
 	long tleft;
 
 #ifdef NET_DEBUG
@@ -87,8 +88,13 @@ sendrecv(struct iodesc *d,
 	tmo = MINTMO;
 	tlast = 0;
 	tleft = 0;
+	tref = getsecs();
 	t = getsecs();
 	for (;;) {
+		if (MAXWAIT > 0 && (getsecs() - tref) >= MAXWAIT) {
+			errno = ETIMEDOUT;
+			return -1;
+		}
 		if (tleft <= 0) {
 			if (tmo >= MAXTMO) {
 				errno = ETIMEDOUT;

Modified: stable/11/stand/libsa/net.h
==============================================================================
--- stable/11/stand/libsa/net.h	Tue Mar 20 17:39:50 2018	(r331250)
+++ stable/11/stand/libsa/net.h	Tue Mar 20 17:41:54 2018	(r331251)
@@ -61,6 +61,20 @@ enum net_proto {
 #define MAXTMO 120	/* seconds */
 #define MINTMO 2	/* seconds */
 
+/*
+ * Maximum wait time for sending and receiving before we give up and timeout.
+ * If set to 0, operations will eventually timeout completely, but send/recv
+ * timeouts must progress exponentially from MINTMO to MAXTMO before final
+ * timeout is hit.
+ */
+#ifndef MAXWAIT
+#define MAXWAIT 0	/* seconds */
+#endif
+
+#if MAXWAIT < 0
+#error MAXWAIT must not be a negative number
+#endif
+
 #define FNAME_SIZE 128
 #define	IFNAME_SIZE 16
 #define RECV_SIZE 1536	/* XXX delete this */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803201741.w2KHfs2N053180>