From d49f5f38337a523c07584665e23c1fabcc960a77 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 5 Mar 2020 22:08:21 +0100 Subject: vrf: T31: improve kernel rule lookup table code --- src/conf_mode/vrf.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') 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 -- cgit v1.2.3