Skip to content

telemetry: resolve no-TLS link-local bind by interface#721

Open
hdwhdw wants to merge 3 commits into
sonic-net:masterfrom
hdwhdw:fix/28540-notls-link-local
Open

telemetry: resolve no-TLS link-local bind by interface#721
hdwhdw wants to merge 3 commits into
sonic-net:masterfrom
hdwhdw:fix/28540-notls-link-local

Conversation

@hdwhdw

@hdwhdw hdwhdw commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Why I did it

SmartSwitch DPUs expose plaintext gNMI/gNOI only on their chassis-internal
IPv4 link-local midplane. The NPU proxy must reach that address, but the current
--noTLS validation permits loopback addresses only. This makes it impossible
to restore proxy connectivity without removing the cleartext bind protection
entirely.

This is the binary-side dependency for
sonic-net/sonic-buildimage#28540.

How I did it

  • Added an explicit, default-off --no_tls_link_local_interface option.
  • Kept loopback as the default requirement for --noTLS.
  • Resolve exactly one IPv4 link-local address from the named interface and bind
    that concrete address.
  • Wait up to 30 seconds for address readiness, then fail nonzero if the address
    remains unavailable or ambiguous.
  • Reject simultaneous explicit bind-address configuration and use with a
    non-default gNMI VRF.
  • Added deterministic tests for arguments, delayed readiness, timeout, and
    zero/one/multiple link-local address selection.

How to verify it

  • Native arm64 SONiC package and container build succeeded, including gofmt
    validation and compilation of the telemetry binary.
  • On a physical SmartSwitch DPU, the built binary resolved the concrete
    eth0-midplane IPv4 link-local address itself.
  • With the dependent launch-script change, both DPU services bound only to the
    concrete midplane link-local address. Direct gNOI System.Time and the real
    NPU UDS metadata-routed DPUProxy call succeeded.
  • Negative TCP probes confirmed the services were not listening on the DPU
    management address or loopback.

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

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605

Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): N/A
Failure type: regression

Tested branch

  • master
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605
  • N/A

Test result

  • master: native arm64 build passed; physical SmartSwitch direct and proxied
    gNOI validation passed.

Description for the changelog

Allow explicitly selected plaintext gNMI binding to an interface's IPv4 link-local address.

Link to config_db schema for YANG module changes

N/A

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Copilot AI review requested due to automatic review settings July 22, 2026 04:17
@azure-pipelines

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

Copilot AI 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.

Pull request overview

This PR updates the telemetry server’s --noTLS bind-address safety checks to support SmartSwitch DPU deployments that must expose plaintext gNMI/gNOI only on a chassis-internal IPv4 link-local midplane address, while keeping the existing “loopback-only” protection as the default.

Changes:

  • Introduces a default-off --allow_no_tls_link_local flag to explicitly opt into plaintext binding on IPv4 link-local unicast addresses.
  • Extends --noTLS validation to permit IPv4 link-local only when opted in, and rejects using that opt-in with a non-default --gnmi_vrf.
  • Expands unit tests to cover allowed/rejected combinations for loopback, IPv4 link-local, private IPv4, and IPv6 link-local addresses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
telemetry/telemetry.go Adds the new opt-in flag and enforces updated --noTLS bind-address/VRF validation rules.
telemetry/telemetry_test.go Updates and extends the --noTLS bind-address validation test matrix for the new behavior.

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Copilot AI review requested due to automatic review settings July 22, 2026 14:54
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread telemetry/telemetry.go
Comment on lines 188 to 191
Insecure: fs.Bool("insecure", false, "Skip providing TLS cert and key, for testing only!"),
NoTLS: fs.Bool("noTLS", false, "disable TLS, for testing only!"),
NoTLSLinkLocalInterface: fs.String("no_tls_link_local_interface", "", "Bind --noTLS to the only IPv4 link-local address on this interface."),
AllowNoClientCert: fs.Bool("allow_no_client_auth", false, "When set, telemetry server will request but not require a client certificate."),
Comment thread telemetry/telemetry.go
Comment on lines +282 to +285
ip := net.ParseIP(*telemetryCfg.BindAddress)
if ip == nil || !ip.IsLoopback() {
return nil, nil, fmt.Errorf("--noTLS requires --bind_address to be a loopback address (e.g. 127.0.0.1 or ::1)")
}
Comment thread telemetry/telemetry.go
Comment on lines +396 to +403
func selectIPv4LinkLocalAddress(interfaceName string, addresses []net.Addr) (string, error) {
var linkLocalAddresses []string
for _, address := range addresses {
ip, _, err := net.ParseCIDR(address.String())
if err == nil && ip.To4() != nil && ip.IsLinkLocalUnicast() {
linkLocalAddresses = append(linkLocalAddresses, ip.String())
}
}
Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Copilot AI review requested due to automatic review settings July 22, 2026 16:23
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

Copilot AI 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.

Pull request overview

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

Comments suppressed due to low confidence (1)

telemetry/telemetry.go:406

  • selectIPv4LinkLocalAddress currently parses each net.Addr via net.ParseCIDR(address.String()). If interface Addrs include *net.IPAddr entries (no CIDR mask in String()), ParseCIDR fails and the address is silently ignored, which can incorrectly report 0 link-local addresses and trigger an unnecessary timeout/failure. Consider handling *net.IPNet/*net.IPAddr directly (with a String()-parse fallback only if needed).
	for _, address := range addresses {
		ip, _, err := net.ParseCIDR(address.String())
		if err == nil && ip.To4() != nil && ip.IsLinkLocalUnicast() {
			linkLocalAddresses = append(linkLocalAddresses, ip.String())
		}

Comment thread telemetry/telemetry.go
} else {
ip := net.ParseIP(*telemetryCfg.BindAddress)
if ip == nil || !ip.IsLoopback() {
return nil, nil, fmt.Errorf("--noTLS requires --bind_address to be a loopback address (e.g. 127.0.0.1 or ::1)")
@hdwhdw hdwhdw changed the title telemetry: allow explicit no-TLS link-local bind telemetry: resolve no-TLS link-local bind by interface Jul 22, 2026
@hdwhdw
hdwhdw requested a review from qiluo-msft July 22, 2026 18:34
@donghaolicd
donghaolicd self-requested a review July 23, 2026 00:04
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.

3 participants