Skip to content

Commit

Permalink
firewall: T4694: incomplete node checks in migration script
Browse files Browse the repository at this point in the history
This patch on vyos#3616 will only attempt to fix ipsec matches in rules if the
firewall config tree passed to migrate_chain() has rules attached.
  • Loading branch information
talmakion committed Jul 29, 2024
1 parent 7b325c1 commit 3d42009
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/migration-scripts/firewall/16-to-17
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
# (nftables rejects 'meta ipsec' in output hooks), they are not considered here.
#

import sys

from vyos.configtree import ConfigTree

firewall_base = ['firewall']

def migrate_chain(config: ConfigTree, path: list[str]) -> None:
if not config.exists(path + ['rule']):
return

for rule_num in config.list_nodes(path + ['rule']):
tmp_path = path + ['rule', rule_num, 'ipsec']
if config.exists(tmp_path + ['match-ipsec']):
Expand All @@ -56,5 +57,4 @@ def migrate(config: ConfigTree) -> None:

for base_hook in [['forward', 'filter'], ['input', 'filter'], ['prerouting', 'raw']]:
tmp_path = firewall_base + [family] + base_hook
if config.exists(tmp_path):
migrate_chain(config, tmp_path)
migrate_chain(config, tmp_path)

0 comments on commit 3d42009

Please sign in to comment.