From: Roy Marples Date: Wed, 2 Sep 2020 08:56:32 +0000 (+0100) Subject: DHCP: allow leasetime -1 to represent infinity X-Git-Tag: v9.2.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47985cc0f14356a033fb47dc878084a088446b3e;p=thirdparty%2Fdhcpcd.git DHCP: allow leasetime -1 to represent infinity Easier to enter than 4294967295 seconds which is the real representation of infinity. --- diff --git a/src/dhcpcd.8.in b/src/dhcpcd.8.in index 8704e245..9309250a 100644 --- a/src/dhcpcd.8.in +++ b/src/dhcpcd.8.in @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 31, 2020 +.Dd September 2, 2020 .Dt DHCPCD 8 .Os .Sh NAME @@ -385,8 +385,10 @@ If no interfaces are left running, .Nm will exit. .It Fl l , Fl Fl leasetime Ar seconds -Request a specific lease time in +Request a lease time of .Ar seconds . +.Ar -1 +represents an infinite lease time. By default .Nm does not request any lease time and leaves it in the hands of the diff --git a/src/dhcpcd.conf.5.in b/src/dhcpcd.conf.5.in index 071bef49..998f99e9 100644 --- a/src/dhcpcd.conf.5.in +++ b/src/dhcpcd.conf.5.in @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 18, 2020 +.Dd September 2, 2020 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -448,8 +448,14 @@ Enables IPv6 Router Advertisement solicitation. This is on by default, but is documented here in the case where it is disabled globally but needs to be enabled for one interface. .It Ic leasetime Ar seconds -Request a leasetime of +Request a lease time of .Ar seconds . +.Ar -1 +represents an infinite lease time. +By default +.Nm dhcpcd +does not request any lease time and leaves it in the hands of the +DHCP server. .It Ic link_rcvbuf Ar size Override the size of the link receive buffer from the kernel default. While diff --git a/src/if-options.c b/src/if-options.c index 9ea629ae..213d05cc 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -761,6 +761,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, break; case 'l': ARG_REQUIRED; + if (strcmp(arg, "-1") == 0) { + ifo->leasetime = DHCP_INFINITE_LIFETIME; + break; + } ifo->leasetime = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); if (e) {