Changeset 655


Ignore:
Timestamp:
12/18/14 15:49:11 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Smooth off some rough edges on edge cases in deleteBlock()

File:
1 edited

Legend:

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

    r653 r655  
    14431443        my $sth2 = $dbh->prepare("INSERT INTO poolips (ip,city,type,custid,parent_id) VALUES ".
    14441444          "(?,'$poolcity','$pooltype','$poolcustid',$poolid)");
     1445
    14451446##fixme:  need to not insert net, gateway, and bcast on "real netblock" pools (DHCPish)
    14461447        # don't insert .0
    14471448        $sth2->execute($cidr->addr) unless $cidr->addr =~ m|\.0$|;
    1448         foreach my $ip ($cidr->hostenum) {
    1449           $sth2->execute($ip);
     1449        $cidr++;
     1450        my $bcast = $cidr->broadcast;
     1451        while ($cidr != $bcast) {
     1452          $sth2->execute($cidr->addr);
     1453          $cidr++;
    14501454        }
    1451         $cidr--;
    14521455        # don't insert .255
    14531456        $sth2->execute($cidr->addr) unless $cidr->addr =~ m|\.255$|;
     1457
     1458# Weirdness Happens.  $cidr goes read-only somewhere (this is a thing?!?),
     1459# causing ->split, ->hostenum, and related methods to explode.  O_o
     1460#        foreach my $ip ($cidr->hostenum) {
     1461#          $sth2->execute($ip);
     1462#        }
     1463
    14541464      }
    14551465
     
    14611471      else {
    14621472
     1473# Edge case:  Block is the same size as more than one parent level.  Should be rare.
     1474# - mainly master + first routing.  Sorting on parent_id hides the problem pretty well,
     1475# but it's likely still possible to fail in particularly well-mangled databases.
     1476# The ultimate fix for this may be to resurrect the "routing depth" atrocity.  :/
    14631477        # Get all possible (and probably a number of impossible) containers for $cidr
    14641478        $sth = $dbh->prepare("SELECT cidr,parent_id,type,city,id FROM allocations ".
    14651479          "WHERE (type LIKE '_m' OR type LIKE '_c') AND cidr >>= ? AND master_id = ? ".
    1466           "ORDER BY masklen(cidr) DESC");
     1480          "ORDER BY masklen(cidr) DESC,parent_id DESC");
    14671481        $sth->execute($cidr, $binfo->{master_id});
    14681482
     
    15051519        # Special case - delete pool IPs
    15061520        if ($binfo->{type} =~ /^.[pd]$/) {
    1507           # We have to delete the IPs from the pool listing.
     1521          # We have to delete the IPs from the pool listing.
     1522##fixme:  rdepth?  vrf?
    15081523          $dbh->do("DELETE FROM poolips WHERE parent_id = ?", undef, ($id) );
    15091524        }
Note: See TracChangeset for help on using the changeset viewer.