X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FIP_Mixin.pm;h=b68b0b6241a6cbfe527058b30a32da0a6537dfa3;hb=e2ee874843b19f6c5221f5ce0af90979dba34e57;hp=beb41d290de4950deb892efc74b44dd643c67091;hpb=4b05b20576ddb14577d59c87c8257c6804449410;p=freeside.git diff --git a/FS/FS/IP_Mixin.pm b/FS/FS/IP_Mixin.pm index beb41d290..b68b0b624 100644 --- a/FS/FS/IP_Mixin.pm +++ b/FS/FS/IP_Mixin.pm @@ -130,6 +130,10 @@ sub assign_ip_addr { my $self = shift; my %opt = @_; + #otherwise we'll get the same assignment for concurrent identical calls + # this will serialize them + $_->lock_table foreach @subclasses; + my @blocks; my $na = $self->NetAddr; @@ -260,18 +264,22 @@ sub router { FS::router->by_key($self->routernum); } -=item used_addresses [ BLOCK ] +=item used_addresses [ FS::addr_block ] + +Returns a list of all addresses in use within the given L. -Returns a list of all addresses (in BLOCK, or in all blocks) -that are in use. If called as an instance method, excludes -that instance from the search. +If called as an instance method, excludes that instance from the search. =cut sub used_addresses { - my $self = shift; - my $block = shift; - return ( map { $_->_used_addresses($block, $self) } @subclasses ); + my ($self, $block) = @_; + + ( + $block->ip_gateway ? $block->ip_gateway : (), + $block->NetAddr->broadcast->addr, + map { $_->_used_addresses($block, $self ) } @subclasses + ); } sub _used_addresses {