mirror of
https://git.proxmox.com/git/pve-common
synced 2025-04-28 15:57:11 +00:00
inotify: fix compatibillity with address + netmask separate passed
fixes commit 78c6656c9aba1d57786f916717c2622a3059fb6 which dropped writing out the netmask but missed to add compat code for the case where the caller did not suplly a address in CIDR format already. Check if an address ends with /\d+, if not see if a netmask is available and add that similar how it gets handled on read. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com> Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
parent
040fc87d59
commit
f6c9d9a4f3
@ -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,
|
||||
|
@ -503,7 +503,7 @@ iface eth0 inet manual
|
||||
|
||||
auto eth1
|
||||
iface eth1 inet6 static
|
||||
address $ip
|
||||
address $ip/$nm
|
||||
gateway $gw
|
||||
|
||||
iface eth2 inet manual
|
||||
|
Loading…
Reference in New Issue
Block a user