]> git.proxmox.com Git - pve-common.git/commitdiff
add ProcFSTools::read_proc_net_ipv6_route
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 6 Jul 2015 08:03:38 +0000 (10:03 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 23 Jul 2015 04:43:52 +0000 (06:43 +0200)
src/PVE/ProcFSTools.pm

index 8bb0d729b50b8ab974cdbc5d3b2ac57d5fe24e70..2d3123bbbce07c33fa03c3f0c4d5f0f50acfba3c 100644 (file)
@@ -284,4 +284,29 @@ sub read_proc_net_route {
     return $res;
 }
 
+sub read_proc_net_ipv6_route {
+    my $filename = "/proc/net/ipv6_route";
+
+    my $res = [];
+
+    my $fh = IO::File->new ($filename, "r");
+    return $res if !$fh;
+
+    my $read_v6addr = sub { s/....(?!$)/$&:/g };
+
+    # ipv6_route has no header
+    while (defined(my $line = <$fh>)) {
+       my ($dest, $prefix, $nexthop, $metric, $iface) = (split(/\s+/, $line))[0,1,4,5,9];
+       push @$res, {
+           dest => &$read_v6addr($dest),
+           prefix => $prefix,
+           gateway => &$read_v6addr($nexthop),
+           metric => $metric,
+           iface => $iface
+       };
+    }
+
+    return $res;
+}
+
 1;