Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T6351: CGNAT add verification if the pool exists (backport #3464) #3469

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 17, 2024

Change Summary

Add verification if the external/internal pools are exists before we can use them in the source and translation rules

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

cgnat

Proposed changes

How to test

Use not exists pool name in the rules (in this example fake-pool):

set nat cgnat pool external ext1 external-port-range '1024-65535'
set nat cgnat pool external ext1 per-user-limit port '2000'
set nat cgnat pool external ext1 range 192.168.122.222/32
set nat cgnat pool internal int1 range '100.64.0.0/28'

set nat cgnat rule 10 source pool 'fake-pool'
set nat cgnat rule 10 translation pool 'ext1'

Before the fix:

vyos@r4# commit
[ nat cgnat ]
VyOS had an issue completing a command.

Report time:      2024-05-16 15:23:29
Image version:    VyOS 1.5-rolling-202405140019
Release train:    current

Built by:         autobuild@vyos.net
Built on:         Tue 14 May 2024 02:55 UTC
Build UUID:       c30a637d-f3c1-473e-8af6-03c9bfaf0729
Build commit ID:  3463386246a9ac

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  QEMU
Hardware model:   Standard PC (Q35 + ICH9, 2009)
Hardware S/N:     
Hardware UUID:    166cfd25-7d3a-4eca-9ef6-0b655c9acf0f

Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/nat_cgnat.py", line 284, in <module>
    generate(c)
  File "/usr/libexec/vyos/conf_mode/nat_cgnat.py", line 240, in generate
    i_count = IPOperations(int_range).get_ips_count()
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/conf_mode/nat_cgnat.py", line 39, in __init__
    self.ip_network = ipaddress.ip_network(ip_prefix) if '/' in ip_prefix else None
                                                         ^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable



[[nat cgnat]] failed
Commit failed
[edit]
vyos@r4#

After the fix:

vyos@r4# commit
[ nat cgnat ]
Internal pool "fake-pool" does not exist!

[[nat cgnat]] failed
Commit failed
[edit]
vyos@r4# 

Smoketest result

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

This is an automatic backport of pull request #3464 done by [Mergify](https://mergify.com).

Add verification if the external/internal pools are exists before we
can use them in the source and translation rules

(cherry picked from commit c4cee2b)

# Conflicts:
#	src/conf_mode/nat_cgnat.py
Copy link
Contributor Author

mergify bot commented May 17, 2024

Cherry-pick of c4cee2b has failed:

On branch mergify/bp/sagitta/pr-3464
Your branch is up to date with 'origin/sagitta'.

You are currently cherry-picking commit c4cee2b7c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   src/conf_mode/nat_cgnat.py

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the conflicts label May 17, 2024
@github-actions github-actions bot added the sagitta VyOS 1.4 LTS label May 17, 2024
@sever-sever
Copy link
Member

We do not have CGNAT for 1.4

@mergify mergify bot deleted the mergify/bp/sagitta/pr-3464 branch May 17, 2024 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

1 participant