Skip Menu |

This queue is for tickets about the NetAddr-IP CPAN distribution.

Report information
The Basics
Id: 41008
Status: resolved
Worked: 36.2 hours (2175 min)
Priority: 0/
Queue: NetAddr-IP

People
Owner: michael [...] bizsystems.com
Requestors: kashmish [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: split not working for v6 addresses
Date: Mon, 17 Nov 2008 20:12:14 -0500
To: bug-NetAddr-IP [...] rt.cpan.org
From: kashmish <kashmish [...] gmail.com>
tested 4.007, 4.012 and 4.015 (used to work in the past with some older version) on FreeBSD 6.3-RELEASE #0 with: perl, v5.8.8 built for amd64-freebsd-thread-multi still works fine for v4 addresses... thx -k
On Mon Nov 17 20:12:43 2008, kashmish@gmail.com wrote: Show quoted text
> > tested 4.007, 4.012 and 4.015 (used to work in the past with some older > version) > on FreeBSD 6.3-RELEASE #0 > with: > perl, v5.8.8 built for amd64-freebsd-thread-multi > > still works fine for v4 addresses... > > thx > -k >
Can you provide an example. I don't believe any of that code has been updated recently. Should work as before. Michael
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses
Date: Tue, 18 Nov 2008 19:55:57 -0500
To: bug-NetAddr-IP [...] rt.cpan.org
From: kashmish <kashmish [...] gmail.com>
thx for the quick response! script example (~/script.pl): =================================== #!/usr/bin/perl -w use strict; use NetAddr::IP; my $ip = new NetAddr::IP $ARGV[0]; my $mask = $ip->masklen(); my $newmask = $mask + 1; my @CURRENTHALFS = $ip->split($newmask); print "first half: $CURRENTHALFS[0]\n"; print "second half: $CURRENTHALFS[1]\n"; =================================== v4 usage looks as: $ ~/splitter.pl 10.10.10.0/24 first half: 10.10.10.0/25 second half: 10.10.10.128/25 but with a v6 cidr we get: $ ~/splitter.pl dead::beef/48 Use of uninitialized value in array dereference at blib/lib/NetAddr/IP.pm (autosplit into blib/lib/auto/NetAddr/IP/split.al) line 717. Use of uninitialized value in concatenation (.) or string at /home/kince/splitter.pl line 8. first half: Use of uninitialized value in concatenation (.) or string at /home/kince/splitter.pl line 9. second half: not sure what version we were using in the past, it's been a few years ;-)... cheers and thx again! -k
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses - corrected, ignore previous..
Date: Tue, 18 Nov 2008 19:58:38 -0500
To: bug-NetAddr-IP [...] rt.cpan.org
From: kashmish <kashmish [...] gmail.com>
thx for the quick response! script example (~/splitter.pl): =================================== #!/usr/bin/perl -w use strict; use NetAddr::IP; my $ip = new NetAddr::IP $ARGV[0]; my $mask = $ip->masklen(); my $newmask = $mask + 1; my @CURRENTHALFS = $ip->split($newmask); print "first half: $CURRENTHALFS[0]\n"; print "second half: $CURRENTHALFS[1]\n"; =================================== v4 usage looks as: $ ~/splitter.pl 10.10.10.0/24 first half: 10.10.10.0/25 second half: 10.10.10.128/25 but with a v6 cidr we get: $ ~/splitter.pl dead::beef/48 Use of uninitialized value in array dereference at blib/lib/NetAddr/IP.pm (autosplit into blib/lib/auto/NetAddr/IP/split.al) line 717. Use of uninitialized value in concatenation (.) or string at /home/kince/splitter.pl line 8. first half: Use of uninitialized value in concatenation (.) or string at /home/kince/splitter.pl line 9. second half: not sure what version we were using in the past, it's been a few years ;-)... cheers and thx again! -k
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses - corrected, ignore previous..
Date: Tue, 18 Nov 2008 18:45:25 -0800
To: bug-NetAddr-IP [...] rt.cpan.org
From: michael [...] insulin-pumpers.org
Show quoted text
> Queue: NetAddr-IP > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > > thx for the quick response!
This behavior is a feature. If a hugh number of nets are allowed, the array would consume all of memory. From the docs, by design. Note the last line. ""->split($bits)"" Returns a list of objects, representing subnets of "$bits" mask produced by splitting the original object, which is left unchanged. Note that "$bits" must be longer than the original mask in order for it to be splittable. Note that "$bits" can be given as an integer (the length of the mask) or as a dotted-quad. If omitted, a host mask is assumed. ""->splitref($bits)"" A (faster) version of "->split()" that returns a ref- erence to a list of objects instead of a real list. This is useful when large numbers of objects are expected. Return undef if the number of subnets > 2 ** 32 Show quoted text
> > script example (~/splitter.pl): > =================================== > #!/usr/bin/perl -w > use strict; > use NetAddr::IP; > my $ip = new NetAddr::IP $ARGV[0]; > my $mask = $ip->masklen(); > my $newmask = $mask + 1; > my @CURRENTHALFS = $ip->split($newmask); > print "first half: $CURRENTHALFS[0]\n"; > print "second half: $CURRENTHALFS[1]\n"; > =================================== > > v4 usage looks as: > $ ~/splitter.pl 10.10.10.0/24 > first half: 10.10.10.0/25 > second half: 10.10.10.128/25 > > but with a v6 cidr we get: > $ ~/splitter.pl dead::beef/48 > Use of uninitialized value in array dereference at > blib/lib/NetAddr/IP.pm (autosplit into > blib/lib/auto/NetAddr/IP/split.al) line 717. > Use of uninitialized value in concatenation (.) or string at > /home/kince/splitter.pl line 8. > first half: > Use of uninitialized value in concatenation (.) or string at > /home/kince/splitter.pl line 9. > second half: > > not sure what version we were using in the past, it's been a few years > ;-)... cheers and thx again! -k > >
Behavior is consistent with the docs. splits beyond 2**32 are not allowed due to real world constraints on the processor, etc...
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses
Date: Tue, 18 Nov 2008 23:42:19 -0500
To: bug-NetAddr-IP [...] rt.cpan.org
From: kashmish <kashmish [...] gmail.com>
not sure if i understand, you are saying no masks longer then /32 are allowed? Michael Robinton via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > Behavior is consistent with the docs. splits beyond 2**32 are not > allowed due to real world constraints on the processor, etc... > >
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses
Date: Tue, 18 Nov 2008 21:58:20 -0800
To: bug-NetAddr-IP [...] rt.cpan.org
From: michael [...] insulin-pumpers.org
Show quoted text
> Queue: NetAddr-IP > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > not sure if i understand, > you are saying no masks longer then /32 are allowed? >
No, nets containing IP's of more than 2 **32 are not allowed because it would be too large an array to process and return. I see the dilemma here. I will take a look at the implementation and see if it warrants a change. Perhaps what we need to do is restrict the return size of the array instead of the number of nets. Michael Show quoted text
> > Michael Robinton via RT wrote:
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > > > Behavior is consistent with the docs. splits beyond 2**32 are not > > allowed due to real world constraints on the processor, etc... > > > >
>
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses
Date: Thu, 20 Nov 2008 22:41:56 -0500
To: bug-NetAddr-IP [...] rt.cpan.org
From: kashmish <kashmish [...] gmail.com>
michael, that sounds good! thx for looking into it. one further thought fudder: rather then splitting a cidr into same sized subnets, i personally prefer them as an aggregated list. e.g.: x/48 id given, but i need a /50 out of. instead of splitting the /48 into 8 x /50, i usually need that highest possible aggregates as: 2 x /50 + 1 x /49 so, the returning number of items is only 3 lines instead of 8, similar if youd split a /32 into /128's, instead of manymanymany 128's, (memory probs etc.) i would rather need get 'only' 96 (or 97?) lines back... much easier to handle! so, i wrote a little tool like: -------------- use NetAddr::IP; my $ip = new NetAddr::IP $ARGV[0]; my $ipver = $ip->version(); my $supermask=$ip->masklen(); my $mask=$ARGV[1]; my $oursuper=$ip; for ($i = $supermask + 1; $i <= $mask; $i++) { my $calcip = new NetAddr::IP $oursuper; my @CURRENTHALFS; if ($ipver == 4) { @CURRENTHALFS = $calcip->split($i); print "$CURRENTHALFS[1]\n"; $oursuper=$CURRENTHALFS[0]; } else { my $v6halfstr = `ipv6gen $calcip $i`; @CURRENTHALFS = split("\n", "$v6halfstr"); print "$CURRENTHALFS[1]\n"; $oursuper=$CURRENTHALFS[0]; } } print "$oursuper\n"; -------------------------------------- maybe an easy to implement feature to integrate? eg as: splitaggr(l) or splitaggr(b) with l=little endian and b=bigendian, so the destination split might be at the beginning or the end of the superblock? makes sense? you care? cheers anyways ;-) -k michael@insulin-pumpers.org via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > >
>> Queue: NetAddr-IP >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > >> >> not sure if i understand, >> you are saying no masks longer then /32 are allowed? >> >>
> > No, nets containing IP's of more than 2 **32 are not allowed because > it would be too large an array to process and return. > > I see the dilemma here. I will take a look at the implementation and > see if it warrants a change. Perhaps what we need to do is restrict > the return size of the array instead of the number of nets. > > Michael > >
>> Michael Robinton via RT wrote: >>
>>> <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > >>> >>> Behavior is consistent with the docs. splits beyond 2**32 are not >>> allowed due to real world constraints on the processor, etc... >>> >>> >>>
> > > > >
Subject: Re: [rt.cpan.org #41008] split not working for v6 addresses
Date: Thu, 20 Nov 2008 22:04:19 -0800 (PST)
To: kashmish via RT <bug-NetAddr-IP [...] rt.cpan.org>
From: Michael Robinton <michael [...] insulin-pumpers.org>
On Thu, 20 Nov 2008, kashmish via RT wrote: Show quoted text
> Queue: NetAddr-IP > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > michael, > that sounds good! thx for looking into it. > > one further thought fudder: > > rather then splitting a cidr into same sized subnets, > i personally prefer them as an aggregated list. > e.g.: > x/48 id given, but i need a /50 out of. > instead of splitting the /48 into 8 x /50, > i usually need that highest possible aggregates as: > 2 x /50 + > 1 x /49 > so, the returning number of items is only 3 lines instead of 8, > similar if youd split a /32 into /128's, > instead of manymanymany 128's, (memory probs etc.) > i would rather need get 'only' 96 (or 97?) lines back... > much easier to handle! >
hmmm.... how about something like this where the current split($bits) is extended With a single argument, split works as stated. An extend version could work like this where the "split" would do the arguments as encountered and replicate the last argument. i.e. where $ip = someipV6/48 $ip->split(50,50,49) split would return two 50's and the balance in /49's further, negating any argument to split would cause it to work from the top down instead of the bottom up. i.e it would return a bunch of 49's and two 50's. Similarly, mask IP's could be used but the "reversal" feature would not be available in this context. That might be a reasonable extension. I don't have any idea at the moment what kind of coding would be required to extend this feature. Am pretty busy now but will look into it maybe later. Michael Show quoted text
> so, i wrote a little tool like: > -------------- > use NetAddr::IP; > my $ip = new NetAddr::IP $ARGV[0]; > my $ipver = $ip->version(); > my $supermask=$ip->masklen(); > my $mask=$ARGV[1]; > my $oursuper=$ip; > for ($i = $supermask + 1; $i <= $mask; $i++) { > my $calcip = new NetAddr::IP $oursuper; > my @CURRENTHALFS; > if ($ipver == 4) { > @CURRENTHALFS = $calcip->split($i); > print "$CURRENTHALFS[1]\n"; > $oursuper=$CURRENTHALFS[0]; > } else { > my $v6halfstr = `ipv6gen $calcip $i`; > @CURRENTHALFS = split("\n", "$v6halfstr"); > print "$CURRENTHALFS[1]\n"; > $oursuper=$CURRENTHALFS[0]; > } > } > print "$oursuper\n"; > -------------------------------------- > maybe an easy to implement feature to integrate? > eg as: > splitaggr(l) > or > splitaggr(b) > > with l=little endian and b=bigendian, > so the destination split might be at the beginning or the end of the > superblock? > > makes sense? > you care? > > cheers anyways > ;-) > -k > > > > michael@insulin-pumpers.org via RT wrote:
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > > > >
> >> Queue: NetAddr-IP > >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > >> > >> not sure if i understand, > >> you are saying no masks longer then /32 are allowed? > >> > >>
> > > > No, nets containing IP's of more than 2 **32 are not allowed because > > it would be too large an array to process and return. > > > > I see the dilemma here. I will take a look at the implementation and > > see if it warrants a change. Perhaps what we need to do is restrict > > the return size of the array instead of the number of nets. > > > > Michael > > > >
> >> Michael Robinton via RT wrote: > >>
> >>> <URL: http://rt.cpan.org/Ticket/Display.html?id=41008 > > >>> > >>> Behavior is consistent with the docs. splits beyond 2**32 are not > >>> allowed due to real world constraints on the processor, etc... > >>> > >>> > >>>
> > > > > > > > > >
> >
Extended the capability of 'splitref' to allow splitting of objects into multiple pieces with differing CIDR masks. Returned object list can be split from bottom to top or from top to bottom depending on which method is called split, rsplit, splitref, rsplitref Splits are restricted by default to 2**16 but may be changed with the "netlimit" function call