View Issue Details

IDProjectCategoryView StatusLast Update
585RackTablesdefaultpublic2012-07-31 20:53
Reportermalayamanas Assigned Toandriyanov  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Platformx86OSCentosOS Version5.5
Product Version0.20.0 
Target Version0.20.0Fixed in Version0.20.0 
Summary585: New IPv4 address space is 127.0.0.0 instead of submitted value
DescriptionWhat ever IPV4 Address space is given, it creates an address space of loopback 127.0.0.0 range
Steps To ReproduceJust checkout from svn trunk and setup apache,mysql.
Add an IPV4 address space, it will create an address space starting from 127. range.

It is not happening in 0.19.3 version.
TagsNo tags attached.

Activities

malayamanas

malayamanas

2012-07-18 09:16

reporter   ~0000708

It is not happening in 0.19.13 version.
malayamanas

malayamanas

2012-07-26 09:01

reporter   ~0000715

Is there any update ?
andriyanov

andriyanov

2012-07-26 09:11

reporter   ~0000716

Can you provide the HTTP request dump with form parameters' values? Some kind of browser debugger could be used (e.g. FireBug).

Maybe your browser sends 127.0.0.0 to the server.
malayamanas

malayamanas

2012-07-30 13:47

reporter   ~0000718

I can confirm that in database it stores the IP range value correctly.
It may be the issue with displaying it after the addition.

mysql> SELECT ip, INET_NTOA(ip), mask FROM IPv4Network;
+-----------+---------------+------+
| ip | INET_NTOA(ip) | mask |
+-----------+---------------+------+
| 2886737408| 172.16.30.0 | 24 |
+-----------+---------------+------+

Please check.
malayamanas

malayamanas

2012-07-30 14:13

reporter   ~0000719

This issue may be associated with inc/database.php
malayamanas

malayamanas

2012-07-30 14:18

reporter  

live-http-header.PNG (139,025 bytes)   
live-http-header.PNG (139,025 bytes)   
malayamanas

malayamanas

2012-07-30 14:19

reporter   ~0000720

Uploaded screen shot from live-http-header firefox extension.
andriyanov

andriyanov

2012-07-30 21:54

reporter  

test.php (511 bytes)
andriyanov

andriyanov

2012-07-30 21:55

reporter   ~0000722

Please run the attached PHP script and post its output. Your current directory should contain wwwroot/inc dir.
malayamanas

malayamanas

2012-07-31 07:13

reporter   ~0000725

I ran the test.php and the out come is mentioned below.

ip = 172.16.30.0 ip_bin = ac101e0 net['ip'] = 127.255.255.0 net['ip_bin'] = 7fffff0 ip4_format() = 127.255.255.0
andriyanov

andriyanov

2012-07-31 10:08

reporter   ~0000726

Hmm, looks very strange.
Please grab some more diagnostics by typing these 3 commands:

# echo "show create table IPv4Network\G" | mysql racktables

# cat <<\END >test2.php
<?php
$script_mode = TRUE;
require 'wwwroot/inc/init.php';

$row = fetchIPv4AddressNetworkRow (ip_parse ('172.16.30.0'));
var_dump ($row);
echo ip_format (ip4_int2bin ($row['ip'])) . "\n";
END

# php test2.php
malayamanas

malayamanas

2012-07-31 10:17

reporter   ~0000727

TEST#1
===================

*************************** 1. row ***************************
       Table: IPv4Network
Create Table: CREATE TABLE `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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
==============================================================================

TEST#2
===============================================================================


array(5) {
  ["id"]=>
  string(2) "13"
  ["ip"]=>
  string(10) "2886737408"
  ["mask"]=>
  string(2) "24"
  ["name"]=>
  string(7) "pool-30"
  ["comment"]=>
  NULL
}
127.255.255.255

==========================================================================
malayamanas

malayamanas

2012-07-31 10:22

reporter   ~0000728

THIS IS FROM 0.20.0 DB OUTPUT FROM echo "show create table IPv4Network\G" | mysql racktables20

[root@localhost wwwroot]# echo "show create table IPv4Network\G" | mysql racktables20
*************************** 1. row ***************************
       Table: IPv4Network
Create Table: CREATE TABLE `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 AUTO_INCREMENT=14 DEFAULT CHARSET=utf8

======================================================
======================================================

THIS IS FROM 0.19.13 DB OUTPUT FROM echo "show create table IPv4Network\G" | mysql racktables

[root@localhost wwwroot]# echo "show create table IPv4Network\G" | mysql racktables
*************************** 1. row ***************************
       Table: IPv4Network


Create Table: CREATE TABLE `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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8

Difference is AUTO_INCREMENT value in both versions of the DB schema.
malayamanas

malayamanas

2012-07-31 11:02

reporter   ~0000729

From inc/functions.php

function ip4_int2bin ($ip_int) //expects an integer as parameter.
{
        return pack ('N', $ip_int);
}

But $row['ip'] is an array of string, which is passed to above function.
malayamanas

malayamanas

2012-07-31 11:44

reporter   ~0000730

SOLVED by doing below change in wwwroot/inc/function.php


function ip4_int2bin ($ip_int)
{
        return pack ('N', (double)$ip_int);
}

Added a double type casting. int casting is out of range.
Please check for IPv6. May be 64 bit OS required.
andriyanov

andriyanov

2012-07-31 11:50

reporter   ~0000731

I've made a fix: https://github.com/RackTables/racktables/commit/5a8bd9a372ca6a371f718c5eb369aef487335e70

Hope it will work for you, please check it out (we've moved project from SVN to git)
malayamanas

malayamanas

2012-07-31 12:34

reporter   ~0000732

Fixed

Issue History

Date Modified Username Field Change
2012-07-18 09:12 malayamanas New Issue
2012-07-18 09:16 malayamanas Note Added: 0000708
2012-07-18 21:38 infrastation Assigned To => andriyanov
2012-07-18 21:38 infrastation Status new => assigned
2012-07-26 09:01 malayamanas Note Added: 0000715
2012-07-26 09:11 andriyanov Note Added: 0000716
2012-07-30 13:47 malayamanas Note Added: 0000718
2012-07-30 14:13 malayamanas Note Added: 0000719
2012-07-30 14:18 malayamanas File Added: live-http-header.PNG
2012-07-30 14:19 malayamanas Note Added: 0000720
2012-07-30 21:54 andriyanov File Added: test.php
2012-07-30 21:55 andriyanov Note Added: 0000722
2012-07-31 05:18 adoom42 Summary It is on latest 0.20.0 version. from SVN trunk => New IPv4 address space is 127.0.0.0 instead of submitted value
2012-07-31 07:13 malayamanas Note Added: 0000725
2012-07-31 10:08 andriyanov Note Added: 0000726
2012-07-31 10:17 malayamanas Note Added: 0000727
2012-07-31 10:22 malayamanas Note Added: 0000728
2012-07-31 11:02 malayamanas Note Added: 0000729
2012-07-31 11:44 malayamanas Note Added: 0000730
2012-07-31 11:50 andriyanov Note Added: 0000731
2012-07-31 12:34 malayamanas Note Added: 0000732
2012-07-31 12:34 malayamanas Status assigned => closed
2012-07-31 12:34 malayamanas Resolution open => fixed
2012-07-31 16:57 adoom42 Fixed in Version => 0.19.14
2012-07-31 16:57 adoom42 Target Version => 0.19.14
2012-07-31 17:22 andriyanov Product Version 0.19.13 => development repository checkout
2012-07-31 17:22 andriyanov Fixed in Version 0.19.14 => development repository checkout
2012-07-31 17:22 andriyanov Target Version 0.19.14 => development repository checkout
2012-07-31 20:53 andriyanov Product Version development repository checkout => 0.20.0
2012-07-31 20:53 andriyanov Fixed in Version development repository checkout => 0.20.0
2012-07-31 20:53 andriyanov Target Version development repository checkout => 0.20.0