summaryrefslogtreecommitdiffhomepage
path: root/src/config.c
AgeCommit message (Collapse)Author
2021-08-14dhcpv6-ia: allow up to 64 bit wide hostidMikael Magnusson
Add dhcpv6_hostid_len config option which controls the number of bits in the host identifier of dynamically assigned IPv6 addresses. The default is 12 bits which is also the minimum. The maximum is the whole interface identifier, i.e. 64 bits. Allow up to 64 bit wide hostid in static leases. Fixes #84 and #27. Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2021-06-13config: fix ra_flags none settingHans Dedecker
Fixes commit a12fcb3cee2d489b8648a2398812d7bed2f25faa which wrongly removed setting ra_flags to 0 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2021-05-22config: log config parse failures to syslogHans Dedecker
An invalid config setting for an interface lead to a flush of all config settings of the related interface and thus made the interface unusable. Change the behavior by logging config parse failures to syslog and not flushing all config settings 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-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-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-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-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-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-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-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>
2019-05-03dhcpv4: DHCP pool size is off-by-oneDainis Jonitis
1. "limit" option should specify the size of dynamic pool. The dhcpv4_end includes the last valid pool address. 2. Also handle 7 bit host addresses when not directly specified in config file. 3. Make sure code does what documentation says and default 'start'/'limit' pool options to 100 and 150 respectively. Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-04-23config: set default loglevel to LOG_WARNINGHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-04-05ndp: create ICMPv6 socket per interfaceHans Dedecker
Get rid of the global raw ICMPv6 socket by creating a raw ICMPv6 ping socket per interface. This fixes an open raw ICMPv6 socket in case all ndp interfaces are configured as disabled. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-04-05router: create ICMPv6 socket per interfaceHans Dedecker
Get rid of the global raw ICMPv6 socket by creating a raw ICMPv6 socket per interface. This fixes an open raw ICMPv6 socket in case all ra interfaces are configured as disabled. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2019-04-04treewide: initialize properly file descriptorsHans Dedecker
Initialzie properly the dhcpv6, dhcpv4 and ndp ffile descriptors when creating an interface. As such the check for a valid descriptor can be done correct now in the different modules 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-18config: fix build failure in case DHCPv4 support is disabledHans Dedecker
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-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-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>
2019-01-01router: make announcing DNS info configurable (FS#2020)Hans Dedecker
Make announcing options Recursive DNS server and DNS search list configurable via the ra_dns config option. This allows to disable sending RA based DNS info if such info is already provided by DHCPv6. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-12-31config: check for invalid DNS addressesHans Dedecker
Don't accept 0.0.0.0 and :: as DNS addresses. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-11-23config: correctly break string for prefix filterHamster Tian
This if statement does the following: 1. Copy the value of "config prefix_filter" 2. Break the string at "/" 3. Save the number after / as prefix length 4. Convert the address before / into in6_addr However the extraneous "=" broke the second step and inet_pton failed with addresses with mask. This commit removes the = thus fixes the feature. Signed-off-by: Tian Hao <haotia@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-09-03config: fix odhcpd_attrs array sizeHans Dedecker
Use ODHCPD_ATTR_MAX as array size of odhcpd_attrs Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-06-22config: fix wrong assignmentHans Dedecker
Detected by Coverity in CID1430899 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-12-17odhcpd: Replace strerror(errno) with %m formatRosen Penev
Saves a few bytes. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2017-12-08Support muliple RAs on single interfacePierre Pfister
IETF is moving toward implementing IPv6 multihoming by sending multiple RAs on a single interface: - draft-ietf-intarea-provisioning-domains-00 - draft-ietf-rtgwg-enterprise-pa-multihoming-02 odhcpd supports configuration of multiple software interfaces on the same physical interface, which already advertises multiple RAs, but had two issues: - Each RA includes all the prefixes available on the interface. - Replies to sollicits with a single RA. This patch introduces the prefix_filter configuration parameter which allows filtering prefixes that are sent in a given RA, and fixes the sollicit code in order to reply with all the RAs that are configured on a given interface. Signed-off-by: Pierre Pfister <ppfister@cisco.com>
2017-11-09dhcpv4: make DHCPv4 support compiletime configurableHans Dedecker
Make DHCPv4 support compile time configurable; avoids DHCPv4 functionality overlap with other packages. 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-13ndp: detect ifindex changes via interface netlink eventsHans Dedecker
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-07treewide: rework IPv4 address logicHans Dedecker
Align IPv4 address logic with IPv6 by caching per interface the assigned IPv4 addresses. This allows to get rid of different ioctl calls in the DHCPv4 logic to retrieve the IPv4 address and netmask in use by an interface. 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-29treewide: rework code to get rid of fixed IPv6 address arraysHans Dedecker
Rework code to get rid of RELAYD_MAX_PREFIXES and RELAYD_MAX_ADDRS by using dynamic IPv6 address array allocation. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-06-27config: rework code to get rid of IFNAMSIZ usageHans Dedecker
Get rid of IFNAMSIZE usage for interface name and ifname variables Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-05-15config: fix invalid hoplimit in RA messageHans Dedecker
Don't send an invalid hoplimit in RA message when the interface is shutdown due to a invalid configured ra_hoplimit. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-05-15config: fix invalid retranstime in RA messageHans Dedecker
Don't send an invalid retranstime in RA message when the interface is shutdown due to a invalid configured ra_retranstime. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-05-15config: fix invalid reachabletime in RA messageHans Dedecker
Don't send an invalid reachabletime in RA message when the interface is shutdown due to a invalid configured ra_reachabletime. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>