diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2025-12-11 11:26:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-11 11:26:06 +0200 |
| commit | db841de87054f79adc53ad744287e8121f405db0 (patch) | |
| tree | 1b01abe21a5fd12b0ac3151b098d65deb1c6e732 /src | |
| parent | 781691031f68d5ad0f32b34703a5650844685a0b (diff) | |
| parent | e091fb8bd87da8c9cd56f3435b39134b917a57a2 (diff) | |
| download | vyos-1x-db841de87054f79adc53ad744287e8121f405db0.tar.gz vyos-1x-db841de87054f79adc53ad744287e8121f405db0.zip | |
Merge pull request #4880 from natali-rs1985/T7972
vpp: T7972: Make `nat44 no-forwarding` feature automatically configurable
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_mode/vpp_nat.py | 8 | ||||
| -rw-r--r-- | src/migration-scripts/vpp/3-to-4 | 30 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/conf_mode/vpp_nat.py b/src/conf_mode/vpp_nat.py index f7dbf4052..cfe527ab8 100644 --- a/src/conf_mode/vpp_nat.py +++ b/src/conf_mode/vpp_nat.py @@ -439,10 +439,10 @@ def apply(config): # Add NAT44 n.enable_nat44_ed() - # Enable/disable forwarding - enable_forwarding = True - if 'no_forwarding' in config: - enable_forwarding = False + # Dynamic rules always require `address-pool translation` in CLI - we can use this for an easy validation + # Forwarding must be disabled when dynamic rules are present + # Without dynamic rules, forwarding remains enabled + enable_forwarding = not bool(config.get('address_pool', {}).get('translation')) n.enable_disable_nat44_forwarding(enable_forwarding) # Add inside interfaces diff --git a/src/migration-scripts/vpp/3-to-4 b/src/migration-scripts/vpp/3-to-4 new file mode 100644 index 000000000..8c79299f5 --- /dev/null +++ b/src/migration-scripts/vpp/3-to-4 @@ -0,0 +1,30 @@ +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see <http://www.gnu.org/licenses/>. + +# Delete 'vpp settings nat44 no-forwarding' +# because it will be set automatically (T7972) + + +from vyos.configtree import ConfigTree + +base = ['vpp', 'settings', 'nat44'] + +def migrate(config: ConfigTree) -> None: + + if config.exists(base + ['no-forwarding']): + # Delete no-forwarding option from NAT44 settings + config.delete(base + ['no-forwarding']) + if config.exists(base) and len(config.list_nodes(base)) == 0: + config.delete(base) |
