Skip Menu |

This queue is for tickets about the Net-CIDR CPAN distribution.

Report information
The Basics
Id: 111939
Status: rejected
Priority: 0/
Queue: Net-CIDR

People
Owner: Nobody in particular
Requestors: quanah.gibsonmount [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 0.17
  • 0.18
Fixed in: (no value)



Subject: Net::CIDR fails on valid IPv6 addr/mask combination
ifconfig -a inet6 addr: fc00:10:137:242::53/64 Scope:Global Yet if I plug this in to net::cidr, we get: Invalid netmask at /opt/zimbra/common/lib/perl5/Net/CIDR.pm line 546, <$fh> line 9. Specifically: IP: fc00:10:137:242::53 Mask: 64 Invalid netmask at /opt/zimbra/common/lib/perl5/Net/CIDR.pm line 546, <$fh> line 9. Code is: print "IP: $ip\n"; print "Mask: $mask\n"; my $cidr = Net::CIDR::addrandmask2cidr($ip, $mask); print "CIDR: $cidr\n";
"fc00:10:137:242::53" is an IP6 address assigned to this interface. It is not a CIDR. It is not a network route. The output format from ifconfig is misleading. The "inet6" value reported by ifconfig is an interface's IP6 address, and not a network route via this interface. If it were actually /64 route, the correct CIDR would be "fc00:10:137:242::/64" instead of "fc00:10:137:242::53/64", so Net::CIDR is correct. Looks like net-tools 2.0 has changed the output format ifconfig, to stop confusing people from thinking that it's a CIDR of some kind. $ ifconfig -a | grep inet6 inet6 fe80::230:48ff:fefc:83fa prefixlen 64 scopeid 0x20<link> inet6 ::1 prefixlen 128 scopeid 0x10<host> inet6 fe80::230:48ff:fefc:83fa prefixlen 64 scopeid 0x20<link>
On Wed Feb 10 17:44:52 2016, MRSAM wrote: Show quoted text
> "fc00:10:137:242::53" is an IP6 address assigned to this interface. It > is not a CIDR
Of course it's not a CIDR. Why would I give a CIDR to a function that takes an IP address and a mask? Did you bother to read the code snippet I provided before responding? According to the documentation: $cidr=Net::CIDR::addrandmask2cidr($address, $netmask); The addrandmask2cidr function takes an IP address and a netmask, and returns the CIDR range whose size fits the netmask and which contains the address.
A slight misunderstanding here. The second parameter to addrandmask2cidr() is, indeed a mask. But not a prefix, as you interpreted it. The same documentation you are refered to gives an example that makes it clear, in the SYNOPSIS section: print Net::CIDR::addrandmask2cidr("195.149.50.61", "255.255.255.248")."\n"; In your case: Net::CIDR::addrandmask2cidr( "fc00:10:137:242::53", "ffff:ffff:ffff:ffff::") Will return the expected results: "fc00:10:137:242::/64".
On Wed Feb 10 21:08:53 2016, MRSAM wrote: Show quoted text
> A slight misunderstanding here. > > The second parameter to addrandmask2cidr() is, indeed a mask. But not > a prefix, as you interpreted it. > > The same documentation you are refered to gives an example that makes > it clear, in the SYNOPSIS section: > > print Net::CIDR::addrandmask2cidr("195.149.50.61", > "255.255.255.248")."\n"; > > In your case: > > Net::CIDR::addrandmask2cidr( > "fc00:10:137:242::53", > "ffff:ffff:ffff:ffff::") > > Will return the expected results: "fc00:10:137:242::/64".
Ok thanks. I ended up using NetAddr::IP instead, since I was already using it, and it can generate the information from either form of netmask.