[PR #6674] [MERGED] [client] Fix forwarder peers never excluded from lazy connections #28733

Closed
opened 2026-08-05 08:06:51 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6674
Author: @riccardomanfrin
Created: 7/6/2026
Status: Merged
Merged: 7/14/2026
Merged by: @riccardomanfrin

Base: mainHead: fix/forwarders_exclusion_from_lazy_conn


📝 Commits (4)

  • 8fb5171 [client] Extract peerRoutesAddr helper in toExcludedLazyPeers
  • 4bb9b81 [client] Add failing test for lazy-conn forward-target exclusion
  • e509b7b [client] Fix lazy-conn exclusion for ingress forward peers
  • de3f0bf [client] Reuse parsed AllowedIPs from peerStore in lazy exclusion

📊 Changes

2 files changed (+114 additions, -5 deletions)

View changed files

📝 client/internal/engine.go (+27 -5)
client/internal/engine_lazy_exclude_test.go (+87 -0)

📄 Description

Describe your changes

toExcludedLazyPeers compared each peer's AllowedIPs (CIDR, e.g. an overlay IP as /32) against ForwardRule.TranslatedAddress.String() (unmasked), so the match never fired and forward-target peers were never excluded from lazy connections — inbound forwarded traffic can't wake a lazy peer, so those peers must stay permanent. Extracted a peerRoutesAddr helper and switched to prefix containment.

Internal bug found while investigating lazy-connection DNS/forwarding breakage. Broken line on main: https://github.com/netbirdio/netbird/blob/main/client/internal/engine.go#L2568

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal lazy-connection exclusion fix. No public API, config, or CLI change.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved inbound forwarding peer exclusion by matching forwarded targets against peers’ routed address ranges (prefix containment) instead of relying on exact string matches, reducing missed exclusions for IPv4 and IPv6.
  • Tests
    • Added unit tests covering address/prefix membership behavior (IPv4/IPv6, matching and non-matching cases) and validating forward-target exclusion.
    • Added coverage for handling when no forward rules are provided.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6674 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 7/6/2026 **Status:** ✅ Merged **Merged:** 7/14/2026 **Merged by:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Base:** `main` ← **Head:** `fix/forwarders_exclusion_from_lazy_conn` --- ### 📝 Commits (4) - [`8fb5171`](https://github.com/netbirdio/netbird/commit/8fb51711641705d4579cdbf55c6a70a31568254c) [client] Extract peerRoutesAddr helper in toExcludedLazyPeers - [`4bb9b81`](https://github.com/netbirdio/netbird/commit/4bb9b81c6ee9086dd2e52197a796b4103e7c12c7) [client] Add failing test for lazy-conn forward-target exclusion - [`e509b7b`](https://github.com/netbirdio/netbird/commit/e509b7b2c5088d408e6a073db4584edff422aedc) [client] Fix lazy-conn exclusion for ingress forward peers - [`de3f0bf`](https://github.com/netbirdio/netbird/commit/de3f0bf77f2e16801eea84262ea48286d9c0c543) [client] Reuse parsed AllowedIPs from peerStore in lazy exclusion ### 📊 Changes **2 files changed** (+114 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/engine.go` (+27 -5) ➕ `client/internal/engine_lazy_exclude_test.go` (+87 -0) </details> ### 📄 Description ## Describe your changes `toExcludedLazyPeers` compared each peer's `AllowedIPs` (CIDR, e.g. an overlay IP as `/32`) against `ForwardRule.TranslatedAddress.String()` (unmasked), so the match never fired and forward-target peers were **never** excluded from lazy connections — inbound forwarded traffic can't wake a lazy peer, so those peers must stay permanent. Extracted a `peerRoutesAddr` helper and switched to prefix containment. ## Issue ticket number and link Internal bug found while investigating lazy-connection DNS/forwarding breakage. Broken line on main: https://github.com/netbirdio/netbird/blob/main/client/internal/engine.go#L2568 ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal lazy-connection exclusion fix. No public API, config, or CLI change. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved inbound forwarding peer exclusion by matching forwarded targets against peers’ routed address ranges (prefix containment) instead of relying on exact string matches, reducing missed exclusions for IPv4 and IPv6. * **Tests** * Added unit tests covering address/prefix membership behavior (IPv4/IPv6, matching and non-matching cases) and validating forward-target exclusion. * Added coverage for handling when no forward rules are provided. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:06:51 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28733