Skip to content

Fix TransferToRemote DPU connection: replace localhost loopback with …#175

Open
hdwhdw wants to merge 1 commit intoAzure:202506from
hdwhdw:cherrypick/fix-dpu-transfer-202506
Open

Fix TransferToRemote DPU connection: replace localhost loopback with …#175
hdwhdw wants to merge 1 commit intoAzure:202506from
hdwhdw:cherrypick/fix-dpu-transfer-202506

Conversation

@hdwhdw
Copy link
Copy Markdown
Contributor

@hdwhdw hdwhdw commented Feb 26, 2026


Why I did it

Cherry-pick fix for DPU TransferToRemote file transfer from upstream sonic-gnmi to 202506 branch.

How I did it

Cherry-picked the following PR from https://github.com/sonic-net/sonic-gnmi:

  1. Fix TransferToRemote DPU connection: replace localhost loopback with … sonic-net/sonic-gnmi#591 - Fix TransferToRemote DPU connection: replace localhost loopback with
    direct DPU connection

The fix addresses a production issue where HandleTransferToRemoteForDPUStreaming used grpc.Dial("localhost:8080",
insecure.NewCredentials()) to loop back through the local gNMI proxy for DPU file transfers. This hardcoded address breaks
when the gNMI server runs on port 50052 with TLS (mTLS) enabled.

Changes:

  • Replace localhost loopback with dpuproxy.GetDPUConnection(), which resolves DPU info from Redis and returns a cached,
    direct gRPC connection to the target DPU
  • Add package-level singleton in dpuproxy (SetDefaultProxy/GetDPUConnection) for global DPU connection access
  • Remove dead code (HandleTransferToRemoteForDPU disk-based two-phase version, never called)
  • Fix gomonkey test patching for Go 1.24 inlining

How to verify it

Verified on Cisco-8102-28FH-DPU-O (str3-8102-07) with gNMI server on port 50052 with mTLS:

grpcurl
-cert /etc/sonic/telemetry/client.cer
-key /etc/sonic/telemetry/client.key
-cacert /etc/sonic/telemetry/streamingtelemetryserver.cer
-H "x-sonic-ss-target-type: dpu"
-H "x-sonic-ss-target-index: 0"
-d '{
"local_path": "/var/tmp/build.log",
"remote_download": {
"path": "http://.......",
"protocol": "HTTP"
}
}'
localhost:50052 gnoi.file.File/TransferToRemote

File successfully transferred to DPU0 and verified via ssh admin@169.254.200.1 'md5sum /var/tmp/build.log'.


…… (#591)

* Fix TransferToRemote DPU connection: replace localhost loopback with direct DPU connection

HandleTransferToRemoteForDPUStreaming previously dialed localhost:8080
with insecure credentials to issue a File/Put RPC that the DPU proxy
would intercept and forward. This breaks when the gNMI server runs on
a different port or with TLS enabled.

Replace the loopback pattern with dpuproxy.GetDPUConnection(), which
resolves DPU info via Redis and returns a cached gRPC connection
directly to the target DPU. This eliminates the hardcoded address,
the insecure dial, and the need for DPU routing metadata headers on
the outgoing request.

Also removes HandleTransferToRemoteForDPU (disk-based two-phase
version) which was never called in production.

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>

* Fix gomonkey inlining issue with NewFileClient on Go 1.24

Extract gnoi_file_pb.NewFileClient into a package-level variable so
tests can patch it via ApplyGlobalVar instead of ApplyFunc. The generated
protobuf function is tiny and gets inlined by Go 1.24, which defeats
gomonkey's function-level patching and causes nil pointer panics in CI.

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>

---------

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
@hdwhdw hdwhdw requested a review from prsunny February 26, 2026 15:39
@prsunny
Copy link
Copy Markdown

prsunny commented Feb 26, 2026

@prabhataravind for viz

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.

2 participants