From d9ba5d4a6f38111b9656c91589bdc274214ac93b Mon Sep 17 00:00:00 2001 From: sarthurdev <965089+sarthurdev@users.noreply.github.com> Date: Tue, 5 Jul 2022 19:10:40 +0200 Subject: firewall: T2199: Fix migration when `icmpv6 type` is an integer --- smoketest/configs/dialup-router-complex | 21 +++++++++++++++++++++ src/migration-scripts/firewall/6-to-7 | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/smoketest/configs/dialup-router-complex b/smoketest/configs/dialup-router-complex index ac5ff5e99..909e6d17b 100644 --- a/smoketest/configs/dialup-router-complex +++ b/smoketest/configs/dialup-router-complex @@ -66,6 +66,27 @@ firewall { action accept protocol icmpv6 } + rule 15 { + action accept + icmpv6 { + type 1 + } + protocol icmpv6 + } + rule 16 { + action accept + icmpv6 { + type 1/1 + } + protocol icmpv6 + } + rule 17 { + action accept + icmpv6 { + type destination-unreachable + } + protocol icmpv6 + } } ipv6-name ALLOW-ESTABLISHED-6 { default-action drop diff --git a/src/migration-scripts/firewall/6-to-7 b/src/migration-scripts/firewall/6-to-7 index 5f4cff90d..626d6849f 100755 --- a/src/migration-scripts/firewall/6-to-7 +++ b/src/migration-scripts/firewall/6-to-7 @@ -194,11 +194,12 @@ if config.exists(base + ['ipv6-name']): if config.exists(rule_icmp + ['type']): tmp = config.return_value(rule_icmp + ['type']) - type_code_match = re.match(r'^(\d+)/(\d+)$', tmp) + type_code_match = re.match(r'^(\d+)(?:/(\d+))?$', tmp) if type_code_match: config.set(rule_icmp + ['type'], value=type_code_match[1]) - config.set(rule_icmp + ['code'], value=type_code_match[2]) + if type_code_match[2]: + config.set(rule_icmp + ['code'], value=type_code_match[2]) elif tmp in icmpv6_remove: config.delete(rule_icmp + ['type']) elif tmp in icmpv6_translations: -- cgit v1.2.3