Skip to content

Add NAT model #1335

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add NAT model #1335

wants to merge 5 commits into from

Conversation

nleiva
Copy link

@nleiva nleiva commented Jul 14, 2025

Change Scope

  • This PR introduces a new YANG data model for Network Address Translation (NAT).
  • This is a new model, so the change is backward compatible.

We use NAT instances to stay in line with RFC 8512.
NAT rules can match a routing-policy or acl-set to accommodate different vendor implementations.

module: openconfig-nat
  +--rw nat
     +--rw config
     |  +--rw enabled?               boolean
     |  +--rw translation-timeout?   uint32
     |  +--rw max-translations?      uint32
     |  +--rw log-level?             enumeration
     +--ro state
     |  +--ro enabled?                      boolean
     |  +--ro total-instances?              uint32
     |  +--ro active-instances?             uint32
     |  +--ro total-active-translations?    yang:counter64
     |  +--ro total-translation-failures?   yang:counter64
     |  +--ro memory-usage?                 uint32
     |  +--ro uptime?                       yang:timeticks
     +--rw instances
        +--rw instance* [name]
           +--rw name          -> ../config/name
           +--rw config
           |  +--rw name?          string
           |  +--rw type?          identityref
           |  +--rw enabled?       boolean
           |  +--rw description?   string
           +--ro state
           |  +--ro name?               string
           |  +--ro type?               identityref
           |  +--ro enabled?            boolean
           |  +--ro description?        string
           |  +--ro active-mappings?    yang:counter64
           |  +--ro total-mappings?     yang:counter64
           |  +--ro mapping-failures?   yang:counter64
           +--rw interfaces
           |  +--rw interface* [interface]
           |     +--rw interface    -> ../config/interface
           |     +--rw config
           |     |  +--rw interface?   oc-if:base-interface-ref
           |     |  +--rw direction?   nat-direction
           |     +--ro state
           |        +--ro interface?            oc-if:base-interface-ref
           |        +--ro direction?            nat-direction
           |        +--ro packets-translated?   yang:counter64
           |        +--ro bytes-translated?     yang:counter64
           |        +--ro translation-errors?   yang:counter64
           +--rw pools
           |  +--rw pool* [name]
           |     +--rw name      -> ../config/name
           |     +--rw config
           |     |  +--rw name?                           string
           |     |  +--rw start-address?                  inet:ipv4-address
           |     |  +--rw end-address?                    inet:ipv4-address
           |     |  +--rw port-range-start?               inet:port-number
           |     |  +--rw port-range-end?                 inet:port-number
           |     |  +--rw port-block-size?                uint16
           |     |  +--rw (traffic-matcher)?
           |     |  |  +--:(routing-policy)
           |     |  |  |  +--rw policy-definition?        -> /oc-rpol:routing-policy/policy-definitions/policy-definition/name
           |     |  |  +--:(access-list)
           |     |  |     +--rw acl-set?                  -> /oc-acl:acl/acl-sets/acl-set/config/name
           |     |  +--rw persistent?                     boolean
           |     |  +--rw max-sessions?                   uint32
           |     |  +--rw address-only?                   boolean
           |     |  +--rw timeout?                        uint32
           |     |  +--rw tcp-timeout?                    uint32
           |     |  +--rw udp-timeout?                    uint32
           |     |  +--rw icmp-timeout?                   uint32
           |     |  +--rw overload?                       boolean
           |     |  +--rw log-translations?               boolean
           |     |  +--rw max-translations-per-address?   uint32
           |     +--ro state
           |        +--ro name?                           string
           |        +--ro start-address?                  inet:ipv4-address
           |        +--ro end-address?                    inet:ipv4-address
           |        +--ro port-range-start?               inet:port-number
           |        +--ro port-range-end?                 inet:port-number
           |        +--ro port-block-size?                uint16
           |        +--ro (traffic-matcher)?
           |        |  +--:(routing-policy)
           |        |  |  +--ro policy-definition?        -> /oc-rpol:routing-policy/policy-definitions/policy-definition/name
           |        |  +--:(access-list)
           |        |     +--ro acl-set?                  -> /oc-acl:acl/acl-sets/acl-set/config/name
           |        +--ro persistent?                     boolean
           |        +--ro max-sessions?                   uint32
           |        +--ro address-only?                   boolean
           |        +--ro timeout?                        uint32
           |        +--ro tcp-timeout?                    uint32
           |        +--ro udp-timeout?                    uint32
           |        +--ro icmp-timeout?                   uint32
           |        +--ro overload?                       boolean
           |        +--ro log-translations?               boolean
           |        +--ro max-translations-per-address?   uint32
           |        +--ro allocated-addresses?            uint32
           |        +--ro available-addresses?            uint32
           |        +--ro hit-count?                      yang:counter64
           |        +--ro active-sessions?                uint32
           +--rw mappings
              +--rw mapping* [name]
                 +--rw name      -> ../config/name
                 +--rw config
                 |  +--rw name?                      string
                 |  +--rw internal-address?          inet:ipv4-address
                 |  +--rw external-address?          inet:ipv4-address
                 |  +--rw internal-port?             inet:port-number
                 |  +--rw external-port?             inet:port-number
                 |  +--rw protocol?                  protocol-type
                 |  +--rw (traffic-matcher)?
                 |  |  +--:(routing-policy)
                 |  |  |  +--rw policy-definition?   -> /oc-rpol:routing-policy/policy-definitions/policy-definition/name
                 |  |  +--:(access-list)
                 |  |     +--rw acl-set?             -> /oc-acl:acl/acl-sets/acl-set/config/name
                 |  +--rw persistent?                boolean
                 |  +--rw max-sessions?              uint32
                 |  +--rw bidirectional?             boolean
                 |  +--rw enabled?                   boolean
                 +--ro state
                    +--ro name?                      string
                    +--ro internal-address?          inet:ipv4-address
                    +--ro external-address?          inet:ipv4-address
                    +--ro internal-port?             inet:port-number
                    +--ro external-port?             inet:port-number
                    +--ro protocol?                  protocol-type
                    +--ro (traffic-matcher)?
                    |  +--:(routing-policy)
                    |  |  +--ro policy-definition?   -> /oc-rpol:routing-policy/policy-definitions/policy-definition/name
                    |  +--:(access-list)
                    |     +--ro acl-set?             -> /oc-acl:acl/acl-sets/acl-set/config/name
                    +--ro persistent?                boolean
                    +--ro max-sessions?              uint32
                    +--ro bidirectional?             boolean
                    +--ro enabled?                   boolean
                    +--ro creation-time?             yang:date-and-time
                    +--ro last-used?                 yang:date-and-time
                    +--ro packet-count?              yang:counter64
                    +--ro byte-count?                yang:counter64
                    +--ro hit-count?                 yang:counter64
                    +--ro active-sessions?           uint32

Platform Implementations

@nleiva nleiva requested a review from a team as a code owner July 14, 2025 18:42
@dplore dplore moved this to Ready to discuss in OC Operator Review Jul 15, 2025
@dplore
Copy link
Member

dplore commented Jul 15, 2025

/gcbrun

@OpenConfigBot
Copy link

OpenConfigBot commented Jul 15, 2025

No major YANG version changes in commit 78ed184

Copy link
Member

@dplore dplore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nleiva for this contribution! I've only done a very shallow review so far of the general tree structure so far, but please consider using when statements and or descriptions instead of the choice statement.

"Number of ports allocated per mapping";
}

choice traffic-matcher {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC style strongly prefers to avoid choice statements, but you could use when for enforcing some validations in the model. (So far we have not used choice in any OC model)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dplore, that was an oversight on our end. We replaced choice with when statements.

@ElodinLaarz
Copy link
Contributor

/gcbrun

1 similar comment
@dplore
Copy link
Member

dplore commented Jul 15, 2025

/gcbrun

@ElodinLaarz
Copy link
Contributor

Discussed in the OC Operators Meeting on July 15th. If we don't have a reason to use multiple implementations, we should try to choose a single means of configuration to help with vendor-neutral implementations.

If we do actually have operational use cases for needing both ways of implementation, then this is fine. Sounds like ACL-based is supported by two vendors already; so, we may choose to only add the model for that subtree.

@nleiva
Copy link
Author

nleiva commented Jul 15, 2025

/gcbrun

Hi @dplore , would you trigger the cloud checks again? I believe we fixed the failing test. Thanks

@dplore
Copy link
Member

dplore commented Jul 15, 2025

/gcbrun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready to discuss
Development

Successfully merging this pull request may close these issues.

4 participants