diff options
author | Henning Surmeier <me@hensur.de> | 2022-01-21 13:27:18 +0100 |
---|---|---|
committer | Henning Surmeier <me@hensur.de> | 2022-02-23 22:12:35 +0100 |
commit | 00b680a4ac975759b088f6b480e311b5919a2e09 (patch) | |
tree | ef244ac3ca8efdab767059fd86e5f27bee05aa8c | |
parent | cb580de792caa00206401c84bbb11a31a6fccf95 (diff) | |
download | vyos-1x-00b680a4ac975759b088f6b480e311b5919a2e09.tar.gz vyos-1x-00b680a4ac975759b088f6b480e311b5919a2e09.zip |
backport: policy: T4151: Bugfix policy ipv6-local-route
-rwxr-xr-x | smoketest/scripts/cli/test_policy.py | 8 | ||||
-rwxr-xr-x | src/conf_mode/policy-local-route.py | 15 |
2 files changed, 14 insertions, 9 deletions
diff --git a/smoketest/scripts/cli/test_policy.py b/smoketest/scripts/cli/test_policy.py index df21d51d8..7dc154fbf 100755 --- a/smoketest/scripts/cli/test_policy.py +++ b/smoketest/scripts/cli/test_policy.py @@ -924,8 +924,8 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase): path = base_path + ['local-route'] path_v6 = base_path + ['local-route6'] - sources = ['203.0.113.1/24', '203.0.114.5'] - destinations = ['203.0.112.1/24', '203.0.116.5'] + sources = ['203.0.113.0/24', '203.0.114.5'] + destinations = ['203.0.112.0/24', '203.0.116.5'] sources_v6 = ['2001:db8:1338::/126', '2001:db8:1339::/56'] destinations_v6 = ['2001:db8:13::/48', '2001:db8:16::/48'] fwmk = '23' @@ -975,8 +975,8 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase): tmp = cmd('ip rule show prio 103') tmp_v6 = cmd('ip -6 rule show prio 103') - original = [''] - original_v6 = [''] + original = None + original_v6 = None self.assertEqual(sort_ip(tmp), original) self.assertEqual(sort_ip(tmp_v6), original_v6) diff --git a/src/conf_mode/policy-local-route.py b/src/conf_mode/policy-local-route.py index 5e2b8c267..f866346a4 100755 --- a/src/conf_mode/policy-local-route.py +++ b/src/conf_mode/policy-local-route.py @@ -127,11 +127,14 @@ def apply(pbr): if rule_rm in pbr: v6 = " -6" if rule_rm == 'rule6_remove' else "" for rule, rule_config in pbr[rule_rm].items(): - for src in (rule_config['source'] or ['']): + rule_config['source'] = rule_config['source'] if 'source' in rule_config else [''] + for src in rule_config['source']: f_src = '' if src == '' else f' from {src} ' - for dst in (rule_config['destination'] or ['']): + rule_config['destination'] = rule_config['destination'] if 'destination' in rule_config else [''] + for dst in rule_config['destination']: f_dst = '' if dst == '' else f' to {dst} ' - for fwmk in (rule_config['fwmark'] or ['']): + rule_config['fwmark'] = rule_config['fwmark'] if 'fwmark' in rule_config else [''] + for fwmk in rule_config['fwmark']: f_fwmk = '' if fwmk == '' else f' fwmark {fwmk} ' call(f'ip{v6} rule del prio {rule} {f_src}{f_dst}{f_fwmk}') @@ -147,9 +150,11 @@ def apply(pbr): for rule, rule_config in pbr_route['rule'].items(): table = rule_config['set']['table'] - for src in (rule_config['source'] or ['all']): + rule_config['source'] = rule_config['source'] if 'source' in rule_config else ['all'] + for src in rule_config['source'] or ['all']: f_src = '' if src == '' else f' from {src} ' - for dst in (rule_config['destination'] or ['all']): + rule_config['destination'] = rule_config['destination'] if 'destination' in rule_config else ['all'] + for dst in rule_config['destination']: f_dst = '' if dst == '' else f' to {dst} ' f_fwmk = '' if 'fwmark' in rule_config: |