]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Network.pm
Consider /31 and /32 valid subnet masks.
[pve-common.git] / src / PVE / Network.pm
index bda20677f33a00012bc269d8ca4880c7c9a5f1b8..ab073505710150a5a24bea052e52070117fe99a6 100644 (file)
@@ -71,15 +71,18 @@ our $ipv4_mask_hash_localnet = {
     '255.255.255.240' => 28,
     '255.255.255.248' => 29,
     '255.255.255.252' => 30,
+    '255.255.255.254' => 31,
+    '255.255.255.255' => 32,
 };
 
 sub setup_tc_rate_limit {
     my ($iface, $rate, $burst, $debug) = @_;
 
-    system("/sbin/tc class del dev $iface parent 1: classid 1:1 >/dev/null 2>&1");
-    system("/sbin/tc filter del dev $iface parent ffff: protocol all pref 50 u32 >/dev/null 2>&1");
-    system("/sbin/tc qdisc del dev $iface ingress >/dev/null 2>&1");
-    system("/sbin/tc qdisc del dev $iface root >/dev/null 2>&1");
+    # these are allowed / expected to fail, e.g. when there is no previous rate limit to remove
+    eval { run_command("/sbin/tc class del dev $iface parent 1: classid 1:1 >/dev/null 2>&1"); };
+    eval { run_command("/sbin/tc filter del dev $iface parent ffff: protocol all pref 50 u32 >/dev/null 2>&1"); };
+    eval { run_command("/sbin/tc qdisc del dev $iface ingress >/dev/null 2>&1"); };
+    eval { run_command("/sbin/tc qdisc del dev $iface root >/dev/null 2>&1"); };
 
     return if !$rate;
 
@@ -178,6 +181,8 @@ my $bridge_add_interface = sub {
        if ($tag) {
            system("/sbin/bridge vlan add dev $iface vid $tag pvid untagged") == 0 ||
            die "unable to add vlan $tag to interface $iface\n";
+
+           warn "Caution: Setting VLAN ID 1 on a VLAN aware bridge may be dangerous\n" if $tag == 1;
        } else {
            system("/sbin/bridge vlan add dev $iface vid 2-4094") == 0 ||
            die "unable to add default vlan tags to interface $iface\n" if !$trunks;
@@ -439,7 +444,7 @@ sub activate_bridge_vlan {
 
     my @ifaces = ();
     my $dir = "/sys/class/net/$bridge/brif";
-    PVE::Tools::dir_glob_foreach($dir, '((eth|bond)\d+(\.\d+)?)', sub {
+    PVE::Tools::dir_glob_foreach($dir, '(((eth|bond)\d+|en[^.]+)(\.\d+)?)', sub {
         push @ifaces, $_[0];
     });