project/odhcpd.git
3 days agorouter: fix dns search list option master
Hans Dedecker [Fri, 19 Apr 2019 11:16:58 +0000 (13:16 +0200)]
router: fix dns search list option

Fix regression issue introduced in commit 0523bdd as empty DNS search
list option was sent making the RA message invalid

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
5 days agorouter: use ra_lifetime as lifetime for RA options (FS#2206)
Hans Dedecker [Wed, 17 Apr 2019 09:22:43 +0000 (11:22 +0200)]
router: use ra_lifetime as lifetime for RA options (FS#2206)

Use the RA lifetime as lifetime for the recursive DNS and DNS search options
For the route options use as lifetime the smallest value of either the valid
lifetime of the address associated with the route or the RA lifetime.
This avoids routes having infinite lifetime being installed in downstream
clients which can results into routes pointing to a removed router.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
5 days agorouter: improve code readibility
Hans Dedecker [Thu, 11 Apr 2019 20:48:28 +0000 (22:48 +0200)]
router: improve code readibility

No functional changes; just improve code readibilty in send_router_advert()

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
6 days agoRevert "router:"
Hans Dedecker [Tue, 16 Apr 2019 20:46:26 +0000 (22:46 +0200)]
Revert "router:"

This reverts commit f1d7da9801adc0a77c1a35363e4242544c4915e7.

6 days agotreewide: align syslog loglevels
Hans Dedecker [Tue, 16 Apr 2019 13:27:42 +0000 (15:27 +0200)]
treewide: align syslog loglevels

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 days agorouter:
Hans Dedecker [Fri, 12 Apr 2019 13:47:29 +0000 (15:47 +0200)]
router:

11 days agotreewide: fix compiler warnings
Hans Dedecker [Thu, 11 Apr 2019 20:00:15 +0000 (22:00 +0200)]
treewide: fix compiler warnings

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 days agoCMakeList.txt: enable extra compiler checks
Hans Dedecker [Thu, 11 Apr 2019 19:50:12 +0000 (21:50 +0200)]
CMakeList.txt: enable extra compiler checks

Enforce additional compiler checks in order to catch
possible errors during compilation

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 weeks agondp: create ICMPv6 socket per interface
Hans Dedecker [Thu, 4 Apr 2019 14:57:47 +0000 (16:57 +0200)]
ndp: create ICMPv6 socket per interface

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>
2 weeks agorouter: create ICMPv6 socket per interface
Hans Dedecker [Wed, 3 Apr 2019 14:29:19 +0000 (16:29 +0200)]
router: create ICMPv6 socket per interface

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>
2 weeks agotreewide: initialize properly file descriptors
Hans Dedecker [Thu, 4 Apr 2019 10:01:46 +0000 (12:01 +0200)]
treewide: initialize properly file descriptors

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>
3 weeks agonetlink: rework IPv4 address refresh logic
Hans Dedecker [Fri, 29 Mar 2019 14:10:29 +0000 (15:10 +0100)]
netlink: rework IPv4 address refresh logic

Rework logic to refresh IPv4 addresses so we can get rid of the
second for loop

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 weeks agonetlink: rework IPv6 address refresh logic
Hans Dedecker [Fri, 29 Mar 2019 11:01:19 +0000 (12:01 +0100)]
netlink: rework IPv6 address refresh logic

Rework logic to refresh IPv6 addresses so we can get rid of the
second for loop

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 weeks agonetlink: fix IPv6 address updates (FS#2204)
Hans Dedecker [Wed, 27 Mar 2019 15:55:19 +0000 (16:55 +0100)]
netlink: fix IPv6 address updates (FS#2204)

Keep the valid and preferred lifetimes in sync with the kernel by always
updating the cached IPv6 addresses in refesh_iface_addr6().
This fixes invalid preferred and valid IA lifetimes in DHCPv6 reply
messages due to the cached preferred and valid lifetimes not being in
sync with the preferred and valid kernel lifetimes

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 weeks agodhcpv6: extra syslog tracing
Hans Dedecker [Thu, 21 Mar 2019 14:37:56 +0000 (15:37 +0100)]
dhcpv6: extra syslog tracing

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 weeks agodhcpv6/router: add support for mutiple master interfaces
Hans Dedecker [Thu, 21 Mar 2019 13:43:52 +0000 (14:43 +0100)]
dhcpv6/router: add support for mutiple master interfaces

Support multiple master interfaces for dhcpv6 and ra; it allows
to forward dhcpv6 mesaages and RS on multiple upstream links

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 weeks agondp: fix adding proxy neighbor entries
Hans Dedecker [Thu, 21 Mar 2019 13:17:50 +0000 (14:17 +0100)]
ndp: fix adding proxy neighbor entries

In case multiple logical OpenWrt interfaces are stacked on the same device
and one of the interfaces is configured in relay and the other not; adding
a proxy neighbor entry will result into it immediately being deleted if
the interface in non relay mode comes last.
Fix this by not doing a delete on the interface which is not configured in
relay mode.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 weeks agorouter: add extra syslog tracing
Hans Dedecker [Thu, 21 Mar 2019 08:19:00 +0000 (09:19 +0100)]
router: add extra syslog tracing

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 weeks agonetlink: fix neighbor event handling (FS#2160)
Hans Dedecker [Wed, 20 Mar 2019 15:33:19 +0000 (16:33 +0100)]
netlink: fix neighbor event handling (FS#2160)

Commit a54cee0 introduced a regression in the handling of netlink neighbor
events as it did not set the interface pointer in the netevent_handler_info
struct resulting into a breakage of ndp relay mode

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
7 weeks agoubus: always trigger an update if interface is not found
Hans Dedecker [Wed, 27 Feb 2019 10:10:29 +0000 (11:10 +0100)]
ubus: always trigger an update if interface is not found

Commit 9f25dd8af76dc30e54ddcbb4a284058e598951d5 changed the logic of
handle_update by only triggering an update if the interface is
found in the interface list and is not set as to be ignored.
However this breaks the behavior of loading the dhcp config for
interfaces which were previously not yet known by netifd and as
result were not yet created in the interface list.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
8 weeks agodhcpv4: fix adding assignment in list (FS#2142)
Hans Dedecker [Mon, 25 Feb 2019 09:48:44 +0000 (10:48 +0100)]
dhcpv4: fix adding assignment in list (FS#2142)

Add assignment to the tail of the list in case the last element
is not bigger

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
8 weeks agodhcpv4: fix static lease lookup
Hans Dedecker [Mon, 25 Feb 2019 09:46:18 +0000 (10:46 +0100)]
dhcpv4: fix static lease lookup

Function config_find_lease_by_ip_addr expects IP address in network
byte order

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcp: rework assignment free logic
Hans Dedecker [Mon, 18 Feb 2019 17:22:24 +0000 (18:22 +0100)]
dhcp: rework assignment free logic

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>
2 months agoconfig: fix build failure in case DHCPv4 support is disabled
Hans Dedecker [Mon, 18 Feb 2019 14:35:04 +0000 (15:35 +0100)]
config: fix build failure in case DHCPv4 support is disabled

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv4: fix assignment of requested IP address
Hans Dedecker [Mon, 18 Feb 2019 13:11:12 +0000 (14:11 +0100)]
dhcpv4: fix assignment of requested IP address

Fix assignment of requested IP address by a client in case the
assignment list is empty.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcp: rework static lease logic
Hans Dedecker [Tue, 12 Feb 2019 15:07:24 +0000 (16:07 +0100)]
dhcp: rework static lease logic

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>
2 months agodhcpv6: rapid commit support
Hans Dedecker [Wed, 13 Feb 2019 11:07:49 +0000 (12:07 +0100)]
dhcpv6: rapid commit support

Add support for rapid commit according to RFC8415 18.3.1

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv6: fix parsing of DHCPv6 relay messages
Hans Dedecker [Wed, 13 Feb 2019 10:07:38 +0000 (11:07 +0100)]
dhcpv6: fix parsing of DHCPv6 relay messages

Commit 0db69b0b85c83fedd74ac77e850669a17c4e6617 broke parsing of DHCPv6
relay messages as the DHCPv6 client header pointer was not updated
after parsing the nested relay forward message(s).

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv4: fix compile issue
Hans Dedecker [Tue, 12 Feb 2019 13:14:50 +0000 (14:14 +0100)]
dhcpv4: fix compile issue

Fix compile issue introduced in commit 671ccaabc893b53be8a1891aaf2236b657d6ce06

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv6-ia: move function definitions to odhcpd.h
Hans Dedecker [Mon, 11 Feb 2019 14:46:29 +0000 (15:46 +0100)]
dhcpv6-ia: move function definitions to odhcpd.h

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv6: improve code readibility
Hans Dedecker [Sun, 10 Feb 2019 20:21:51 +0000 (21:21 +0100)]
dhcpv6: improve code readibility

Use struct dhcpv6_client_header hdr to access fixed DHCPv6 header fields

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agotreewide: unify dhcpv6 and dhcpv4 assignments
Hans Dedecker [Tue, 11 Dec 2018 13:13:30 +0000 (14:13 +0100)]
treewide: unify dhcpv6 and dhcpv4 assignments

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agonetlink: rework handling of netlink messages
Hans Dedecker [Thu, 7 Feb 2019 12:18:40 +0000 (13:18 +0100)]
netlink: rework handling of netlink messages

Multiple logical OpenWrt interfaces can be stacked on top of the same
Linux device. As such netlink events for addresses/routes/ifindex changes
need to be propagated to the different logical OpenWrt interfaces
which use the Linux device as reported in the netlink message.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agotreewide: use avl tree to store interfaces
Hans Dedecker [Tue, 5 Feb 2019 11:09:44 +0000 (12:09 +0100)]
treewide: use avl tree to store interfaces

Store the interfaces in an avl tree iso a linear linked list

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agotreewide: align syslog tracing
Hans Dedecker [Sun, 3 Feb 2019 17:03:42 +0000 (18:03 +0100)]
treewide: align syslog tracing

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>
2 months agodhcpv6-ia: add full CONFIRM support
Hans Dedecker [Wed, 30 Jan 2019 17:19:49 +0000 (18:19 +0100)]
dhcpv6-ia: add full CONFIRM support

Add CONFIRM support as specified in RFC8415 paragraph 18.3.3

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2 months agodhcpv6-ia: rework append_reply()
Hans Dedecker [Tue, 29 Jan 2019 14:38:36 +0000 (15:38 +0100)]
dhcpv6-ia: rework append_reply()

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 months agodhcpv6-ia: fix compiler warning
Hans Dedecker [Wed, 16 Jan 2019 21:40:46 +0000 (22:40 +0100)]
dhcpv6-ia: fix compiler warning

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>
3 months agodhcpv6-ia: fix onlink IA check (FS#2060)
Hans Dedecker [Wed, 16 Jan 2019 10:03:14 +0000 (11:03 +0100)]
dhcpv6-ia: fix onlink IA check (FS#2060)

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>
3 months agodhcpv6: add setting to choose IA_NA, IA_PD or both
Matija Amidzic [Fri, 21 Dec 2018 14:58:47 +0000 (15:58 +0100)]
dhcpv6: add setting to choose IA_NA, IA_PD or both

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>
3 months agorouter: add syslog tracing for skipped routes
Hans Dedecker [Wed, 2 Jan 2019 20:36:27 +0000 (21:36 +0100)]
router: add syslog tracing for skipped routes

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 months agorouter: filter route information option
Hans Dedecker [Wed, 2 Jan 2019 18:23:11 +0000 (19:23 +0100)]
router: filter route information option

Commit 750e457e3000187b85906814a2529ede24775325 added the capability
to filter out prefixes in RAs; however routes were not filtered out
based on the prefixes. This commit fixes this by taking into account
the prefix_filter when constructing the RA route info option

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 months agorouter: make announcing DNS info configurable (FS#2020)
Hans Dedecker [Mon, 31 Dec 2018 16:06:40 +0000 (17:06 +0100)]
router: make announcing DNS info configurable (FS#2020)

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>
3 months agorouter: check return code of odhcpd_get_interface_dns_addr()
Hans Dedecker [Mon, 31 Dec 2018 15:00:12 +0000 (16:00 +0100)]
router: check return code of odhcpd_get_interface_dns_addr()

Check if odhcpd_get_interface_dns_addr() returns a valid DNS address.
While at it restructure the DNS RA code to make it more readable

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
3 months agoconfig: check for invalid DNS addresses
Hans Dedecker [Mon, 31 Dec 2018 14:41:25 +0000 (15:41 +0100)]
config: check for invalid DNS addresses

Don't accept 0.0.0.0 and :: as DNS addresses.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 months agoodhcpd: switch to libubox container_of implementation
Hans Dedecker [Wed, 12 Dec 2018 17:48:30 +0000 (18:48 +0100)]
odhcpd: switch to libubox container_of implementation

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 months agotreewide: switch to libubox ARRAY_SIZE immplementation
Hans Dedecker [Wed, 12 Dec 2018 16:58:18 +0000 (17:58 +0100)]
treewide: switch to libubox ARRAY_SIZE immplementation

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 months agonetlink: fix triggering of NETEV_ADDR6LIST_CHANGE event
Hans Dedecker [Mon, 26 Nov 2018 13:58:08 +0000 (14:58 +0100)]
netlink: fix triggering of NETEV_ADDR6LIST_CHANGE event

Generate a NETEV_ADDR6LIST_CHANGE event in case the preferred lifetime
makes a transition from deprecated (preferred lifetime not greater than
current timestamp) to not deprecated (preferred lifetime greater than
current timestamp)

Reported-by: Tian Hao <haotia@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
4 months agoconfig: correctly break string for prefix filter
Hamster Tian [Thu, 22 Nov 2018 15:36:14 +0000 (23:36 +0800)]
config: correctly break string for prefix filter

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>
6 months agoodhcpd: make DHCPv6/RA/NDP support optional
Hans Dedecker [Sun, 30 Sep 2018 19:54:33 +0000 (21:54 +0200)]
odhcpd: make DHCPv6/RA/NDP support optional

In case IPv6 is not enabled don't try to init DHCPv6/RA and NDP but only
init DHCPv4. This allows odhcpd to start up in absence of IPv6 support.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
6 months agodhcpv6: check return code of dhcpv6_ia_init()
Hans Dedecker [Sun, 23 Sep 2018 18:21:54 +0000 (20:21 +0200)]
dhcpv6: check return code of dhcpv6_ia_init()

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
6 months agorouter: don't leak RA message in relay mode (FS#1853)
Hans Dedecker [Sun, 23 Sep 2018 17:06:08 +0000 (19:06 +0200)]
router: don't leak RA message in relay mode (FS#1853)

In relay mode don't send RA message with router lifetime equal to 0 when
interface gets disabled as router

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
7 months agoodhcpd: detect broken hostnames
Hans Dedecker [Wed, 22 Aug 2018 09:45:53 +0000 (11:45 +0200)]
odhcpd: detect broken hostnames

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>
7 months agoconfig: fix odhcpd_attrs array size
Hans Dedecker [Mon, 3 Sep 2018 11:46:28 +0000 (13:46 +0200)]
config: fix odhcpd_attrs array size

Use ODHCPD_ATTR_MAX as array size of odhcpd_attrs

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
8 months agoubus: avoid dumping interface state with NULL message
Jo-Philipp Wich [Thu, 26 Jul 2018 12:26:37 +0000 (14:26 +0200)]
ubus: avoid dumping interface state with NULL message

Invoking ubus methods with NULL message is not supported anymore, so
make sure that network.interface/dump is called with an empty blob buffer
argument.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
9 months agodhcpv4: improve error checking in handle_dhcpv4()
Hans Dedecker [Mon, 9 Jul 2018 06:58:00 +0000 (08:58 +0200)]
dhcpv4: improve error checking in handle_dhcpv4()

Check ioctl return value as reported by Coverity in CID1437659

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 months agoodhcpd: Check if open the ioctl socket failed
Hyeonsik Song [Thu, 5 Jul 2018 01:45:37 +0000 (10:45 +0900)]
odhcpd: Check if open the ioctl socket failed

Signed-off-by: Hyeonsik Song <blogcin@naver.com>
9 months agodhcpv6-ia: fix border assignment size setting
Hans Dedecker [Tue, 26 Jun 2018 10:17:11 +0000 (12:17 +0200)]
dhcpv6-ia: fix border assignment size setting

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>
9 months agodhcpv6-ia: fix status code for not on link IAs
Hans Dedecker [Mon, 25 Jun 2018 14:51:42 +0000 (16:51 +0200)]
dhcpv6-ia: fix status code for not on link IAs

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>
10 months agodhcpv6-ia: improve error checking in assign_pd()
Hans Dedecker [Fri, 22 Jun 2018 14:32:31 +0000 (16:32 +0200)]
dhcpv6-ia: improve error checking in assign_pd()

Detected by Coverity in CID1412267

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agoconfig: fix wrong assignment
Hans Dedecker [Fri, 22 Jun 2018 14:16:30 +0000 (16:16 +0200)]
config: fix wrong assignment

Detected by Coverity in CID1430899

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv4: delay forced renew transaction start
Hans Dedecker [Thu, 21 Jun 2018 08:25:53 +0000 (10:25 +0200)]
dhcpv4: delay forced renew transaction start

Delay the start of the forced renew transaction start with a random delay
between 500 and 1000 ms. This avoids sending DHCP forced renew messages
in case the DHCP client starts sending discover messages triggered by
link state flap.
Also it distributes sending of DHCP forced renew messages to different clients
over an interval instead of sending DHCP forced renew messages in a burst mode.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv4: fix DHCP address space logic
Hans Dedecker [Thu, 21 Jun 2018 14:36:29 +0000 (16:36 +0200)]
dhcpv4: fix DHCP address space logic

Don't use an IPv4 address which belongs to the force renew IP address
list as candidate for the DHCP address space calculation logic as
such addresses are installed by the forced renew logic to safeguard
IP connectivity during the forced renew message exchanges and thus
cannot be used to calculate the DHCP address space

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv4: improve logging when sending DHCP messages
Hans Dedecker [Fri, 15 Jun 2018 12:30:18 +0000 (14:30 +0200)]
dhcpv4: improve logging when sending DHCP messages

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agoodhcpd: call handle_error when socket error can be retrieved
Hans Dedecker [Wed, 13 Jun 2018 20:15:51 +0000 (22:15 +0200)]
odhcpd: call handle_error when socket error can be retrieved

Detected by Coverity in CID1412300

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv6: fix out of bounds write in handle_nested_message()
Hans Dedecker [Thu, 7 Jun 2018 20:36:29 +0000 (22:36 +0200)]
dhcpv6: fix out of bounds write in handle_nested_message()

Detected by Coverity in CID1412413

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv6-ia: log renew messages as well
Hans Dedecker [Thu, 7 Jun 2018 15:33:27 +0000 (17:33 +0200)]
dhcpv6-ia: log renew messages as well

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>
10 months agorouter: fix possible segfault in send_router_advert()
Hans Dedecker [Mon, 4 Jun 2018 20:07:13 +0000 (22:07 +0200)]
router: fix possible segfault in send_router_advert()

Detected by Coverity in CID1412349

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agoodhcpd: fix passing possible negative parameter
Hans Dedecker [Mon, 4 Jun 2018 19:49:52 +0000 (21:49 +0200)]
odhcpd: fix passing possible negative parameter

Prevent passing negative argument to read; detected by Coverity in CID1412381

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agotreewide: switch to C-code style comments
Hans Dedecker [Mon, 28 May 2018 10:26:19 +0000 (12:26 +0200)]
treewide: switch to C-code style comments

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agorouter: improve error checking
Hans Dedecker [Sun, 27 May 2018 20:18:25 +0000 (22:18 +0200)]
router: improve error checking

Improve error checking fixing resource leak detected by Coverity in CID
1430880.
Further fix unchecked return value reported by Coverity in CIDs 1430872,
14308391430831 and 1412382

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agonetlink: fix incorrect sizeof argument
Hans Dedecker [Sat, 26 May 2018 11:30:47 +0000 (13:30 +0200)]
netlink: fix incorrect sizeof argument

Fix incorrect sizeof arguments detetced by Coverity in CID 1430866 and
CID 1430893

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 months agodhcpv6: improve error checking in dhcpv6_setup_interface()
Hans Dedecker [Sat, 19 May 2018 20:37:27 +0000 (22:37 +0200)]
dhcpv6: improve error checking in dhcpv6_setup_interface()

Improve error checking fixing resource leakage detected by Coverity in
CID 1430880

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agoubus: fix invalid ipv6-prefix json
Mislav Novakovic [Mon, 21 May 2018 16:07:38 +0000 (18:07 +0200)]
ubus: fix invalid ipv6-prefix json

"ipv6-prefix": [
{
"<some ipv6 address>",
"preferred-lifetime": 37979,
"valid-lifetime": 48779,
"prefix-length": 63
}
],

json object is missing key, set address as key name.

Line up DHCPv4 lease json info by using key name "address"

Signed-off-by: Mislav Novakovic <mislav.novakovic@sartura.hr>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agondp: improve error checking
Hans Dedecker [Wed, 16 May 2018 19:57:31 +0000 (21:57 +0200)]
ndp: improve error checking

Improve error checking; fixes resource leak detected by Coverity
in CID 1430925

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agodhcpv4: fix error checking in dhcpv4_setup_interface()
Hans Dedecker [Wed, 16 May 2018 19:36:16 +0000 (21:36 +0200)]
dhcpv4: fix error checking in dhcpv4_setup_interface()

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agodhcpv4: fix out of bound access in dhcpv4_put
Hans Dedecker [Tue, 15 May 2018 20:22:30 +0000 (22:22 +0200)]
dhcpv4: fix out of bound access in dhcpv4_put

Detected by Coverity in CID 1433363 and 1432121

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agodhcpv4: improve error checking in dhcpv4_setup_interface()
Hans Dedecker [Mon, 7 May 2018 13:49:13 +0000 (15:49 +0200)]
dhcpv4: improve error checking in dhcpv4_setup_interface()

Improve error checking fixing resource leakage detected by Coverity in
CID 1433402

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agoodhcpd: fix strncpy bounds
Hans Dedecker [Thu, 3 May 2018 15:21:15 +0000 (17:21 +0200)]
odhcpd: fix strncpy bounds

Fix strncpy bounds as reported by Coverity in CID 1412278 and 1412293

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
11 months agodhcpv6-ia: keep tentative assignments alive for a short time
Hans Dedecker [Mon, 23 Apr 2018 11:32:19 +0000 (13:32 +0200)]
dhcpv6-ia: keep tentative assignments alive for a short time

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>
11 months agodhcpv6-ia: make assignment lookup more strict
Hans Dedecker [Mon, 23 Apr 2018 09:56:27 +0000 (11:56 +0200)]
dhcpv6-ia: make assignment lookup more strict

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>
12 months agorouter: fix managed address configuration setting
Hans Dedecker [Wed, 18 Apr 2018 12:09:47 +0000 (14:09 +0200)]
router: fix managed address configuration setting

Don't announce managed address configuration in case DHCPv6 is disabled

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
12 months agorouter: improve RFC7084 compliancy
Hans Dedecker [Mon, 9 Apr 2018 15:01:45 +0000 (17:01 +0200)]
router: improve RFC7084 compliancy

Send Router Information Option as well for prefixes with length 64 in order
to be compliant with L-3 in RFC7084: An IPv6 CE router must advertise
itself as a router for the delegated prefixes using the "Route Information
Option".

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
14 months agodhcpv6-ia: don't always send reconf accept option (FS#1377)
Hans Dedecker [Tue, 20 Feb 2018 10:23:25 +0000 (11:23 +0100)]
dhcpv6-ia: don't always send reconf accept option (FS#1377)

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>
16 months agoodhcpd: Replace strerror(errno) with %m format
Rosen Penev [Sun, 17 Dec 2017 03:55:04 +0000 (19:55 -0800)]
odhcpd: Replace strerror(errno) with %m format

Saves a few bytes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
16 months agoSupport muliple RAs on single interface
Pierre Pfister [Fri, 8 Dec 2017 14:15:02 +0000 (15:15 +0100)]
Support muliple RAs on single interface

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>
16 months agodhcpv4: notify DHCP ACK and RELEASE via ubus
Hans Dedecker [Tue, 28 Nov 2017 14:08:27 +0000 (15:08 +0100)]
dhcpv4: notify DHCP ACK and RELEASE via ubus

If the ubus object has any subscription notify DHCP ACK and DHCP RELEASE
events using ubus notifications.

Signed-off-by: Borja Salazar <borja.salazar@fon.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
16 months agodhcpv6: fix compile issues when CER-ID extension is enabled
Hans Dedecker [Sat, 25 Nov 2017 16:42:00 +0000 (17:42 +0100)]
dhcpv6: fix compile issues when CER-ID extension is enabled

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
17 months agondp: add switch/case fallthrough comments
Hans Dedecker [Tue, 21 Nov 2017 13:48:14 +0000 (14:48 +0100)]
ndp: add switch/case fallthrough comments

Fixes gcc 7 build errors

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
17 months agodhcpv4: make DHCPv4 support compiletime configurable
Hans Dedecker [Thu, 9 Nov 2017 15:09:51 +0000 (16:09 +0100)]
dhcpv4: make DHCPv4 support compiletime configurable

Make DHCPv4 support compile time configurable; avoids DHCPv4 functionality
overlap with other packages.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
17 months agotreewide: rework handling of netlink events
Hans Dedecker [Tue, 17 Oct 2017 14:23:35 +0000 (16:23 +0200)]
treewide: rework handling of netlink events

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>
18 months agotreewide: add netlink file
Hans Dedecker [Fri, 13 Oct 2017 13:35:29 +0000 (15:35 +0200)]
treewide: add netlink file

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>
18 months agotreewide: align function naming
Hans Dedecker [Fri, 13 Oct 2017 10:09:28 +0000 (12:09 +0200)]
treewide: align function naming

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agodhcpv4: fix memset compile issue
Hans Dedecker [Wed, 13 Sep 2017 13:56:42 +0000 (15:56 +0200)]
dhcpv4: fix memset compile issue

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agodhcpv4: rework assignment lookup
Hans Dedecker [Tue, 12 Sep 2017 09:03:37 +0000 (11:03 +0200)]
dhcpv4: rework assignment lookup

When receiving a DHCPv4 message use find_assignment_by_hwaddr to find
an assignment as only one entry can be present in the assignment table
for a given mac address.
While at it pass requested address by the client as an uint32_t type
to clean up the code.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agodhcpv4: cleanup dhcpv4_test usage
Hans Dedecker [Tue, 12 Sep 2017 08:52:12 +0000 (10:52 +0200)]
dhcpv4: cleanup dhcpv4_test usage

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agodhcpv4: rework lease expire handling logic
Hans Dedecker [Tue, 12 Sep 2017 08:31:13 +0000 (10:31 +0200)]
dhcpv4: rework lease expire handling logic

Don't rely on incoming DHCPv4 messages to trigger the lease expire
detection logic but rather use a periodic timer which checks every
second if a lease is expired

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agodhcpv4: force renew nonce authentication support
Hans Dedecker [Thu, 6 Jul 2017 07:41:10 +0000 (09:41 +0200)]
dhcpv4: force renew nonce authentication support

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>
19 months agodhcpv4: avoid segfault when there's no IPv4 prefix
Hans Dedecker [Mon, 3 Jul 2017 14:39:21 +0000 (16:39 +0200)]
dhcpv4: avoid segfault when there's no IPv4 prefix

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
19 months agondp: detect ifindex changes via interface netlink events
Hans Dedecker [Fri, 11 Aug 2017 14:05:01 +0000 (16:05 +0200)]
ndp: detect ifindex changes via interface netlink events

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>