[pve-devel] [PATCH v3 container] fix #1885: delete old route when changing gateway
David Limbeck
d.limbeck at proxmox.com
Tue Sep 4 09:24:29 CEST 2018
if the gateway is not in the subnet of the ip a route is
added. this change enables the deletion of the old route when it
is no longer needed.
Signed-off-by: David Limbeck <d.limbeck at proxmox.com>
---
changes since v2:
- added $oldip check
- changed comment
- changed commit message
src/PVE/LXC.pm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 1504bd0..0b57ae9 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -791,9 +791,10 @@ sub update_ipconfig {
my $newip = $newnet->{$ip};
my $newgw = $newnet->{$gw};
my $oldip = $optdata->{$ip};
+ my $oldgw = $optdata->{$gw};
my $change_ip = &$safe_string_ne($oldip, $newip);
- my $change_gw = &$safe_string_ne($optdata->{$gw}, $newgw);
+ my $change_gw = &$safe_string_ne($oldgw, $newgw);
return if !$change_ip && !$change_gw;
@@ -836,6 +837,11 @@ sub update_ipconfig {
# warn and continue
warn $@ if $@;
}
+ if ($oldgw && $oldip && !PVE::Network::is_ip_in_cidr($oldgw, $oldip)) {
+ eval { &$ipcmd($family_opt, 'route', 'del', $oldgw, 'dev', $eth); };
+ # warn if the route was deleted manually
+ warn $@ if $@;
+ }
}
# from this point on we save the configuration
--
2.11.0
More information about the pve-devel
mailing list