Skip Menu |

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

Report information
The Basics
Id: 66778
Status: resolved
Worked: 10 min
Priority: 0/
Queue: NetAddr-IP

People
Owner: Nobody in particular
Requestors: tcaine [...] cpan.org
Cc:
AdminCc:

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



Subject: IPv6 first/last bug
first() and last() don't always do the right thing for IPv6 addresses. $ perl -MNetAddr::IP -le 'print $NetAddr::IP::VERSION' 4.041 $ cat ipv6_first_last.t use strict; use warnings; use Test::More tests => 2; use NetAddr::IP; my $ipv6 = NetAddr::IP->new( '2001::E/127' ); is $ipv6->first, "2001:0:0:0:0:0:0:E/127", "first address is 2001::E"; is $ipv6->last, "2001:0:0:0:0:0:0:F/127", "last address is 2001::F"; exit; $ prove -v ./ipv6_first_last.t ./ipv6_first_last.t .. 1..2 not ok 1 - first address is 2001::E # Failed test 'first address is 2001::E' # at ./ipv6_first_last.t line 11. # got: '2001:0:0:0:0:0:0:F/127' # expected: '2001:0:0:0:0:0:0:E/127' not ok 2 - last address is 2001::F # Failed test 'last address is 2001::F' # at ./ipv6_first_last.t line 12. # got: '2001:0:0:0:0:0:0:E/127' # expected: '2001:0:0:0:0:0:0:F/127' # Looks like you failed 2 tests of 2. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/2 subtests Test Summary Report ------------------- ./ipv6_first_last.t (Wstat: 512 Tests: 2 Failed: 2) Failed tests: 1-2 Non-zero exit status: 2 Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.03 cusr 0.00 csys = 0.05 CPU) Result: FAIL
Actually looks like this affects IPv4 as well. So the bug affects /31's for IPv4 and /127's for IPv6.
/31 and /127 are not valid networks. When you exclude the NETWORK and BROADCAST addresses there is no address space left for use so there can be no first or last addresses. Example: for the network 2001::C/126, the first and last addresses are 2001:0:0:0:0:0:0:D/126 2001:0:0:0:0:0:0:E/126 respectively, not ...C/126 and ...F/126
CC: tcaine [...] cpan.org
Subject: Re: [rt.cpan.org #66778] IPv6 first/last bug
Date: Tue, 22 Mar 2011 10:29:46 -0700
To: bug-NetAddr-IP [...] rt.cpan.org
From: Todd Caine <todd.caine [...] gmail.com>
Actually they are valid networks. Many point-to-point connections between routers using /31's and /127's. As a matter of fact, google only uses /31's for their point to point connections. Here's a few documents that talk about /31's and /127's if it helps. http://www.faqs.org/rfcs/rfc3021.html http://www.cisco.com/en/US/docs/ios/12_2t/12_2t2/feature/guide/ft31addr.html http://tools.ietf.org/search/draft-kohno-ipv6-prefixlen-p2p-01 -T On Tue, Mar 22, 2011 at 10:11 AM, Michael Robinton via RT <bug-NetAddr-IP@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66778 > > > /31 and /127 are not valid networks. When you exclude the NETWORK and > BROADCAST addresses there is no address space left for use so there can > be no first or last addresses. > > Example: > > for the network 2001::C/126, the first and last addresses are > > 2001:0:0:0:0:0:0:D/126 > 2001:0:0:0:0:0:0:E/126 > > respectively, not ...C/126 and ...F/126 > >
4.042 Tue Mar 22 15:26:02 PDT 2011 Update Lite.pm v1.27 to encompass treatment of /31 and /127 point-to-point networks as described in RFC 3021 NOTE: for /31's and /127's this changes the behavior of the following methods: first returns the "network" address last returns the "broadcast" address nth index 0 returns "network" addr instead of undef nth index 1 returns "broadcast" addr instead of undef num returns 2 instead of 0 (zero) "old_nth" behavior is unchanged