[c-nsp] prefix-list rearranging itself

Nick Hilliard nick at foobar.org
Sun Jun 7 06:01:50 EDT 2015

On 07/06/2015 01:36, Charles Sprickman wrote:
> On pretty much every rancid run, a chunk of the config (bgp prefix lists) rearranges itself, only in the IPv6 section:

this is a rancid bug caused by a change in behaviour in how perl >= 5.18
handles hashes.  You can find more details about the underlying issue if
you google for "perl hash order randomization".

The bug is fixed in rancid 3.2.  Alternatively, see the attached for a
replacement for the two relevant functions.


-------------- next part --------------
sub ipaddrval {
    use Socket qw(AF_INET AF_INET6 inet_pton);
    my (@a) = @_;
    my $norder;
    $norder = inet_pton(AF_INET, $_[0]);	# ipv4?
    if (!defined($norder)) {
        $norder = inet_pton(AF_INET6, $_[0]);	# ipv6?
    if (defined($norder)) {
        return unpack("H*", $norder);
    # otherwise return original key value so that perl will
    # not sort on null index
    return ($_[0]);

sub sortbyipaddr {
    &ipaddrvalnew($a) cmp &ipaddrvalnew($b);

More information about the cisco-nsp mailing list