diff options
author | Franck Bui <franck.bui@mandriva.com> | 2011-08-31 06:31:23 +0000 |
---|---|---|
committer | Franck Bui <franck.bui@mandriva.com> | 2011-08-31 06:31:23 +0000 |
commit | dce5c8f6f8e90506f7a4d47f279f496e1450b5ad (patch) | |
tree | d6a2f2eb6b3eb0c90b2cbd708d0c8cea8415fde0 | |
parent | 8c261d2f3521fb14a1e3d2465c0391b7029b66c5 (diff) | |
download | drakx-net-dce5c8f6f8e90506f7a4d47f279f496e1450b5ad.tar drakx-net-dce5c8f6f8e90506f7a4d47f279f496e1450b5ad.tar.gz drakx-net-dce5c8f6f8e90506f7a4d47f279f496e1450b5ad.tar.bz2 drakx-net-dce5c8f6f8e90506f7a4d47f279f496e1450b5ad.tar.xz drakx-net-dce5c8f6f8e90506f7a4d47f279f496e1450b5ad.zip |
fix get_routes() which depends on order of entry in /proc/net/route
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | lib/network/tools.pm | 11 |
2 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,5 @@ +- Make get_routes() more robust when parsing /proc/net/route + 0.93: - Make draknetcenter.desktop XDG compliant - Move autostart desktop files to /etc/xdg/autostart diff --git a/lib/network/tools.pm b/lib/network/tools.pm index 0a1d840..9636450 100644 --- a/lib/network/tools.pm +++ b/lib/network/tools.pm @@ -265,7 +265,16 @@ sub get_routes() { my %routes; foreach (cat_("/proc/net/route")) { if (/^(\S+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+[0-9A-F]+\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { - if (defined $3) { $routes{$1}{gateway} = hex($3) ? host_hex_to_dotted($3) : $routes{$1}{network} } + next if (defined $routes{$1}{has_gateway}); + + if (defined $3) { + if (hex($3)) { + $routes{$1}{gateway} = host_hex_to_dotted($3); + $routes{$1}{has_gateway} = "yes"; + } else { + $routes{$1}{gateway} = $routes{$1}{network}; + } + } if (defined $2) { $routes{$1}{network} = host_hex_to_dotted($2) } if (defined $4) { $routes{$1}{metric} = $4 } } |