summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv6-ia.c
AgeCommit message (Collapse)Author
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>
2017-08-03dhcpv6: assign all viable DHCPv6 addresses by default (FS#402, FS#524)Hans Dedecker
Some client implementations expect DHCPv6 addresses to be assigned for every prefix present in a RA as reported in FS#524; if not done the client implementations spam the DHCPv6 server with SOLICIT messages trying to get an DHCPv6 address for every prefix. When ra_managed is set to 1 and an ULA prefix is configured; the DHCPv6 server will only assign an ULA DHCPv6 addresses which possibly leads to DNS issues. Fix these problems by providing dhcpv6_assignall config option which assigns all viable DHCPv6 addresses to a client by default. This is a trade off as it means client implementations will be assigned more IPv6 addresses and lose the ability to quickly renumber clients which don't support reconfigure accept in case of wan prefix change Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-08-02treewide: reflect managed mode is related to RAHans Dedecker
Improve code readability by renaming managed into ra_managed and define the according ra_managed flags. This will help to better understand the ra_managed logic as defined in the README file. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-07-03treewide: rework logic to retrieve IPv6 interface addressesHans Dedecker
Retrieve IPv6 interface addresses when the interface gets created; this allows to get rid of the IPv6 address dump logic in ndp.c. Add IPv4 address support in odhcp_ipaddr struct. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-06-27treewide: use angle-brackets to include libubox header filesHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-04-26dhcpv6-ia: Fix segfault when writing DHCPv4 leases in state fileHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-04-21dhcpv6-ia: simplify logic to write statefile and dhcpv6 loggingHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-04-13dhcpv6-ia: create assignment for unknown IA in rebind messagesHans Dedecker
Create assignment for unknown identity association in rebind messages which is equivalent to the handling of identity association for solicit/request messages. However don't consider identity associations in rebind messages as a request so that addresses/prefixes which are not apropriate for the link are returned with lifetimes of 0. This aligns with the behavior of the ISC DHCPv6 server. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-03-29ndp: keep an exact copy of IPv6 interface addressesHans Dedecker
Don't reset the final 32 bit IPv6 host suffix when storing the IPv6 addresses in the interface structure. This will allow exact lookup aand return of IPv6 addresses stored in the interface structure when needed. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-03-04dhcpv6-ia: Check lockf return valueFlorian Fainelli
Check the lockf return value to fix the following warning/error: /home/fainelli/dev/openwrt/trunk/build_dir/target-mipsel-linux-gnu_glibc/odhcpd-2017-02-21-1b630f8b/src/dhcpv6-ia.c: In function 'dhcpv6_write_statefile': /home/fainelli/dev/openwrt/trunk/build_dir/target-mipsel-linux-gnu_glibc/odhcpd-2017-02-21-1b630f8b/src/dhcpv6-ia.c:246:8: error: ignoring return value of 'lockf', declared with attribute warn_unused_result [-Werror=unused-result] lockf(fd, F_LOCK, 0); ^ cc1: all warnings being treated as errors Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2017-02-19treewide: simplify dhcp leasetime checkingHans Dedecker
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>
2017-02-01dhcpv6-ia: apply lease delete based on assignment bound stateHans Dedecker
Make adding and removing of routes via apply_lease dependant on the assignment bound state as it makes no sense to delete routes for an assignment which is not bound. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-01-06dhcpv6-ia: filter out prefixes having invalid lengthHans Dedecker
Function append_reply filters out addresses having invalid prefix length when constructing prefixes being delegated to a client. Now also filter out addresses with an invalid prefix length when writing the delegated prefixes in the statefile and during logging of the delegated prefixes. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-01-05dhcpv6-ia: fix dereference after freeing assignmentHans Dedecker
Fix assignment dereference by dhcpv6_log in case the assignment is freed when nothing has been assigned. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-01-05dhcpv6-ia: log only IPv6 addresses which are effectively assigned to a ↵Hans Dedecker
DHCPv6 client Fix displaying IPv6 addresses which were not assigned to a DHCPv6 client Clean up the code by using macro ADDR_ENTRY_VALID_IA_ADDR on different places to align the checks. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-01-03dhcpv6-ia: fix static assignment checkHans Dedecker
Fix static assignment check failure which was introduced in commit 561890e Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>