Skip to content

feat(ipv6): add IPv6 address family detection and nvme-cli IPv6 fixes#276

Merged
derekbit merged 1 commit into
longhorn:mainfrom
COLDTURNIP:10928-v2-engine-ipv6
Apr 22, 2026
Merged

feat(ipv6): add IPv6 address family detection and nvme-cli IPv6 fixes#276
derekbit merged 1 commit into
longhorn:mainfrom
COLDTURNIP:10928-v2-engine-ipv6

Conversation

@COLDTURNIP
Copy link
Copy Markdown
Member

Which issue(s) this PR fixes:

  • Export DetectAddressFamily() in pkg/spdk/client for adrfam auto-detection
  • Replace hardcoded NvmeAddressFamilyIPv4 in NvmfSubsystemAddListener and StartExposeBdevWithANAState with dynamic detection via DetectAddressFamily()
  • Add normalizeNvmeAddr() to strip brackets for nvme-cli -a flag
  • Fix strings.Split -> strings.SplitN in GetIPAndPortFromControllerAddress to handle IPv6 addresses containing colons

Issue longhorn/longhorn#10928

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

@COLDTURNIP COLDTURNIP requested review from a team and Copilot April 22, 2026 04:16
@COLDTURNIP COLDTURNIP self-assigned this Apr 22, 2026
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 improves NVMe/TCP IPv6 support across the SPDK client and nvme-cli initiator integration, adding address-family auto-detection and safer parsing/normalization for IPv6 inputs.

Changes:

  • Exported DetectAddressFamily() in pkg/spdk/client and used it to select IPv4 vs IPv6 when adding NVMe-oF listeners / setting ANA state.
  • Added normalizeNvmeAddr() to strip IPv6 brackets before passing addresses to nvme-cli -a, and added unit tests.
  • Updated GetIPAndPortFromControllerAddress() parsing to use strings.SplitN and added IPv6-oriented unit tests.

Reviewed changes

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

File Description
pkg/spdk/client/advanced.go Adds exported address-family detection and uses it for listener creation and ANA state setting.
pkg/spdk/client/advanced_test.go Adds unit tests for DetectAddressFamily().
pkg/initiator/nvmecli.go Normalizes bracketed IPv6 for nvme-cli usage and improves controller address parsing.
pkg/initiator/nvmecli_test.go Adds unit tests for IPv6 normalization and controller address parsing.

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

Comment thread pkg/spdk/client/advanced.go
Comment thread pkg/initiator/nvmecli.go Outdated
Comment thread pkg/initiator/nvmecli.go Outdated
COLDTURNIP added a commit to COLDTURNIP/longhorn-go-spdk-helper that referenced this pull request Apr 22, 2026
- Export DetectAddressFamily() in pkg/spdk/client for adrfam auto-detection
- Replace hardcoded NvmeAddressFamilyIPv4 in StartExposeBdev/StartExposeBdevWithANAState
- Add normalizeNvmeAddr() in pkg/initiator to strip brackets from IPv6 for nvme-cli -a
- Use SplitN in GetIPAndPortFromControllerAddress to correctly split IPv6 traddr values

Address review comments (PR longhorn#276):
- DetectAddressFamily: strip brackets before net.ParseIP so [fd00::1] is handled correctly
- normalizeNvmeAddr: downgrade log from Warn to Debug (bracketed IPv6 is normal input)
- GetIPAndPortFromControllerAddress: add IPv6 example to function comment

Signed-off-by: Raphanus Lo <yunchang.lo@suse.com>
@COLDTURNIP COLDTURNIP force-pushed the 10928-v2-engine-ipv6 branch from d167ac4 to ad3285f Compare April 22, 2026 04:32
COLDTURNIP added a commit to COLDTURNIP/longhorn-go-spdk-helper that referenced this pull request Apr 22, 2026
- Export DetectAddressFamily() in pkg/spdk/client for adrfam auto-detection
- Replace hardcoded NvmeAddressFamilyIPv4 in StartExposeBdev/StartExposeBdevWithANAState
- Add NormalizeNvmeAddr() in pkg/util to strip brackets from IPv6 addresses
- Use NormalizeNvmeAddr in DetectAddressFamily and nvme-cli call sites
- Use SplitN in GetIPAndPortFromControllerAddress to correctly split IPv6 traddr values

Address review comments (PR longhorn#276):
- DetectAddressFamily: delegate bracket stripping to util.NormalizeNvmeAddr
- normalizeNvmeAddr: extracted to pkg/util as NormalizeNvmeAddr (shared across packages)
- normalizeNvmeAddr: downgrade log from Warn to Debug; removed now it is in util
- GetIPAndPortFromControllerAddress: add IPv6 example to function comment

Signed-off-by: Raphanus Lo <yunchang.lo@suse.com>
@COLDTURNIP COLDTURNIP force-pushed the 10928-v2-engine-ipv6 branch 3 times, most recently from e9c921e to e426ec6 Compare April 22, 2026 04:46
@COLDTURNIP COLDTURNIP requested a review from Copilot April 22, 2026 04:46
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

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


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

Comment thread pkg/spdk/client/advanced.go
Comment thread pkg/spdk/client/advanced.go
Comment thread pkg/spdk/client/advanced_test.go
Copy link
Copy Markdown
Member

@derekbit derekbit left a comment

Choose a reason for hiding this comment

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

In general, LGTM. The comments are more for coding style.

Comment thread pkg/util/nvme.go
Comment thread pkg/initiator/nvmecli.go
Comment thread pkg/spdk/client/advanced.go
@derekbit
Copy link
Copy Markdown
Member

After resolving comments, we can merge the PR.

Signed-off-by: Raphanus Lo <yunchang.lo@suse.com>
@COLDTURNIP COLDTURNIP force-pushed the 10928-v2-engine-ipv6 branch from ecdf1c3 to cf51c16 Compare April 22, 2026 09:05
Copy link
Copy Markdown
Member

@derekbit derekbit left a comment

Choose a reason for hiding this comment

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

LGTM

@derekbit derekbit merged commit 74dd5eb into longhorn:main Apr 22, 2026
5 checks passed
@COLDTURNIP COLDTURNIP deleted the 10928-v2-engine-ipv6 branch April 22, 2026 09:29
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