]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/INotify.pm
inotify: fix compatibillity with address + netmask separate passed
[pve-common.git] / src / PVE / INotify.pm
index 86d5459852234ebe3a61728cdbb19f8d8db769ee..d170cc14163c737ee0c7d90bb64e662272dbbbb8 100644 (file)
@@ -1171,7 +1171,20 @@ sub __interface_to_string {
     my $raw = '';
 
     $raw .= "iface $iface $family " . $d->{"method$suffix"} . "\n";
-    $raw .= "\taddress " . $d->{"address$suffix"} . "\n" if $d->{"address$suffix"};
+
+    if (my $addr = $d->{"address$suffix"}) {
+
+       if ($addr !~ /\/\d+$/ && $d->{"netmask$suffix"}) {
+           if ($d->{"netmask$suffix"} =~ m/^\d+$/) {
+               $addr .= "/" . $d->{"netmask$suffix"};
+           } elsif (my $mask = PVE::JSONSchema::get_netmask_bits($d->{"netmask$suffix"})) {
+               $addr .= "/" . $mask;
+           }
+       }
+
+       $raw .= "\taddress " . $addr . "\n";
+    }
+
     $raw .= "\tgateway " . $d->{"gateway$suffix"} . "\n" if $d->{"gateway$suffix"};
 
     my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,