diff options
author | Andrei Pavel <andrei@isc.org> | 2023-04-26 14:45:29 +0200 |
---|---|---|
committer | Andrei Pavel <andrei@isc.org> | 2023-05-17 18:09:38 +0200 |
commit | 4a06d2baf0dff1d21948bd9a39f100c94a159fe0 (patch) | |
tree | 83c4bce0b946e63e204521806ad0341f747e5f46 /src/lib/dhcpsrv/cfg_subnets4.cc | |
parent | [#2658] add BigIntElement (diff) | |
download | kea-4a06d2baf0dff1d21948bd9a39f100c94a159fe0.tar.xz kea-4a06d2baf0dff1d21948bd9a39f100c94a159fe0.zip |
[#2658] add big integer support to statistics
Pool capacities have been promoted in code from uint64_t to uint128_t.
Bigint is modelled as an int128_t in statistics, following the precedent of
signed integer of int64_t from statistics.
- "total-nas" is extended to 128 bits as requested in the issue.
- "total-pds" has the same risk of overflowing so it has been extended
as well.
- "total-addresses" always fits in 64 bits, but certain code forces a
128 bit value on it. See Pool::getCapacity(), Subnet::getPoolCapacity(),
Subnet::sumPoolCapacity(). It could have been truncated to a 64 bit value,
but that seems like an unnecessary complication.
Because of the disparity in signedness there is some truncation that can
happen when pool capacity values are passed on to statistics. That only happens
for the last half of the value range, so for prefix ranges larger than /1.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_subnets4.cc')
-rw-r--r-- | src/lib/dhcpsrv/cfg_subnets4.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/lib/dhcpsrv/cfg_subnets4.cc b/src/lib/dhcpsrv/cfg_subnets4.cc index 381b4d4404..aaebbd693a 100644 --- a/src/lib/dhcpsrv/cfg_subnets4.cc +++ b/src/lib/dhcpsrv/cfg_subnets4.cc @@ -553,8 +553,7 @@ CfgSubnets4::updateStatistics() { stats_mgr.setValue(StatsMgr:: generateName("subnet", subnet_id, "total-addresses"), - static_cast<int64_t> - (subnet4->getPoolCapacity(Lease::TYPE_V4))); + int64_t(subnet4->getPoolCapacity(Lease::TYPE_V4))); std::string name = StatsMgr::generateName("subnet", subnet_id, "cumulative-assigned-addresses"); if (!stats_mgr.getObservation(name)) { |