[PR #991] [MERGED] Improve userspace filter performance #13210

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/991
Author: @pascal-fischer
Created: 6/28/2023
Status: Merged
Merged: 7/12/2023
Merged by: @pascal-fischer

Base: mainHead: fix/improve_uspfilter_performance


📝 Commits (7)

📊 Changes

2 files changed (+119 additions, -109 deletions)

View changed files

📝 client/firewall/uspfilter/uspfilter.go (+94 -80)
📝 client/firewall/uspfilter/uspfilter_test.go (+25 -29)

📄 Description

Describe your changes

Switched rule set from array to map (as lookup table grouped by IP) to reduce number of rules checked for each packet when filtering) this way increasing throughput.

To test:

  • throughput when thousands of rules active
  • startup time when thousands of rules active
  • memory consumption between old and new impl.
  • functionality

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)
  • Extended the README / documentation, if necessary

🔄 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/991 **Author:** [@pascal-fischer](https://github.com/pascal-fischer) **Created:** 6/28/2023 **Status:** ✅ Merged **Merged:** 7/12/2023 **Merged by:** [@pascal-fischer](https://github.com/pascal-fischer) **Base:** `main` ← **Head:** `fix/improve_uspfilter_performance` --- ### 📝 Commits (7) - [`d96f882`](https://github.com/netbirdio/netbird/commit/d96f882acb2576d329f2eb8a6c7340ccf6c5c701) seems to work but delete fails - [`b39ffef`](https://github.com/netbirdio/netbird/commit/b39ffef22c8855c08fd35029aaedd91d9f50d642) add missing all rule - [`5187865`](https://github.com/netbirdio/netbird/commit/51878659f8382794a01ecb7cfc0517e7db55bc5b) remove Rule index map - [`33a155d`](https://github.com/netbirdio/netbird/commit/33a155d9aa94024c6e760203c272ab45286f66d6) fix all rules check - [`54fe05f`](https://github.com/netbirdio/netbird/commit/54fe05f6d86180500a2efe9cb08ed81ae6377ebb) fix test - [`e074c24`](https://github.com/netbirdio/netbird/commit/e074c244878ec04d5cbf20bf76d5b885745c829b) add type for RuleSet - [`6e264d9`](https://github.com/netbirdio/netbird/commit/6e264d9de704b4ae50ef462e3d8e32ea2a575fa2) fix rule order to solve DNS resolver issue ### 📊 Changes **2 files changed** (+119 additions, -109 deletions) <details> <summary>View changed files</summary> 📝 `client/firewall/uspfilter/uspfilter.go` (+94 -80) 📝 `client/firewall/uspfilter/uspfilter_test.go` (+25 -29) </details> ### 📄 Description ## Describe your changes Switched rule set from array to map (as lookup table grouped by IP) to reduce number of rules checked for each packet when filtering) this way increasing throughput. To test: - throughput when thousands of rules active - startup time when thousands of rules active - memory consumption between old and new impl. - functionality ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <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 02:07:46 -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#13210