diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-08-05 14:39:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-05 14:39:46 +0100 |
| commit | 11efbfa0eab5cc6090f6d5ff22eca5c8562a9c37 (patch) | |
| tree | 7a615d617f1634c791031c7c16629cae2a3ece61 | |
| parent | 35f333b26326940e5e0cf3f97eb99dbb55a77e08 (diff) | |
| parent | d54b9445672ad454edde8d56f19468b225dd87e0 (diff) | |
| download | vyos-1x-11efbfa0eab5cc6090f6d5ff22eca5c8562a9c37.tar.gz vyos-1x-11efbfa0eab5cc6090f6d5ff22eca5c8562a9c37.zip | |
Merge pull request #4643 from MattKobayashi/T7685
T7685: load-balancing: fix rules with multiple ports
| -rw-r--r-- | python/vyos/wanloadbalance.py | 2 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_load-balancing_wan.py | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/python/vyos/wanloadbalance.py b/python/vyos/wanloadbalance.py index 2381f7d1c..158ee76c8 100644 --- a/python/vyos/wanloadbalance.py +++ b/python/vyos/wanloadbalance.py @@ -65,7 +65,7 @@ def nft_rule(rule_conf, rule_id, local=False, exclude=False, limit=False, weight if port[:1] == '!': operator = '!=' port = port[1:] - output.append(f'th {prefix}port {operator} {port}') + output.append(f'th {prefix}port {operator} {{ {port} }}') if 'source_based_routing' not in rule_conf and not restore_mark: output.append('ct state new') diff --git a/smoketest/scripts/cli/test_load-balancing_wan.py b/smoketest/scripts/cli/test_load-balancing_wan.py index 937cc3b76..904dabd04 100755 --- a/smoketest/scripts/cli/test_load-balancing_wan.py +++ b/smoketest/scripts/cli/test_load-balancing_wan.py @@ -306,6 +306,17 @@ echo "$ifname - $state" > {hook_output_path} self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp1_iface]) self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp1_iface, 'weight', '10']) self.cli_set(base_path + ['wan', 'rule', '10', 'interface', isp2_iface]) + self.cli_set(base_path + ['wan', 'rule', '20', 'inbound-interface', lan_iface]) + self.cli_set(base_path + ['wan', 'rule', '20', 'protocol', 'udp']) + self.cli_set( + base_path + ['wan', 'rule', '20', 'source', 'address', '198.51.100.0/24'] + ) + self.cli_set(base_path + ['wan', 'rule', '20', 'source', 'port', '80,443']) + self.cli_set( + base_path + ['wan', 'rule', '20', 'destination', 'address', '192.0.2.0/24'] + ) + self.cli_set(base_path + ['wan', 'rule', '20', 'destination', 'port', '80,443']) + self.cli_set(base_path + ['wan', 'rule', '20', 'interface', isp2_iface]) # commit changes self.cli_commit() @@ -316,7 +327,22 @@ echo "$ifname - $state" > {hook_output_path} nftables_search = [ [f'iifname "eth*"', 'ip daddr 10.0.0.0/8', 'return'], - [f'iifname "{lan_iface}"', 'ip saddr 198.51.100.0/24', 'udp sport 53', 'ip daddr 192.0.2.0/24', 'udp dport 53', f'jump wlb_mangle_isp_{isp1_iface}'] + [ + f'iifname "{lan_iface}"', + 'ip saddr 198.51.100.0/24', + 'udp sport 53', + 'ip daddr 192.0.2.0/24', + 'udp dport 53', + f'jump wlb_mangle_isp_{isp1_iface}', + ], + [ + f'iifname "{lan_iface}"', + 'ip saddr 198.51.100.0/24', + 'udp sport { 80, 443 }', + 'ip daddr 192.0.2.0/24', + 'udp dport { 80, 443 }', + f'jump wlb_mangle_isp_{isp2_iface}', + ], ] self.verify_nftables_chain(nftables_search, 'ip vyos_wanloadbalance', 'wlb_mangle_prerouting') |
