Skip to content

Fix Issue #170: saiLoglevelNotify Invalid SAI loglevel errors#1803

Open
kallal79 wants to merge 1 commit intosonic-net:masterfrom
kallal79:fix-issue-170-sai-loglevel-notify-clean
Open

Fix Issue #170: saiLoglevelNotify Invalid SAI loglevel errors#1803
kallal79 wants to merge 1 commit intosonic-net:masterfrom
kallal79:fix-issue-170-sai-loglevel-notify-clean

Conversation

@kallal79
Copy link
Copy Markdown

This patch fixes the Invalid SAI loglevel errors that occur when setting log levels for SAI APIs using swssloglevel command or during syncd restart.

Problem:

  • ERR syncd: :- saiLoglevelNotify: Invalid SAI loglevel SAI_API_NEIGHBOR INFO
  • ERR syncd: :- saiLoglevelNotify: Invalid SAI loglevel SAI_API_NEXT_HOP INFO

Root Cause:
swss::Logger::linkToDb delivers log level as short swss priority strings (INFO, NOTICE, DEBUG, etc.) but sai_deserialize_log_level() expects full SAI enum names (SAI_LOG_LEVEL_INFO, SAI_LOG_LEVEL_NOTICE, etc.).

Solution:

  1. Added swssLogLevelToSaiLogLevel() function that maps 8 swss priority strings to their SAI equivalents
  2. Modified saiLoglevelNotify() to call translation before deserializing
  3. Backward compatible: SAI enum names pass through unchanged
  4. Added comprehensive unit tests (13 test cases)

Files Changed:

  • syncd/Syncd.cpp: Added translation function and modified saiLoglevelNotify()
  • syncd/Syncd.h: Added FRIEND_TEST declarations for unit tests
  • unittest/syncd/TestSaiLoglevelNotify.cpp: New comprehensive test suite
  • unittest/syncd/Makefile.am: Added test file to build

Test Coverage:
All 8 swss SAI mappings (EMERG, ALERT, CRIT, ERROR, WARN, NOTICE, INFO, DEBUG)
Backward compatibility with SAI enum names
Error handling for unknown strings
Vendor SAI failure handling
Exact regression tests for reported error strings

Verification:
The fix resolves: swssloglevel -l INFO -c SAI_API_NEIGHBOR No more Invalid SAI loglevel errors in syncd logs.

Fixes: #170

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 22, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kallal79 / name: Kallal Mukherjee (a27a2ca)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kallal79 kallal79 force-pushed the fix-issue-170-sai-loglevel-notify-clean branch from 73b1d28 to 19c0b3a Compare March 22, 2026 12:45
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

This patch fixes the Invalid SAI loglevel errors that occur when setting
log levels for SAI APIs using swssloglevel command or during syncd restart.

Problem:
- ERR syncd: :- saiLoglevelNotify: Invalid SAI loglevel SAI_API_NEIGHBOR INFO
- ERR syncd: :- saiLoglevelNotify: Invalid SAI loglevel SAI_API_NEXT_HOP INFO

Root Cause:
swss::Logger::linkToDb delivers log level as short swss priority strings
(INFO, NOTICE, DEBUG, etc.) but sai_deserialize_log_level() expects
full SAI enum names (SAI_LOG_LEVEL_INFO, SAI_LOG_LEVEL_NOTICE, etc.).

Solution:
1. Added swssLogLevelToSaiLogLevel() function that maps 8 swss priority
   strings to their SAI equivalents
2. Modified saiLoglevelNotify() to call translation before deserializing
3. Backward compatible: SAI enum names pass through unchanged
4. Added comprehensive unit tests (13 test cases)

Files Changed:
- syncd/Syncd.cpp: Added translation function and modified saiLoglevelNotify()
- syncd/Syncd.h: Added FRIEND_TEST declarations for unit tests
- unittest/syncd/TestSaiLoglevelNotify.cpp: New comprehensive test suite
- unittest/syncd/Makefile.am: Added test file to build

Test Coverage:
 All 8 swss  SAI mappings (EMERG, ALERT, CRIT, ERROR, WARN, NOTICE, INFO, DEBUG)
 Backward compatibility with SAI enum names
 Error handling for unknown strings
 Vendor SAI failure handling
 Exact regression tests for reported error strings

Verification:
The fix resolves: swssloglevel -l INFO -c SAI_API_NEIGHBOR
No more Invalid SAI loglevel errors in syncd logs.

Fixes: sonic-net#170
Signed-off-by: kallal79 <kallal79@users.noreply.github.com>
@kallal79 kallal79 force-pushed the fix-issue-170-sai-loglevel-notify-clean branch from 19c0b3a to a27a2ca Compare March 22, 2026 13:09
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

Failed to set back the log level from DEBUG to INFO/NOTICE for SAI APIs

2 participants