summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2021-04-03odhcpd: fix extra compiler warningHans Dedecker
src/odhcpd.c:143:2: error: format not a string literal, argument types not checked [-Werror=format-nonliteral] snprintf(buf, sizeof(buf), sysctl_pattern, ifname, what); ^~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
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-12-13config: remove local mkdir_p implementationDaniel Golle
Replace local mkdir_p implementation in favour of using mkdir_p now added to libubox. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2020-12-06ubus: add add_lease methodSantiago Piccinini
Allows sharing leases between odhcpd instances running in multiple hosts. Signed-off-by: Santiago Piccinini <spiccinini@altermundi.net> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-11-24config: add option to indicate dns service presenceicpz
Adds the config option to set if ipv6 dns service is availiable on the interface. In some cases the dns service may not be listening on the ipv6 address of the interface, and thus should not be announced to clients. Signed-off-by: Paizhuo Chen <cc@icpz.dev>
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-11-01dhcpv6: fix size_t fields in syslog formatMikael Magnusson
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
2020-10-31dhcpv6: add explicit dhcpv4o6 server addressMikael Magnusson
Include the All_DHCP_Relay_Agents_and_Servers multicast address in the option explicitly. It shouldn't be needed according to RFC 7341 section 7.2 but ISC dhclient logs an error otherwise: dhcp4-o-dhcp6-server: expecting at least 16 bytes; got 0 Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
2020-10-31dhcpv6: add DHCPv4-over-DHCPv6 supportMikael Magnusson
Add support for DHCPv4-over-DHCPv6 (DHCP 4o6) Transport (RFC 7341). Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-10-29dhcpv6: check message typeMikael Magnusson
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
2020-09-07router: fix advertisement interval optionHans Dedecker
The variable maxival contains the maximum time in seconds between successive unsolicited Router Advertisement messages; RFC6275 defines the Advertisement Interval option as the time in milliseconds. Therefore convert maxival to milliseconds when populating the Advertisement Interval option. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-06-23odhcpd: fix compilation with GCC10Rosen Penev
GCC10 mandates the C++ one definition rule, which breaks on multiple definitions of config. Add the appropriate extern declaration. Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2020-05-03router: fix Lan host reachibility due to identical RIO and PIO prefixes ↵Hans Dedecker
(FS#3056) odhcpd includes RIO RA options according to requirement L3 in RFC7084. However if the delegated prefix length received on the wan is equal to the downstream delegated prefix length on the Lan this may pollute the routing table of type C hosts as the RIO routing entry can take precedence of the PIO routing entry meaning all traffic for the on link hosts will go via the router iso direct on link communication. If the traffic is dropped in the router hosts are unreachable; therefore don't include RIO options with prefixes and prefix length identical to those in a PIO RA option 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-02-16dhcpv4: 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 leasetime 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-10-13ndp: fix endian issueHans Dedecker
Fix endian issue introduced in commit 91a28e4 by using ND_NA_FLAG_SOLICITED defined in netinet/icmp6.h Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-10-01netlink: fix potential infinite loopsHans Dedecker
Fix potential infinite loops by checking the return code of nl_send_auto_complete; if nl_send_auto_complete fails pending will always have the value 1 as the finish callback will not be called resulting into an infinite loop Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-09-15netlink: rename netlink callback handlersHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-09-15ndp: answer global-addressed NS manuallysfan5
An upstream router may address solicits to the global address of the target, these will not be answered by the kernel and not routed either due to link-local source. The NS will eventually be retried as multicast, but we want to avoid this. see also https://forum.archive.openwrt.org/viewtopic.php?id=40871 Signed-off-by: Stefan Alfers <sfan5@live.de>
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-09-12config: ra_management compatibility supportHans Dedecker
Keep supporting ra_management for backwards compatibility support; ra_management will only be processed if neither ra_slaac and ra_flags are set. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-09-03odhcpd: router: Fix out of scope memory accessHauke Mehrtens
A pointer to search_buf is accessed by search_domain outside of the if branch which defines search_buf. The compiler could already reuse this memory. Coverity: #1445747 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
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-08-26router: speed up initial router advertisementsHans Dedecker
Speed up sending initial router advertisement messages as documented in RFC2461 point 6.2.4 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-08-19router: close socket upon NETEV_IFINDEX_CHANGE fixedKoen Aerts
Make sure the raw socket is removed from the uloop file descriptor list before the socket is closed as introduced in https://github.com/openwrt/odhcpd/commit/000182fe4f94a5a6ec139456a2b74f0cdea13b9c Related to https://github.com/openwrt/odhcpd/issues/135 Signed-off-by: Koen Aerts <aertskoen5@gmail.com>
2019-08-16router: fix previous commitHans Dedecker
After closing the router socket the value needs to be set to -1 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-08-14router: close socket upon NETEV_IFINDEX_CHANGEKoen Aerts
Make sure the socket is closed in a case where the bridge goes down as a result of NO-CARRIER on the bridge. If not present Router Discovery and Router Advertisement will break permanently after the bridge went down. Related to https://github.com/openwrt/odhcpd/issues/135 Signed-off-by: Koen Aerts <aertskoen5@gmail.com>
2019-08-08router: fix lingering uloop socket descriptorHans Dedecker
In case setting one of the socket options fails; make sure the raw socket is removed from the uloop file descriptor list before the socket is closed. In case this is not done and a new raw socket is created with the same fd value odhcpd will not be triggered by uloop in case RS messages are received on the socket as reported in https://github.com/openwrt/odhcpd/issues/135 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-07-07router: support ra_lifetime being 0Jan-Philipp Litza
The value 0 has the special meaning of not being a default router. This is useful to only advertise prefixes or DNS settings without being a real router. Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
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-14config: use list safe iterator in lease_deleteHans Dedecker
As the current assignment is freed in lease_delete use list_for_each_entry_safe Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-03dhcpv4: fix lease ordering by ip addressDainis Jonitis
1. Maintaining of sorted list was wrong for static lease case. Add dhcpv4_insert_assignment() helper function and use it from all places. 2. Add ip4toa() helper function to print ipv4 address that is stored as network byte-order uint32_t. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-05-03config: use multi-stage parsing of uci sectionsDainis Jonitis
When loading uci sections from config file, in one pass do not mix sections from different types. First load odhcpd global settings, then all interface sections and finally static leases. It ensures that section order in file can't affect what information is already parsed. For example static lease section may need information about all interfaces, to decide whether ip address belongs to any of currently defined interfaces/address pools. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.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-05-03dhcpv4: do not allow pool end address to overlap with broadcast addressDainis Jonitis
Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com>
2019-05-03treewide: give file descriptors safe initial valueDainis Jonitis
Since main problem of assuming that fd==0 is invalid value was fixed in upstream odhcpd by e7b1d4bf3a2297192638b9c84208b3dcb306ecd8 then what is left are minor problems of static initialization of some global fd variables. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com>