summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2026-03-16 13:23:53 +0000
committerGitHub <noreply@github.com>2026-03-16 13:23:53 +0000
commitc550c01277ef22c1556aab380887744345a46c92 (patch)
tree94ec7a5abc783165a24a92ddf0b76c87d4a4dd7b /python
parent6e2606008e156758bbc8dc0f62290a84ba5507cd (diff)
parent87d9d1e801f7306439dcd79d3c9876225f983111 (diff)
downloadvyos-1x-c550c01277ef22c1556aab380887744345a46c92.tar.gz
vyos-1x-c550c01277ef22c1556aab380887744345a46c92.zip
Merge pull request #5049 from natali-rs1985/T8368
vpp: T8368: Features nat44 and cgnat should not use the same interfaces
Diffstat (limited to 'python')
-rw-r--r--python/vyos/vpp/config_verify.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/vyos/vpp/config_verify.py b/python/vyos/vpp/config_verify.py
index 5c8953392..7b90b37db 100644
--- a/python/vyos/vpp/config_verify.py
+++ b/python/vyos/vpp/config_verify.py
@@ -341,3 +341,27 @@ def verify_vpp_buffers(settings: dict):
'Not enough buffers to initialize RX/TX queues for interfaces. '
f'Set "vpp settings resource-allocation buffers buffers-per-numa" to {buffers_required} or higher'
)
+
+
+def verify_nat_interfaces(config: dict, feature_name: str):
+ """
+ Verify that interfaces are not already used in the selected NAT feature.
+ Example:
+ verify_nat_interfaces(config, 'nat44')
+ verify_nat_interfaces(config, 'cgnat')
+ """
+ directions = ['inside', 'outside']
+ interfaces = config.get('interface', {})
+ nat_interfaces = config.get(f'{feature_name}_config', {}).get('interface', {})
+
+ for direction in directions:
+ for iface in interfaces.get(direction, []):
+ # Check if iface is used in any nat44/cgnat direction
+ nat_dir = next(
+ (d for d in directions if iface in nat_interfaces.get(d, [])), None
+ )
+ if nat_dir:
+ raise ConfigError(
+ f'Cannot use {iface} as {direction} interface: '
+ f'it is already configured as {nat_dir} interface in {feature_name.upper()}'
+ )