summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-12-10 20:44:01 -0800
committerMark Wells <mark@freeside.biz>2013-12-10 20:44:01 -0800
commit7cc8431906315822e8107143920bbca85e5b53ce (patch)
tree0f254ca8ef72c016e9ea0c79831d76bd03485a4b
parenta4c1077430ac3b053c30084dcf76c54be45dca08 (diff)
actually make auto-assignment avoid forbidden ranges, #25530
-rwxr-xr-xFS/FS/addr_block.pm12
-rw-r--r--FS/FS/addr_range.pm7
2 files changed, 12 insertions, 7 deletions
diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm
index 6a62777..1f4000b 100755
--- a/FS/FS/addr_block.pm
+++ b/FS/FS/addr_block.pm
@@ -256,7 +256,17 @@ sub next_free_addr {
# just do a linear search of the block
my $freeaddr = $selfaddr->network + 1;
while ( $freeaddr < $selfaddr->broadcast ) {
- return $freeaddr unless $used{ $freeaddr->addr };
+ # also make sure it's not blocked from assignment by an address range
+ if ( !$used{$freeaddr->addr } ) {
+ my ($range) = grep { !$_->allow_use }
+ FS::addr_range->any_contains($freeaddr);
+ if ( !$range ) {
+ # then we've found a free address
+ return $freeaddr;
+ }
+ # otherwise, skip to the end of the range
+ $freeaddr = NetAddr::IP->new($range->end, $self->ip_netmask);
+ }
$freeaddr++;
}
return;
diff --git a/FS/FS/addr_range.pm b/FS/FS/addr_range.pm
index 5faa443..18ae1e2 100644
--- a/FS/FS/addr_range.pm
+++ b/FS/FS/addr_range.pm
@@ -219,11 +219,6 @@ sub desc {
$status_desc{ $self->status };
}
-sub allow_auto {
- my $self = shift;
- $status_allow_auto{ $self->status };
-}
-
sub allow_use {
my $self = shift;
$status_allow_use{ $self->status };
@@ -250,7 +245,7 @@ sub any_contains {
L<NetAddr::IP> objects have netmasks. When using them to represent
range endpoints, be sure to set the netmask to I<zero> so that math on
the address doesn't stop at the subnet boundary. (The default is /32,
-which doesn't work very well. Address ranges ignore subnet boundaries.
+which doesn't work very well. Address ranges ignore subnet boundaries.)
=head1 BUGS