summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv6-ia.c
AgeCommit message (Collapse)Author
2021-01-30dhcpv6-ia: apply prefix_filter on dhcpv6Nick Hainke
The prefix_filter allows to select which prefix should be assigned to clients if you have multiple prefixes on an interface. Currently, the filter only applies to RAs and does work with a dhcpv6 server. This commit enables the filter also on dhcpv6. Signed-off-by: Nick Hainke <vincent@systemli.org> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2021-01-03odhcpd: add option for setting preferred lifetimeNick Hainke
"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>
2020-12-24dhcpv6-ia: remove assignment equal to 0 checksHans Dedecker
Remove the checks as they're leftovers of the old static lease implementation which created assigments with assigned equal to 0 whihc is not the case anymore in the reworked static lease implementation Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-12-24dhcpv6-ia: fix logic to include IA_PD prefix with lifetimes set to 0Hans Dedecker
Make sure IA_PD prefixes for which no preferred and valid lifetimes can be returned are included in the reply with a preferred and valid lifetime to 0. Therefore exclude IPv6 prefixes with an invalid prefix length as well so IA_PD prefixes for which not a preferred/valid lifetime is returned are included with a preferred and valid lifetime set to 0 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-12-24dhcpv6-ia: fix prefix delegation behaviorHans Dedecker
When an IPv6 address change is triggered each PD assignment is checked if it is still consistent with the updated IPv6 prefix list. If not consistent anymore a reconfigure is triggered for the assignment and a best effort is made to assign a new IA_PD prefix. If it not possible anymore to assign an IA_PD prefix delete the PD assignment now so it will result into a NO BINDING status code for the given IA_PD in the DHCPv6 reply when the client tries to renew the IA_PD prefix. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-11-15dhcpv6-ia : write statefile atomicallyHans Dedecker
Applications (e.g. unbound) need a consistent view of the statefile; therefore write all the lease info to a temporary file which is later renamed to the configured statefile name Suggested-by : John Fremlin <john@fremlin.org> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-04-04dhcpv6-ia: fix preferred and valid lifetimes in ubus ipv6leasesHans Dedecker
Since commit 6db312a698e920ff61505ef1f42469880829774d the preferred and valid lifetimes of the addresses/prefixes is based on the configured leasetime; as a result the displayed preferred and valid lifetimes need to be calculated based on the assignment lifetime as this is set to the lowest valid lifetime of the addresses/prefixes. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-03-28odhcpd: fix compilation with musl 1.2.0Rosen Penev
SYS_clock_gettime is gone with musl 1.2.0. Switched to the function. Also fixed two format strings that fail as time_t is 64-bit with 1.2.0. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-14ubus: use dhcpv6 ia assignment flagHans Dedecker
Further align the code to use DHCPv6 assignment flags to distinguish between prefix delegation and non temporary address assignments Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-02-16dhcpv6-ia: avoid setting lifetime to infinite for static assignmentsHans Dedecker
Don't set the valid lifetime to infinite for static assignments but rather set it to the IA lifetime given to the client. This makes it possible to display the leasetime for static assigments and simplifies the code in several places Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-01-16dhcpv6-ia: use dhcp leasetime to set preferred/valid statefull lifetimesHans Dedecker
Allow to set the preferred/valid lifetimes of IA_NA/IA_PD options based on the configured dhcp leasetime. DHCP leqasetime will be used to set the preferred/valid lifetimes in the IA_NA/IA_PD options unless the preferred/valid lifetimes of the IPv6 address are smaller then the DHCP leasetime. This will avoid IA_NA/IA_PD options being sent with infinite lifetimes due to the IPv6 address having infinite preferred/valid lifetimes like IPv6 ULA addresses. While at it rename dhcpv4_leasetime into dhcp_leasetime as the leasetime is used both for DHCPv4 and DHCPv6 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-01-02dhcpv6-ia: introduce DHCPv6 pd and ia assignments flagsHans Dedecker
Simplify the code by using specific flags which identify the assignment either as a DHCPv6 PD or NA assignment. This allows to remove implicit checks for PD and NA assignments based on the value of the assignment length parameter. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-12-31dhcpv6-ia: cleanup prefix delegation routesHans Dedecker
Remove prefix delegation routes as well in free_dhcpv6_assignment when cleaning up the assignment resources Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-12-31dhcpv6-ia: remove passing interface as parameter to apply_leaseHans Dedecker
As the assignment struct holds a pointer to the interface struct use this one in apply_lease iso passing interface as a parameter Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-12-15treewide: optimize syslog priority valuesHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-09-14dhcpv6: retry failed PD assignments on addrlist changeTian Hao
Currently only assignments with prefixes larger than the largest available one will be re-assigned on addrlist change events. Previously failed PD assignments are not taken into account, and these assignments will never have a chance to recover even if the address just added to the interface could satisfy them. Failed PD assignments could be very common when upstream prefix is obtained from a PPPoE WAN, as ISPs tend to terminate the PPPoE session after a fixed time period. Addresses on LAN could disappear and re-appear during WAN redial, and all existing PD assignments to clients in LAN will become failed when the addresses disappear. These assignments will not be recovered after WAN has been brought back up, and clients in LAN could no longer receive any PD prefix. This commit fixes the issue by including failed PD assignments in the re-assign list on addrlist change event, so that newly added prefixes can be put into use right after they are added to the interface. Signed-off-by: Tian Hao <haotia@gmail.com>
2019-08-28dhcpv6-ia: free assignment when validity timer expiresHans Dedecker
In case clid_len is set free assignment when validity timer expires Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-17router: make RA flags configurable (FS#2019)Hans Dedecker
Replace the config option ra_management by the config options ra_flags and ra_slaac. The latter allows to configure the autonomous-address config flag used for stateless address configuration while the former allows to configure the RA flags in the form of a list. The list can hold the following values : managed-config other-config home-agent none Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-15config: remove 'ignore' config optionbpDainis Jonitis
1. Remove 'ignore' config option for interface. Interface is still used if any of 'ra', 'ndp', 'dhcpv4' or 'dhcpv6' options are different from default 'disabled' mode. In config_parse_interface() update runtime ignore value according to all mode values. 2. Reset ignore, ra, ndp, dhcpv4 and dhcpv6 values in set_interface_defaults(). Otherwise if option is deleted from config file and config is reloaded, it will use the value from old config, potentiallly not turning services off. 3. Do not use implicit checks that 0 server mode means MODE_DISABLED. 4. Simplify code of all service setup functions if passed enabled = true argument, but service mode is disabled. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-15treewide: init assignment lists headHans Dedecker
When allocating an assignment in alloc_assignment; init the circular head and lease_list circular lists. Avoids checking NULL pointer when freeing the assignment in free_assignment. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-03treewide: always init interface list heads during initializationDainis Jonitis
When allocating interface, init dhcpv4_assignments, dhcpv4_fr_ips and ia_assignments circular list heads to point to self. Avoids checking whether next pointer is not null all over the place. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com>
2019-04-16treewide: align syslog loglevelsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-04-11treewide: fix compiler warningsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-19dhcp: rework assignment free logicHans Dedecker
Replace the separate dhcpv4/dhcpv6 assignment free functions by the function free_assignment which calls the dhcp specific free function via a callback Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-18dhcp: rework static lease logicHans Dedecker
Rework the static lease logic as the existing logic had different issues. Static leases are now added in a vlist tree which makes it easier to handle static lease config changes. For both DHCPv4 and DHCPv6 static assignments are now created upon the receival of DHCPv4/DHCPv6 messages as before the static assignment was created even if the client was not physically present. In case a hostname is specified in a static lease it won't be overriden anymore by the hostname received from the client. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-13dhcpv6: rapid commit supportHans Dedecker
Add support for rapid commit according to RFC8415 18.3.1 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-11dhcpv6-ia: move function definitions to odhcpd.hHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-08treewide: unify dhcpv6 and dhcpv4 assignmentsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-05treewide: use avl tree to store interfacesHans Dedecker
Store the interfaces in an avl tree iso a linear linked list Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-03treewide: align syslog tracingHans Dedecker
Use the logical OpenWrt interface name in syslog printing as multiple logical interfaces can be defined on top of the same device Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-02-01dhcpv6-ia: add full CONFIRM supportHans Dedecker
Add CONFIRM support as specified in RFC8415 paragraph 18.3.3 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-01-31dhcpv6-ia: rework append_reply()Hans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-01-16dhcpv6-ia: fix compiler warningHans Dedecker
Fixes : src/dhcpv6-ia.c:1117:22: warning: variable 'onlink' set but not used [-Wunused-but-set-variable] for (size_t i = 0, onlink = false; i < addrlen; ++i) { Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-01-16dhcpv6-ia: fix onlink IA check (FS#2060)Hans Dedecker
Some DHCPv6 clients start sending SOLICIT messages without including either an IA_NA or IA_PD and only start including an IA_NA or IA_PD in the REQUEST message without including an IA_PREFIX or IA_ADDR as suboption. As a result the check to verify if an IA_ADDR and/or IA_PREFIX is onlink fails. Fix this by returning notonlink if an IA_PREFIX or IA_ADDR suboption is present having an address/prefix not matching any of the addresses Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-01-15dhcpv6: add setting to choose IA_NA, IA_PD or bothMatija Amidzic
Adds the config options to set if DHCPv6 'stateful addresing' hands out IA_NA (Internet Address - Network Address), IA_PD (Internet Address - Prefix Delegation), both or none. Signed-off-by: Matija Amidzic <matija.amidzic@sartura.hr>
2018-12-12odhcpd: switch to libubox container_of implementationHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-09-05odhcpd: detect broken hostnamesHans Dedecker
Check hostnames contain valid characters as defined in RFC 952 and RFC 1123. Invalid hostnames in uci configured host entries will result into a refusal to create the static lease. In case a client received hostname contains an invalid character no <hostname> <IP address> entry will be added to the lease file. In such case the leaseinfo description in the lease file will still contain the hostname but preceded by the string broken\x20 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-06-26dhcpv6-ia: fix border assignment size settingHans Dedecker
The border assignment size is not updated by address list change events if the interface is not configured as DHCPv6 server; therefore set the border assignment size when an interface is enabled and configured as a DHCPv6 server in order to keep the assignment size in sync with the available prefix sizes Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-06-26dhcpv6-ia: fix status code for not on link IAsHans Dedecker
Set status code not on link for IAs in DHCPv6 request messages carrying prefixes/addresses not matching the link prefix(es) to which the client is connected Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-06-22dhcpv6-ia: improve error checking in assign_pd()Hans Dedecker
Detected by Coverity in CID1412267 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-06-07dhcpv6-ia: log renew messages as wellHans Dedecker
As the odhcpd log verbosity is configurable log renew messages as well. Fixes logically dead code reported by Coverity in CID1412318 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-04-23dhcpv6-ia: keep tentative assignments alive for a short timeHans Dedecker
Assign tentative assignments a lifetime of 60 seconds; this will assure the assignment is seen as valid during lookup when receiving a later REQUEST from the DHCPv6 client. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-04-23dhcpv6-ia: make assignment lookup more strictHans Dedecker
Whe doing an assignment lookup do a strict match between the assignment IAID and the IAID received form the client in case the BOUND or TENTATIVE assignment flags are set. This fixes a wrong assignment being returned for a client which uses a different IAID than the IAID used in a previous DHCPv6 exchange. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-02-20dhcpv6-ia: don't always send reconf accept option (FS#1377)Hans Dedecker
Send reconfigure accept and reconfigure key authentication protocol options only if the client indicates it supports reconfigure accept as descibed in RFC3315 paragraph 21.5. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-11-09treewide: rework handling of netlink eventsHans Dedecker
Rework the handling of netlink events by letting the different modules ndp, ra, dhcpv6 and dhcpv4 install netevent handlers. The installed netevent handlers are called by the netlink logic passing an event indication together with event data. Each netevent handler implements its own event logic; this makes the code more modular and less complex by moving all netlink code to netlink.c While at it rename ia_addr and ia_addr_len into addr6 and addr6_len respectively Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-10-16treewide: add netlink fileHans Dedecker
First step in moving netlink code to netlink.c by moving netlink code from odhcpd.c to netlink.c Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-10-13treewide: align function namingHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-09-13dhcpv4: force renew nonce authentication supportHans Dedecker
Support force renew nonce authentication support in the DHCPv4 server as described in RFC3203 and RFC6704. The interface uci arameter dhcpv4_forcereconf allows to supports DHCPv4 clients which support force renew without authentication. While at it align network byte order logic for simplicity. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-09-06treewide: replace RELAYD prefix naming in macrosHans Dedecker
Remove the unfortunate RELAYD naming in the different macros Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-08-10dhcpv6-ia: rework reconfigure accept logicHans Dedecker
Rework reconfigure accept retransmission logic; every DHCPv6 assignment has its own reconfigure accept timer now making sure the timeout and retransmission behavior is in line with RFC3315 paragraph 19.1.2. While at it rename the original reconf_timer into valid_until_timeout as it will only check now the lifetime of the assignments. Set reconf_cnt to INT_MAX for every assignment which belongs to the same client identifier; before the reconf_cnt of the first handled assignment was set by mistake breaking the retransmission logic. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>