summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoctorpangloss <2229300+doctorpangloss@users.noreply.github.com>2026-05-11 15:44:50 -0700
committerdoctorpangloss <2229300+doctorpangloss@users.noreply.github.com>2026-05-12 10:57:27 -0700
commit33ac35a45b813ab408c7ce0ccb511608a637fc68 (patch)
tree9565d9516575a2bc2e0dd16f7f1d4bcc2d36d466
parent2df14cbbc0e4e5e6657bb02938768d48f7294684 (diff)
downloadvyos-1x-33ac35a45b813ab408c7ce0ccb511608a637fc68.tar.gz
vyos-1x-33ac35a45b813ab408c7ce0ccb511608a637fc68.zip
wan: T8480: make only-default-route opt-in
-rw-r--r--interface-definitions/load-balancing_wan.xml.in6
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_wan.py17
-rwxr-xr-xsrc/helpers/vyos-load-balancer.py24
3 files changed, 43 insertions, 4 deletions
diff --git a/interface-definitions/load-balancing_wan.xml.in b/interface-definitions/load-balancing_wan.xml.in
index 24be00111..17bd3aaf3 100644
--- a/interface-definitions/load-balancing_wan.xml.in
+++ b/interface-definitions/load-balancing_wan.xml.in
@@ -29,6 +29,12 @@
<valueless/>
</properties>
</leafNode>
+ <leafNode name="only-default-route">
+ <properties>
+ <help>Prefer specific routes in the main routing table over WAN load balancing</help>
+ <valueless/>
+ </properties>
+ </leafNode>
<leafNode name="hook">
<properties>
<help>Script to be executed on interface status change</help>
diff --git a/smoketest/scripts/cli/test_load-balancing_wan.py b/smoketest/scripts/cli/test_load-balancing_wan.py
index 3b956a12e..1692b8760 100755
--- a/smoketest/scripts/cli/test_load-balancing_wan.py
+++ b/smoketest/scripts/cli/test_load-balancing_wan.py
@@ -138,6 +138,23 @@ class TestLoadBalancingWan(VyOSUnitTestSHIM.TestCase):
tmp = cmd('sudo ip route show table 202')
self.assertEqual(tmp, original)
+ tmp = cmd('sudo ip rule show')
+ self.assertIn('from all fwmark 0xc9 lookup 201', tmp)
+ self.assertIn('from all fwmark 0xca lookup 202', tmp)
+ self.assertNotIn('fwmark 0xc9 lookup main suppress_prefixlength 0', tmp)
+ self.assertNotIn('fwmark 0xca lookup main suppress_prefixlength 0', tmp)
+
+ self.cli_set(base_path + ['wan', 'only-default-route'])
+ self.cli_commit()
+
+ time.sleep(5)
+
+ tmp = cmd('sudo ip rule show')
+ self.assertIn('from all fwmark 0xc9 lookup main suppress_prefixlength 0', tmp)
+ self.assertIn('from all fwmark 0xc9 lookup 201', tmp)
+ self.assertIn('from all fwmark 0xca lookup main suppress_prefixlength 0', tmp)
+ self.assertIn('from all fwmark 0xca lookup 202', tmp)
+
# Delete veth interfaces and netns
for iface in [iface1, iface2, iface3]:
call(f'sudo ip link del dev {iface}')
diff --git a/src/helpers/vyos-load-balancer.py b/src/helpers/vyos-load-balancer.py
index 8cb792a5d..127ce05e5 100755
--- a/src/helpers/vyos-load-balancer.py
+++ b/src/helpers/vyos-load-balancer.py
@@ -207,8 +207,15 @@ def cleanup(lb):
suppress_prio = lb['mark_offset'] + index
table_prio = suppress_prio + 100
run(f'ip route del table {table_num} default')
- run(f'ip rule del priority {suppress_prio}')
- run(f'ip rule del priority {table_prio}')
+ run(
+ f'ip rule del fwmark {hex(table_num)} table main '
+ f'suppress_prefixlength 0 priority {suppress_prio}'
+ )
+ run(
+ f'ip rule del fwmark {hex(table_num)} table {table_num} '
+ f'priority {table_prio}'
+ )
+ run(f'ip rule del fwmark {hex(table_num)} table {table_num}')
index += 1
run(f'nft delete table ip vyos_wanloadbalance')
@@ -268,8 +275,17 @@ if __name__ == '__main__':
suppress_prio = lb['mark_offset'] + index
table_prio = suppress_prio + 100
- run(f'ip rule add fwmark {hex(table_num)} table main suppress_prefixlength 0 priority {suppress_prio}')
- run(f'ip rule add fwmark {hex(table_num)} table {table_num} priority {table_prio}')
+ if 'only_default_route' in lb:
+ run(
+ f'ip rule add fwmark {hex(table_num)} table main '
+ f'suppress_prefixlength 0 priority {suppress_prio}'
+ )
+ run(
+ f'ip rule add fwmark {hex(table_num)} table {table_num} '
+ f'priority {table_prio}'
+ )
+ else:
+ run(f'ip rule add fwmark {hex(table_num)} table {table_num}')
index += 1