[rancid] [PATCH]
Alan McKinnon
alan.mckinnon at gmail.com
Fri Jun 6 23:30:37 UTC 2014
I may have posted this one already. If so, apologies for the dupe.
ACL sorting fails for ipv6 addresses as ipaddrval() always returns false
for these so sorting never happens. Rancid output is then always
whatever order the router presented leading to chatter and noisy diffs.
The simplest solution is to sort ipv6 addresses ASCIIbetically so they
always sort predictably. The only oddity is :: comes after digits 0-9
and before A-F. Aside from that, the order is as expected by hex numbers.
This is much easier than writing an ipv6 sort routine from scratch as
rancid uses no perl user modules.
--- rancid.old 2014-05-16 01:07:20.000000000 +0200
+++ rancid 2014-06-04 01:47:20.000000000 +0200
@@ -168,7 +186,8 @@
$a[3] + 256 * ($a[2] + 256 * ($a[1] +256 * $a[0]));
}
sub sortbyipaddr {
- &ipaddrval($a) <=> &ipaddrval($b);
+ &ipaddrval($a) <=> &ipaddrval($b) ||
+ $a cmp $b;
}
# This routine parses "show version"
@@ -1874,7 +1898,7 @@
# order arp lists
/^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
ProcessHistory("ARP","$aclsort","$1","$_") && next;
- /^ip(v6)?
prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(\/.*)$/
+ /^ip(v4|v6)?
prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(\/.*)$/
&& ProcessHistory("PACL $2 $4","$aclsort","$5",
"ip$1 prefix-list $2 $4 $5$6\n")
&& next;
--
Alan McKinnon
alan.mckinnon at gmail.com
More information about the Rancid-discuss
mailing list