Skip to content

Allow state db to take modified entries made to the tunnel decap table#3960

Merged
prsunny merged 9 commits intosonic-net:masterfrom
developfast:dev/tunnel-decap-mod-state-db
Nov 20, 2025
Merged

Allow state db to take modified entries made to the tunnel decap table#3960
prsunny merged 9 commits intosonic-net:masterfrom
developfast:dev/tunnel-decap-mod-state-db

Conversation

@developfast
Copy link
Copy Markdown
Contributor

@developfast developfast commented Oct 28, 2025

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

  1. "tunnel_type"
  2. "IPINIP"
  3. "dscp_mode"
  4. "pipe"
  5. "ecn_mode"
  6. "standard"
  7. "ttl_mode"
  8. "pipe"

/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB

Added comprehensive unit tests too which pass

make  check-TESTS
make[1]: Entering directory '/home/devojha/data/sonic-swss/tests/mock_tests'
make[2]: Entering directory '/home/devojha/data/sonic-swss/tests/mock_tests'
PASS: tests
PASS: tests_intfmgrd
PASS: tests_teammgrd
PASS: tests_portsyncd
PASS: tests_fpmsyncd
PASS: tests_response_publisher
============================================================================
Testsuite summary for sonic-swss 1.0
============================================================================
# TOTAL: 6
# PASS:  6
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[2]: Leaving directory '/home/devojha/data/sonic-swss/tests/mock_tests'
make[1]: Leaving directory '/home/devojha/data/sonic-swss/tests/mock_tests'

Details if related

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@developfast developfast force-pushed the dev/tunnel-decap-mod-state-db branch from 3fe4837 to 93a087a Compare October 28, 2025 23:32
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@developfast developfast marked this pull request as ready for review November 14, 2025 04:37
@developfast developfast requested a review from prsunny as a code owner November 14, 2025 04:37
Copilot AI review requested due to automatic review settings November 14, 2025 04:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables synchronization of tunnel decap table modifications to STATE_DB, preventing database inconsistencies between STATE_DB, ASIC_DB, and APPL_DB. The implementation tracks field changes via a state_changed flag and publishes updates to STATE_DB when modifications occur to existing tunnel entries.

Key Changes

  • Added state_changed flag tracking in doDecapTunnelTask() to detect when tunnel fields are modified
  • Set the flag when modifiable fields (dscp_mode, ttl_mode, QoS maps) are updated on existing tunnels
  • Added STATE_DB synchronization call when changes are detected

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
orchagent/tunneldecaporch.cpp Implements state change tracking and STATE_DB synchronization for tunnel decap table modifications
tests/mock_tests/tunneldecaporch_ut.cpp Adds comprehensive unit tests for TunnelDecapOrch functionality including creation, modification, and deletion scenarios
tests/mock_tests/Makefile.am Registers the new tunneldecaporch_ut.cpp test file in the build system

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@developfast developfast force-pushed the dev/tunnel-decap-mod-state-db branch from 191dc36 to 03d3d78 Compare November 14, 2025 19:44
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@developfast
Copy link
Copy Markdown
Contributor Author

@kperumalbfn can you pls check why the checks won't run? The agents don't seem to be grabbing the workers before the 45 min timeout

@developfast
Copy link
Copy Markdown
Contributor Author

@prsunny @kperumalbfn can you pls review?

}
}

if (exists && state_changed) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why you want an addition 'state_changed variable? why not simply check 'exists' and set STATE_DB?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If none of the fields were updated, then there's no point updating the state db which this state_changed variable keeps track of

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Its fine, the current check is 'if exists' its anyways setting the SAI attribute.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not necessarily, some attributes like ecn are not set since they are not supported in SAI and still have the exists keyword check; the state_changed variable ensures that if the SAI attribute is not being changed, then the state db does not take in a false change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a comment that ECN_MODE SET attribute is not supported in SAI, so that we will revisit this check after updating SAI headers.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also, this is not a frequent operation of setting the fields, so imo, if 'exists' its still ok to just update STATE_DB. it will be a no-op

@developfast developfast force-pushed the dev/tunnel-decap-mod-state-db branch from 03d3d78 to c1b78ce Compare November 18, 2025 16:18
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@developfast developfast force-pushed the dev/tunnel-decap-mod-state-db branch from 84ef20b to 5c6bfe0 Compare November 19, 2025 21:25
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

}
}

if (exists) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if (valid && exists)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

{ -> new line

Copy link
Copy Markdown
Contributor Author

@developfast developfast Nov 20, 2025

Choose a reason for hiding this comment

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

no need for valid since multiple attributes can be changed in a single call to this function. for instance, dscp and ecn value can be in SET mode where dscp set is allowed and SAI change is made to change asic attribute but ecn mode set is not allowed and the valid flag is set to false. in this case, I still want the dscp mode change to be reflected in the state db. Moreover, state db changes are only reflected if the cached tunnel table has changes to it which doesn't happen when valid = false.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok, i was thinking of this specific case - SWSS_LOG_ERROR("unknown decap tunnel table attribute '%s'.", fvField(i).c_str()); where valid will be false. But agree with you considering the current code flow of setting valid field

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@prsunny prsunny merged commit 820eb74 into sonic-net:master Nov 20, 2025
15 checks passed
yijingyan2 added a commit to yijingyan2/sonic-swss that referenced this pull request Dec 3, 2025
kalash-nexthop pushed a commit to kalash-nexthop/sonic-swss that referenced this pull request Dec 16, 2025
sonic-net#3960)

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

"tunnel_type"
"IPINIP"
"dscp_mode"
"pipe"
"ecn_mode"
"standard"
"ttl_mode"
"pipe"
/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB

Signed-off-by: Kalash Nainwal <kalash@nexthop.ai>
Pterosaur pushed a commit to Janetxxx/sonic-swss that referenced this pull request Jan 6, 2026
sonic-net#3960)

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

"tunnel_type"
"IPINIP"
"dscp_mode"
"pipe"
"ecn_mode"
"standard"
"ttl_mode"
"pipe"
/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB
yehjunying pushed a commit to yehjunying/sonic-swss that referenced this pull request Jan 16, 2026
sonic-net#3960)

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

"tunnel_type"
"IPINIP"
"dscp_mode"
"pipe"
"ecn_mode"
"standard"
"ttl_mode"
"pipe"
/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB
theasianpianist pushed a commit to theasianpianist/sonic-swss that referenced this pull request Feb 4, 2026
sonic-net#3960)

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

"tunnel_type"
"IPINIP"
"dscp_mode"
"pipe"
"ecn_mode"
"standard"
"ttl_mode"
"pipe"
/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
baorliu pushed a commit to baorliu/sonic-swss that referenced this pull request Feb 23, 2026
sonic-net#3960)

What I did
Allow state db to take modified entries made to the tunnel decap table

Why I did it
Prevent DB inconsistency between state, asic and appl db

How I verified it
redis-cli -n 6 HGETALL "TUNNEL_DECAP_TABLE|IPINIP_V6_TUNNEL"

"tunnel_type"
"IPINIP"
"dscp_mode"
"pipe"
"ecn_mode"
"standard"
"ttl_mode"
"pipe"
/var/log/syslog.1:2025 Nov 10 19:18:32.730385 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_TUNNEL' have been synchronised in STATE_DB
/var/log/syslog.1:2025 Nov 10 19:18:32.740298 bjw-can-2700-2 NOTICE swss#orchagent: :- doDecapTunnelTask: Fields for TUNNEL_DECAP_TABLE entry 'IPINIP_V6_TUNNEL' have been synchronised in STATE_DB

Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants