[PR #5300] [CLOSED] [client] Fix port reuse in tcp conntrack #27639

Closed
opened 2026-08-05 07:09:00 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5300
Author: @lixmal
Created: 2/12/2026
Status: Closed

Base: mainHead: fix-reused-ports


📝 Commits (3)

  • 09f538e Treated tombstoned conns as new
  • 6df3b6d Handle TCP port reuse for TIME-WAIT connections
  • e671e2d Merge branch 'main' into fix-reused-ports

📄 Description

Describe your changes

In the userspace filter TCP conntrack, if a port was reused, it extended a connection's lifetime whereas it should treat this as a new connection (for SYN).

Also adds a NB_USPFILTER_LOG_BUFFER env var to increase the uspfilter log buffer

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)

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

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

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved connection tracking so closed or TIME-WAITed connections are correctly treated as superseded, enabling reliable port reuse and preventing stale entries from blocking new connections.
  • Tests

    • Added extensive tests covering port reuse, tombstone/TIME-WAIT scenarios, retransmits, and edge-case packet timing.
  • Chores

    • Made log buffer size configurable via an environment variable.

🔄 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/5300 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 2/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-reused-ports` --- ### 📝 Commits (3) - [`09f538e`](https://github.com/netbirdio/netbird/commit/09f538eb308c4ad71b6b6a8d30158ad5132db09f) Treated tombstoned conns as new - [`6df3b6d`](https://github.com/netbirdio/netbird/commit/6df3b6de54fb00505b87fe4c0eac0d25dacef098) Handle TCP port reuse for TIME-WAIT connections - [`e671e2d`](https://github.com/netbirdio/netbird/commit/e671e2daeb1ecc9ebc2cd89624a2445ea0e18fee) Merge branch 'main' into fix-reused-ports ### 📄 Description ## Describe your changes ## Issue ticket number and link In the userspace filter TCP conntrack, if a port was reused, it extended a connection's lifetime whereas it should treat this as a new connection (for `SYN`). Also adds a `NB_USPFILTER_LOG_BUFFER` env var to increase the uspfilter log buffer ## 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) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit * **Bug Fixes** * Improved connection tracking so closed or TIME-WAITed connections are correctly treated as superseded, enabling reliable port reuse and preventing stale entries from blocking new connections. * **Tests** * Added extensive tests covering port reuse, tombstone/TIME-WAIT scenarios, retransmits, and edge-case packet timing. * **Chores** * Made log buffer size configurable via an environment variable. <!-- 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 07:09:00 -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#27639