diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-05 22:08:21 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-03-05 22:08:21 +0100 |
commit | d49f5f38337a523c07584665e23c1fabcc960a77 (patch) | |
tree | 19ec9acaf3bea8d3b4fdc988e6d6f49079651911 /src/conf_mode/vrf.py | |
parent | e1f8d7678d48750c07fb586d0e6444a92af77f92 (diff) | |
download | vyos-1x-d49f5f38337a523c07584665e23c1fabcc960a77.tar.gz vyos-1x-d49f5f38337a523c07584665e23c1fabcc960a77.zip |
vrf: T31: improve kernel rule lookup table code
Diffstat (limited to 'src/conf_mode/vrf.py')
-rwxr-xr-x | src/conf_mode/vrf.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py index 2ef025aeb..8b91d73bb 100755 --- a/src/conf_mode/vrf.py +++ b/src/conf_mode/vrf.py @@ -230,19 +230,19 @@ def apply(vrf_config): # change preference when VRFs are enabled and local lookup table is default if not local_pref and vrf_config['vrf_add']: - _cmd(f'ip -4 rule add pref 32765 table local') - _cmd(f'ip -4 rule del pref 0') - _cmd(f'ip -6 rule add pref 32765 table local') - _cmd(f'ip -6 rule del pref 0') + for af in ['-4', '-6']: + _cmd(f'ip {af} rule add pref 32765 table local') + _cmd(f'ip {af} rule del pref 0') # return to default lookup preference when no VRF is configured if not vrf_config['vrf_add']: - _cmd(f'ip -4 rule add pref 0 table local') - _cmd(f'ip -4 rule del pref 1000') - _cmd(f'ip -4 rule del pref 32765') - _cmd(f'ip -6 rule add pref 0 table local') - _cmd(f'ip -6 rule del pref 1000') - _cmd(f'ip -6 rule del pref 32765') + for af in ['-4', '-6']: + _cmd(f'ip {af} rule add pref 0 table local') + _cmd(f'ip {af} rule del pref 32765') + + # clean out l3mdev-table rule if present + if 1000 in [r.get('priority') for r in list_rules() if r.get('priority') == 1000]: + _cmd(f'ip {af} rule del pref 1000') return None |