View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
643 | RackTables | IPv4/IPv6/SLB | public | 2012-10-18 09:43 | 2012-12-17 07:01 |
Reporter | KriS | Assigned To | andriyanov | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | Ubuntu | OS Version | 8.04 x64 |
Product Version | 0.20.1 | ||||
Target Version | 0.20.2 | Fixed in Version | 0.20.2 | ||
Summary | 643: New Subnet is added wrong | ||||
Description | After adding a subnet like 213.131.249.0/25 or 213.131.253.192/26 RackTables shows them to be 255.255.255.0-128. One has to change the decimal TCPIP in the database manually for it to show the correct IPs/Subnet. | ||||
Steps To Reproduce | Try adding 213.131.249.0/25 or 213.131.253.192/26 | ||||
Tags | No tags attached. | ||||
has duplicate | 695 | closed | andriyanov | Add IPV4 space error |
Does not reproduce neither on my installation nor on demo.racktables.org. Have I understood correct that your DB contains the '4294967040' value in ip field? Please report OS version, system architecture (32- or 64-bit), PHP and mysql versions. |
|
Hi, yes. You have understood right. And you are also right that I can't reproduce this error on the demo site :( PHP Version: 5.2.4-2ubuntu5.26 MySQL Version: 5.0.96-0ubuntu3 Webserver (Node1): 2.2.8-1ubuntu0.23 MySQL Server (Node2): 5.0.96-0ubuntu3 I've now just added the following Network: 213.131.253.0/26 The entry in IPv4Network Table in MySQL in the field "ip" is set to "4294967295". Can this be a locale issue or something? |
|
I forgot to add: Node1 (Webserver) is 64bit - Ubuntu 8.04 Node2 (Databaseserver) is 32bit - Ubuntu 8.04 |
|
Please report your IPv4Network SQL table schema. Also please post the results of this PHP script: <?php $script_mode = TRUE; require 'wwwroot/inc/init.php'; $net = constructIPRange (ip_parse ('213.131.253.0'), 26); echo "net = ${net['ip']}/${net['mask']}\n"; echo "db.ip = " . ip4_bin2db ($net['ip_bin']) . "\n"; ?> |
|
Hi, here is the output of the PHP script: net = 213.131.253.0/26 db.ip = 18446744072996781312 Table Schema looks like this (Export from phpMyAdmin): --- snip --- CREATE TABLE IF NOT EXISTS `IPv4Network` ( `id` int(10) unsigned NOT NULL auto_increment, `ip` int(10) unsigned NOT NULL default '0', `mask` int(10) unsigned NOT NULL default '0', `name` char(255) default NULL, `comment` text, PRIMARY KEY (`id`), UNIQUE KEY `base-len` (`ip`,`mask`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ; --- snap --- Thanks |
|
Seems that your PHP version is returning a negative integer from unpack ('N', "4byt"), which is terribly wrong. Please try this patch: does it help? diff --git a/wwwroot/inc/functions.php b/wwwroot/inc/functions.php index b4f07ef..815695b 100644 --- a/wwwroot/inc/functions.php +++ b/wwwroot/inc/functions.php @@ -2229,8 +2229,10 @@ function ip4_bin2int ($ip_bin) { if (4 != strlen ($ip_bin)) throw new InvalidArgException ('ip_bin', $ip_bin, "Invalid binary IP"); - $list = unpack ('N', $ip_bin); - return array_shift ($list); + $ret = array_first (unpack ('N', $ip_bin)); + if (PHP_INT_SIZE > 4 && $ret < 0) + $ret = $ret & 0xffffffff; + return $ret; } // Use this function only when you need to export binary ip out of PHP running context (e.g., DB) |
|
Hi, this patch works. Thanks alot! Will this be available in future versions, or is this a custom fix? |
|
Yes, this will be released in 0.20.2. | |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-10-18 09:43 | KriS | New Issue | |
2012-10-18 09:43 | KriS | Status | new => assigned |
2012-10-18 09:43 | KriS | Assigned To | => andriyanov |
2012-10-18 12:17 | andriyanov | Note Added: 0000885 | |
2012-10-18 12:27 | KriS | Note Added: 0000887 | |
2012-10-18 12:30 | KriS | Note Added: 0000889 | |
2012-10-18 14:15 | andriyanov | Note Added: 0000895 | |
2012-10-18 14:50 | KriS | Note Added: 0000897 | |
2012-10-18 15:41 | andriyanov | Note Added: 0000903 | |
2012-10-18 18:51 | KriS | Note Added: 0000907 | |
2012-10-18 20:22 | andriyanov | Note Added: 0000909 | |
2012-10-18 20:22 | andriyanov | Status | assigned => closed |
2012-10-18 20:22 | andriyanov | Resolution | open => fixed |
2012-10-18 20:22 | andriyanov | Fixed in Version | => 0.20.2 |
2012-10-18 20:22 | andriyanov | Target Version | => 0.20.2 |
2012-12-17 07:01 | infrastation | Relationship added | has duplicate 695 |