Révision 316a59e1
dhcp-pool: Fix off-by-one error in pool size.
"range" statement gives the lowest and highest IP addresses (both
inclusive) in a pool. dhcp-pool did not count the highest address
when calculating pool size.
| plugins/network/dhcp-pool | ||
|---|---|---|
| 73 | 73 |
# For each pool, count how many leases from that pool are currently active |
| 74 | 74 |
foreach $start (keys %pools) {
|
| 75 | 75 |
$size = $pools{$start};
|
| 76 |
$end = $start+$size; |
|
| 76 |
$end = $start+$size-1;
|
|
| 77 | 77 |
$free = $size; |
| 78 | 78 |
|
| 79 | 79 |
foreach $lease (@activeleases) {
|
| ... | ... | |
| 103 | 103 |
if ($line =~ /range[\s]+([\d]+\.[\d]+\.[\d]+\.[\d]+)[\s]+([\d]+\.[\d]+\.[\d]+\.[\d]+)/) {
|
| 104 | 104 |
$start = string2ip($1); |
| 105 | 105 |
$end = string2ip($2); |
| 106 |
$size = $end - $start; |
|
| 106 |
|
|
| 107 | 107 |
defined($start) || next; |
| 108 | 108 |
defined($end) || next; |
| 109 |
|
|
| 110 |
# The range statement gives the lowest and highest IP addresses in a range. |
|
| 111 |
$size = $end - $start + 1; |
|
| 109 | 112 |
|
| 110 | 113 |
$pools{$start} = $size;
|
| 111 | 114 |
} |
Formats disponibles : Unified diff