diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-02-19 22:00:38 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-02-19 22:15:57 +0100 |
commit | e437ce9422c2f92752be5b6b3fd453e099a98a7e (patch) | |
tree | d9a87c78ad54ad215c6bfb9210f73cd2c1d0a3a7 /src/config.c | |
parent | 942fb33d3017e8769a7354ee008daf0f31a40fe2 (diff) |
treewide: simplify dhcp leasetime checking
Set dhcp leasetim to 43200 seconds for all interfaces independant
if dhcpv4 is enabled for an interface. Minimum allowed leasetime
is 60 seconds when parsing leastime configuration; this allows to
clean up the awkward leasetime checks on different places in the code
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c index b621c75..df0cbc4 100644 --- a/src/config.c +++ b/src/config.c @@ -192,6 +192,7 @@ static void set_interface_defaults(struct interface *iface) { iface->managed = 1; iface->learn_routes = 1; + iface->dhcpv4_leasetime = 43200; iface->ra_maxinterval = 600; iface->ra_mininterval = iface->ra_maxinterval/3; iface->ra_lifetime = -1; @@ -288,10 +289,10 @@ static double parse_leasetime(struct blob_attr *c) { goto err; } - if (time >= 60) - return time; + if (time < 60) + time = 60; - return 0; + return time; err: return -1; @@ -351,8 +352,7 @@ static int set_lease(struct uci_section *s) if (time < 0) goto err; - if (time >= 60) - lease->dhcpv4_leasetime = time; + lease->dhcpv4_leasetime = time; } list_add(&lease->head, &leases); @@ -425,8 +425,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if (time < 0) goto err; - if (time >= 60) - iface->dhcpv4_leasetime = time; + iface->dhcpv4_leasetime = time; } if ((c = tb[IFACE_ATTR_START])) { |