Wrong masklen in result of netmask()/hostmask() - Mailing list pgsql-hackers

From Tom Lane
Subject Wrong masklen in result of netmask()/hostmask()
Date
Msg-id 14966.1070251615@sss.pgh.pa.us
Whole thread Raw
Responses Re: Wrong masklen in result of netmask()/hostmask()
List pgsql-hackers
Per this gripe:
http://archives.postgresql.org/pgsql-bugs/2003-11/msg00233.php
I think that the recent IPv6 changes made an undocumented and
un-agreed-to change in the semantics of netmask().

The previous behavior of netmask() was that it always delivered
a result with a masklen of 32.  It seems to me that the obvious
extension of that for IPv6 is to deliver masklen of either 32
or 128 depending on whether the input is IPv4 or IPv6.  The
actual behavior in 7.4 is that the masklen is the same as the
input value's, for example:

7.3:
regression=# select masklen(netmask('192.168.1.0/23'));masklen
---------     32
(1 row)

7.4:
regression=# select masklen(netmask('192.168.1.0/23'));masklen
---------     23
(1 row)

The previous behavior had been agreed to at one point:
http://archives.postgresql.org/pgsql-hackers/2000-10/msg01132.php
I can't find anyplace in the archives where the change was discussed
at all.

hostmask() was not in 7.3 so its behavior is a bit up for grabs,
but I think it ought to return the same masklen as netmask().

Comments?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: [GENERAL] Was: Triggers, Stored Procedures, PHP
Next
From: Bruce Momjian
Date:
Subject: Re: Wrong masklen in result of netmask()/hostmask()