Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Non-sequential subnet IDs are improperly handled #19

Open
krocd opened this issue Oct 27, 2018 · 1 comment
Open

Non-sequential subnet IDs are improperly handled #19

krocd opened this issue Oct 27, 2018 · 1 comment
Labels
stork This problem is likely addressed with Stork. See https://github.com/isc-projects/stork

Comments

@krocd
Copy link

krocd commented Oct 27, 2018

app.js lines 257-259:

for (var i = 1; i <= subnet_count; i++) {
	global.kea_server.total_leases += global.kea_stats['subnet[' + i + '].assigned-' + global.kea_server.addr_tag][0][0];
}

Kea Administrator Reference documentation:
https://jenkins.isc.org/job/Kea_doc/guide/kea-guide.html#ipv4-subnet-id

If there are multiple subnets configured with auto-generated identifiers and one of them is removed, the subnet identifiers may be renumbered. For example: if there are four subnets and the third is removed the last subnet will be assigned the identifier that the third subnet had before removal. As a result, the leases stored in the lease database for subnet 3 are now associated with subnet 4, something that may have unexpected consequences. It is planned to implement a mechanism to preserve auto-generated subnet ids in a future version of Kea. However, the only remedy for this issue at present is to manually specify a unique identifier for each subnet.

The statistics code above doesn't account for non-sequential subnet IDs. This causes the code block to fail with the following error:

Error 1:  TypeError: Cannot read property '0' of undefined
    at /home/pi/kea-anterius/app.js:258:135
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Recommend something like this instead:

for (var i = 0; i < subnet_count; i++)
{       
	var subnet = global.kea_server.subnet_list[i];
	global.kea_server.total_leases += global.kea_stats['subnet[' + subnet.id + '].assigned-' + global.kea_server.addr_tag][0][0];
}

Similar faulty logic is littered throughout routes/index.js as well, which results in the following web page error when navigating to the root site:

Cannotread property '0' of undefined

@tomaszmrugalski tomaszmrugalski added the stork This problem is likely addressed with Stork. See https://github.com/isc-projects/stork label Apr 15, 2020
@tomaszmrugalski
Copy link
Member

This problem doesn't exist in Stork. Our test environment uses non-consecutive subnet-ids. Some are starting from one, others from 11 and yet another from 21. Take a look at that Grafana screenshots (need to scroll down quite a bit).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stork This problem is likely addressed with Stork. See https://github.com/isc-projects/stork
Projects
None yet
Development

No branches or pull requests

2 participants