sonic-net / sonic-swss

SONiC Switch State Service (SwSS)
https://azure.github.io/SONiC
Other
176 stars 529 forks source link

[NAT] Interface zone changes after re-adding its IP #1313

Closed mpiechocinski closed 4 years ago

mpiechocinski commented 4 years ago

Problem description: I am deleting interfaces IP with interfaces zone being set to 1, after re-adding the interfaces IP its zone is set to 0.

Steps to reproduce:

echo ' { "PORTCHANNEL": { "PortChannel01": { "admin_status": "up", "members": [ "Ethernet4" ], "min_links": "1", "mtu": "9100" } }, "PORTCHANNEL_INTERFACE": { "PortChannel01": {}, "PortChannel01|10.0.0.78/31": {} }, "PORTCHANNEL_MEMBER": { "PortChannel01|Ethernet4": {} } }' > dynamic_3.json sonic-cfggen -j dynamic_3.json --write-to-db sudo config nat add static basic 10.0.0.78 192.168.0.1 -nat_type dnat sudo config nat add interface PortChannel01 -nat_zone 1 show nat config zones sudo config interface ip remove PortChannel01 10.0.0.78/31 show nat config zones sudo config interface ip add PortChannel01 10.0.0.78/31 show nat config zones

Expected result: Interface zone should be set to 1 after re-adding its IP.

Actual result: Interface zone is set to 0 after re-adding its IP. See log linked at the bottom.

Environment: montara IP: 10.91.68.143 SONiC information:

SONiC Software Version: SONiC.HEAD.18-dirty-20200413.073958 Distribution: Debian 9.12 Kernel: 4.9.0-11-2-amd64 Build commit: d09fba37 Build date: Mon Apr 13 12:26:34 UTC 2020 Built by: johnar@jenkins-worker-8

Platform: x86_64-accton_wedge100bf_32x-r0 HwSKU: montara ASIC: barefoot Serial Number: AJ49009297 Uptime: 13:01:28 up 1 day, 3:32, 1 user, load average: 1.22, 1.25, 1.49 SDE information: "build_date": "Wed Jun 3 05:49:25 2020", "schema_version": "1.11.1", "compiler_version": "9.3.0", "target": "tofino", "program_name": "switch_tofino_x2",

Log:

image

AkhileshSamineni commented 4 years ago

@mpiechocinski This is expected behavior only.

Few points about nat zone :

  1. The nat zone is an RIF attribute. "INTERFACE": {
    "Ethernet18": {
    "nat_zone": "1"
    }, "Ethernet18|125.56.90.12/24": {} }
  2. When RIF is created, nat_zone is set to zero by default.
  3. nat zone configuration is allowed only when interface is created earlier.
  4. nat_zone retains it's value until RIF is present.
  5. Once RIF is deleted, it cleans up the nat zone configuration from CONFIG_DB as well.
arlakshm commented 4 years ago

@mpiechocinski, please verify and close the issue if problem not seen.