View Issue Details

IDProjectCategoryView StatusLast Update
643RackTablesIPv4/IPv6/SLBpublic2012-12-17 07:01
ReporterKriS Assigned Toandriyanov  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version8.04 x64
Product Version0.20.1 
Target Version0.20.2Fixed in Version0.20.2 
Summary643: New Subnet is added wrong
DescriptionAfter 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 ReproduceTry adding 213.131.249.0/25 or 213.131.253.192/26
TagsNo tags attached.

Relationships

has duplicate 695 closedandriyanov Add IPV4 space error 

Activities

andriyanov

andriyanov

2012-10-18 12:17

reporter   ~0000885

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.
KriS

KriS

2012-10-18 12:27

reporter   ~0000887

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?
KriS

KriS

2012-10-18 12:30

reporter   ~0000889

I forgot to add:

Node1 (Webserver) is 64bit - Ubuntu 8.04
Node2 (Databaseserver) is 32bit - Ubuntu 8.04
andriyanov

andriyanov

2012-10-18 14:15

reporter   ~0000895

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";

?>
KriS

KriS

2012-10-18 14:50

reporter   ~0000897

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
andriyanov

andriyanov

2012-10-18 15:41

reporter   ~0000903

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)
KriS

KriS

2012-10-18 18:51

reporter   ~0000907

Hi,

this patch works.
Thanks alot!

Will this be available in future versions, or is this a custom fix?
andriyanov

andriyanov

2012-10-18 20:22

reporter   ~0000909

Yes, this will be released in 0.20.2.

Issue History

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