[pve-devel] [PATCH common] net: don't die in get_active_interfaces() and try both address families
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Mar 10 15:28:34 CET 2016
---
If this fails we still want to be able to show the network interfaces
on the GUI, so return [] instead of die()-ing.
Also, note that while either address family seems to work even with
net.ipv6.conf.all.disable_ipv6=1 a reported error on the forum
indicates that the socket might not open under some circumstances
(perhaps a custom kernel with ipv6 not compiled in?), so just try the
other packet family, too, if opening the socket fails.
src/PVE/Network.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index 56af2ed..78529e1 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -532,8 +532,10 @@ sub get_active_interfaces {
open my $fh, '<', '/proc/net/dev'
or die "failed to open /proc/net/dev: $!\n";
# And filter by IFF_UP flag fetched via a PF_INET6 socket ioctl:
- socket my $sock, PF_INET6, SOCK_DGRAM, &IPPROTO_IP
- or die "failed to open socket\n";
+ my $sock;
+ socket($sock, PF_INET6, SOCK_DGRAM, &IPPROTO_IP)
+ or socket($sock, PF_INET, SOCK_DGRAM, &IPPROTO_IP)
+ or return [];
my $ifaces = [];
while(defined(my $line = <$fh>)) {
--
2.1.4
More information about the pve-devel
mailing list