Skip to content

Fix saisdkdump profile file handling. - #1993

Open
judsonwilson-nvidia wants to merge 4 commits into
sonic-net:masterfrom
judsonwilson-nvidia:fix_saisdkdump_profile
Open

Fix saisdkdump profile file handling.#1993
judsonwilson-nvidia wants to merge 4 commits into
sonic-net:masterfrom
judsonwilson-nvidia:fix_saisdkdump_profile

Conversation

@judsonwilson-nvidia

Copy link
Copy Markdown
Contributor

Why I did it

saisdkdump did not parse the SAI profile file passed with -p: profile_get_value returned the file path for every key, and profile_get_next_value always failed. A new feature on the nvidia-bluefield platform, DASH CT dumps from the SDK in techsupport, needs a profile key (CT_TABLE_DUMP_ENABLE) to reach SAI to trigger the CT dump in the SDK dump.

Work item tracking
  • Microsoft ADO (number only): N/A

How I did it

  • Add ProfileMap (based on saidiscovery) to parse key=value lines, skip comments, and back SAI profile callbacks.
  • Load the profile in saisdkdump before sai_api_initialize; build libsaisdkdump_profile.a.
  • Add gtest coverage in unittest/saisdkdump/ (KV parsing, malformed lines, iterator reset, clear).

How to verify it

./autogen.sh && ./configure --disable-static --disable-python2 --with-sai=vs
make -C saisdkdump libsaisdkdump_profile.a
make -C unittest/saisdkdump check

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305
  • 202311
  • 202405
  • 202411

Tested branch (Please provide the tested image version)

  • master, between 202605–202611

Description for the changelog

Fix saisdkdump profile file flag.

It was not parsing the kv pairs out of the file.

This code is mostly copied from saidiscovery, and put into a separate
file in a class for interfacing with unit tests.

Signed-off-by: Judson Wilson <judsonw@nvidia.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

vivekrnv
vivekrnv previously approved these changes Jul 15, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Signed-off-by: Judson Wilson <judsonw@nvidia.com>
@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).

Signed-off-by: Judson Wilson <judsonw@nvidia.com>
@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).

Signed-off-by: Judson Wilson <judsonw@nvidia.com>
@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

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

2 similar comments
@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

11 similar comments
@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi @sonic-net/sonic-sairedis-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks!

---Powered by SONiC BuildBot

@lolyu lolyu left a comment

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.

Reviewed at head 7363cb5. The core fix is correct and well-tested — profile_get_value previously returned the file path for every key and profile_get_next_value always returned -1, so -p was effectively dead; the new ProfileMap (modeled on saidiscovery) properly parses key=value, skips #/; comments, handles CRLF, and backs both callbacks with the right iterator semantics. Good gtest coverage and clean build wiring (.gitignore/configure.ac/Makefiles/unittest subdir).

One behavior concern on the default (no--p) invocation — inline. Otherwise LGTM; nice work.

Comment thread saisdkdump/saisdkdump.cpp
SWSS_LOG_INFO("The dump file is not specified, generated \"%s\" file name", fileName.c_str());
}

if (!g_profileMap.loadFromFile(sai_profile))

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.

🟠 Possible regression for the default (no--p) case. sai_profile defaults to /tmp/sai.profile (not empty), and -p is optional. loadFromFile returns false when the file can't be opened, and here that maps to exit(EXIT_FAILURE). So if a user runs saisdkdump without -p and /tmp/sai.profile doesn't exist, the tool now hard-fails — whereas before this PR it ran fine (the callbacks just returned the path / -1 and SAI init proceeded). For a general techsupport/diagnostic tool, failing hard when no profile is present at the default path is a meaningful change.

Note the asymmetry that suggests this is unintended: loadFromFile("") returns true and loads nothing (a deliberate "no profile is fine" path), but the non-empty default defeats it, so that graceful branch is never taken unless the user explicitly passes -p "".

Suggest mirroring the existing -f handling: track whether -p was explicitly given (like fileSpecified) and only hard-fail on a missing file when the user explicitly requested one; tolerate absence of the default path (warn + empty map, continue). That keeps prior behavior for the common no--p case while still catching a genuine "pointed at a profile that doesn't exist" mistake.

If the bluefield techsupport flow always passes -p and the default-path fail-hard is acceptable/intended, feel free to confirm and disregard — just flagging since saisdkdump is invoked as a general diagnostic tool.

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.

4 participants