From 55e02bef4f3aeff5e33cddc79f22b93fc671e491 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Tue, 28 May 2024 13:06:51 +0000 Subject: T6411: CGNAT fix sequences for external address ranges Fix the bug where address external alocation was not rely on sequences of the external IP addresses (if set) --- src/conf_mode/nat_cgnat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/conf_mode/nat_cgnat.py b/src/conf_mode/nat_cgnat.py index 5ad65de80..957b12c28 100755 --- a/src/conf_mode/nat_cgnat.py +++ b/src/conf_mode/nat_cgnat.py @@ -252,7 +252,11 @@ def generate(config): ext_pool_name: str = rule_config['translation']['pool'] int_pool_name: str = rule_config['source']['pool'] - external_ranges: list = [range for range in config['pool']['external'][ext_pool_name]['range']] + # Sort the external ranges by sequence + external_ranges: list = sorted( + config['pool']['external'][ext_pool_name]['range'], + key=lambda r: int(config['pool']['external'][ext_pool_name]['range'][r].get('seq', 999999)) + ) internal_ranges: list = [range for range in config['pool']['internal'][int_pool_name]['range']] external_list_hosts_count = [] external_list_hosts = [] -- cgit v1.2.3