- Timestamp:
- 12/18/14 15:49:11 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r653 r655 1443 1443 my $sth2 = $dbh->prepare("INSERT INTO poolips (ip,city,type,custid,parent_id) VALUES ". 1444 1444 "(?,'$poolcity','$pooltype','$poolcustid',$poolid)"); 1445 1445 1446 ##fixme: need to not insert net, gateway, and bcast on "real netblock" pools (DHCPish) 1446 1447 # don't insert .0 1447 1448 $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++; 1450 1454 } 1451 $cidr--;1452 1455 # don't insert .255 1453 1456 $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 1454 1464 } 1455 1465 … … 1461 1471 else { 1462 1472 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. :/ 1463 1477 # Get all possible (and probably a number of impossible) containers for $cidr 1464 1478 $sth = $dbh->prepare("SELECT cidr,parent_id,type,city,id FROM allocations ". 1465 1479 "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"); 1467 1481 $sth->execute($cidr, $binfo->{master_id}); 1468 1482 … … 1505 1519 # Special case - delete pool IPs 1506 1520 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? 1508 1523 $dbh->do("DELETE FROM poolips WHERE parent_id = ?", undef, ($id) ); 1509 1524 }
Note:
See TracChangeset
for help on using the changeset viewer.