summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-21 12:39:02 +0100
committerGitHub <noreply@github.com>2023-12-21 12:39:02 +0100
commit5c91424daafbee512f7c87caa418cd05f0bc4633 (patch)
tree5ed84cf65e4d50c9f1f91ede9100a71dd9b371aa
parent61ebb10f70101931c7e60f5ccf9874091fc8b324 (diff)
parent41fdbae4e5bbfaf9f7539b93a78a851981037cd8 (diff)
downloadvyos-1x-5c91424daafbee512f7c87caa418cd05f0bc4633.tar.gz
vyos-1x-5c91424daafbee512f7c87caa418cd05f0bc4633.zip
Merge pull request #2672 from vyos/mergify/bp/sagitta/pr-2611
T5804: nat: remove inbound|outbound interface from old configuration when it was set to <any>. (backport #2611)
-rwxr-xr-xsrc/migration-scripts/nat/6-to-78
1 files changed, 6 insertions, 2 deletions
diff --git a/src/migration-scripts/nat/6-to-7 b/src/migration-scripts/nat/6-to-7
index b5f6328ef..a2e735394 100755
--- a/src/migration-scripts/nat/6-to-7
+++ b/src/migration-scripts/nat/6-to-7
@@ -21,6 +21,7 @@
# to
# 'set nat [source|destination] rule X [inbound-interface|outbound interface] name <iface>'
# 'set nat [source|destination] rule X [inbound-interface|outbound interface] group <iface_group>'
+# Also remove command if interface == any
from sys import argv,exit
from vyos.configtree import ConfigTree
@@ -56,8 +57,11 @@ for direction in ['source', 'destination']:
if config.exists(base + [iface]):
if config.exists(base + [iface, 'interface-name']):
tmp = config.return_value(base + [iface, 'interface-name'])
- config.delete(base + [iface, 'interface-name'])
- config.set(base + [iface, 'name'], value=tmp)
+ if tmp != 'any':
+ config.delete(base + [iface, 'interface-name'])
+ config.set(base + [iface, 'name'], value=tmp)
+ else:
+ config.delete(base + [iface])
try:
with open(file_name, 'w') as f: