diff options
author | Nick Hainke <vincent@systemli.org> | 2021-01-02 23:27:03 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2021-01-03 15:42:49 +0100 |
commit | 3bda90079ec5574ef469e2a7804808302f17769d (patch) | |
tree | a3a7e8ce9f1f25d211838631b31d587f9f293205 /src/config.c | |
parent | b75bcad7bd5fd03f64011a532b9960d78e4aac22 (diff) |
odhcpd: add option for setting preferred lifetime
"valid_lft" and "preferred_lft" are different. If the "preferred_lft"
is expired the prefix should be avoided in source prefix selection.
However, the interface is allowed to still receive downstream traffic.
preferred_lfetime:
Limit for preferred lifetime of a prefix
If you want the old behavior, you have to set preferred_lifetime to
the same value as leasetime.
Signed-off-by: Nick Hainke <vincent@systemli.org>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index 015a716..78b5855 100644 --- a/src/config.c +++ b/src/config.c @@ -82,6 +82,7 @@ enum { IFACE_ATTR_NDPROXY_ROUTING, IFACE_ATTR_NDPROXY_SLAVE, IFACE_ATTR_PREFIX_FILTER, + IFACE_ATTR_PREFERRED_LIFETIME, IFACE_ATTR_MAX }; @@ -130,6 +131,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_PREFIX_FILTER] = { .name = "prefix_filter", .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_PREFERRED_LIFETIME] = { .name = "preferred_lifetime", .type = BLOBMSG_TYPE_STRING }, }; static const struct uci_blob_param_info iface_attr_info[IFACE_ATTR_MAX] = { @@ -197,6 +199,7 @@ static void set_interface_defaults(struct interface *iface) iface->ndp = MODE_DISABLED; iface->learn_routes = 1; iface->dhcp_leasetime = 43200; + iface->preferred_lifetime = 43200; iface->dhcpv4_start.s_addr = htonl(START_DEFAULT); iface->dhcpv4_end.s_addr = htonl(START_DEFAULT + LIMIT_DEFAULT - 1); iface->dhcpv6_assignall = true; @@ -525,6 +528,14 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr iface->dhcp_leasetime = time; } + if ((c = tb[IFACE_ATTR_PREFERRED_LIFETIME])) { + double time = parse_leasetime(c); + if (time < 0) + goto err; + + iface->preferred_lifetime = time; + } + if ((c = tb[IFACE_ATTR_START])) { iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c)); iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) + |