]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Network.pm
network: tap_rate_limit: fix uninitialized value
[pve-common.git] / src / PVE / Network.pm
index dd365051f4e8d17be4823520b09fe1201f36969e..5d265299c5998683a3179c2139841e8f2d68d96e 100644 (file)
@@ -11,11 +11,11 @@ use POSIX qw(ECONNREFUSED);
 
 use Net::IP;
 
-require "sys/ioctl.ph";
 use Socket qw(IPPROTO_IP);
 
 use constant IFF_UP => 1;
 use constant IFNAMSIZ => 16;
+use constant SIOCGIFFLAGS => 0x8913;
 
 # host network related utility functions
 
@@ -108,7 +108,7 @@ sub tap_rate_limit {
     my ($iface, $rate) = @_;
 
     my $debug = 0;
-    $rate = int($rate*1024*1024);
+    $rate = int($rate*1024*1024) if $rate;
     my $burst = 1024*1024;
 
     setup_tc_rate_limit($iface, $rate, $burst, $debug);
@@ -538,7 +538,7 @@ sub get_active_interfaces {
        next if $line !~ /^\s*([^:\s]+):/;
        my $ifname = $1;
        my $ifreq = pack($STRUCT_IFREQ_SIOCGIFFLAGS, $1, 0);
-       if (!defined(ioctl($sock, &SIOCGIFFLAGS, $ifreq))) {
+       if (!defined(ioctl($sock, SIOCGIFFLAGS, $ifreq))) {
            warn "failed to get interface flags for: $ifname\n";
            next;
        }