Changeset 899 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
11/29/16 16:43:32 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix subtle bug in splitBlock() - if there was a free block at the beginning
of a container block to be split, that itself would need to be split, it
would end up deleted instead. This affected eg a /24 with .128/25 assigned,
and .0/25 free split into /26 or smaller (the .0 free block would go
missing), or a /24 with two /25 containers with no further allocations split
into /26 or smaller (both the resulting .0 and .128 free blocks would go
missing).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r893 r899  
    22472247      my @nbset = $pr->{cidr}->split($args{newmask});
    22482248
    2249       # set up update of existing block
     2249      # update existing block
    22502250      $dbh->do("UPDATE allocations SET cidr = ? WHERE id = ?", undef, ("$nbset[0]", $pr->{id}) );
    22512251
     
    23202320
    23212321      if (%fbdel) {
     2322        # pretty sure this SELECT result isn't used...
    23222323        my $delfblist = $dbh->selectall_arrayref(q{
    23232324            SELECT cidr,parent_id,id FROM freeblocks
    23242325            WHERE id in (
    23252326            }.join(',', keys %fbdel).")", {Slice=>{}} );
    2326         $dbh->do("DELETE FROM freeblocks WHERE id IN (".join(',', keys %fbdel).")") if %fbdel;
     2327        foreach my $fbd (keys %fbdel) {
     2328          $dbh->do("UPDATE freeblocks SET cidr = set_masklen(cidr, ?) WHERE id = ?", undef, $args{newmask}, $fbd);
     2329        }
    23272330      }
    23282331
Note: See TracChangeset for help on using the changeset viewer.