[PR #6802] [client] Preserve firewall authorization in connection marks #29917

Open
opened 2026-08-05 08:09:24 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/6802

State: open
Merged: No


Describe your changes

Persist NetBird firewall authorization and routed-network marks in conntrack instead of relying on mutable per-packet marks. The DNAT guard now checks connection marks, so kube-router, kube-proxy, and other netfilter consumers can modify packet marks without causing authorized traffic to be dropped.

Both iptables and nftables backends are updated. Routed marks remain classified correctly by netflow.

Fixes #6022

Stack

  • This PR is independent

Checklist

  • I have performed a self-review of my own code
  • I have tested the changes locally
  • I have added or updated tests where applicable
  • I have checked for breaking changes

Documentation

  • Documentation is not needed

Validation

  • Cross-compiled Linux test binaries for ./client/firewall/iptables
  • Cross-compiled Linux test binaries for ./client/firewall/nftables
  • Cross-compiled Linux test binaries for ./client/internal/netflow/conntrack
  • git diff --check

Runtime netfilter tests require a Linux environment.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Improved firewall rule behavior for redirected, masqueraded, and return traffic by switching NAT/ACL handling to use connection (conntrack) marks consistently.
    • Strengthened DNAT guard logic to drop incorrectly marked redirected traffic.
    • Improved NetFlow direction detection for firewall-managed connections based on these connection marks.
  • Tests
    • Added/updated Linux-focused tests to verify connection-mark-based rule generation and NAT matching/cleanup behavior.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6802 **State:** open **Merged:** No --- ## Describe your changes Persist NetBird firewall authorization and routed-network marks in conntrack instead of relying on mutable per-packet marks. The DNAT guard now checks connection marks, so kube-router, kube-proxy, and other netfilter consumers can modify packet marks without causing authorized traffic to be dropped. Both iptables and nftables backends are updated. Routed marks remain classified correctly by netflow. ## Issue ticket number and link Fixes #6022 ## Stack - [x] This PR is independent ## Checklist - [x] I have performed a self-review of my own code - [x] I have tested the changes locally - [x] I have added or updated tests where applicable - [x] I have checked for breaking changes ## Documentation - [x] Documentation is **not needed** ## Validation - Cross-compiled Linux test binaries for `./client/firewall/iptables` - Cross-compiled Linux test binaries for `./client/firewall/nftables` - Cross-compiled Linux test binaries for `./client/internal/netflow/conntrack` - `git diff --check` Runtime netfilter tests require a Linux environment. <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6802"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1786808434&installation_id=146802194&pr_number=6802&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6802&signature=9712e419e1e17cb5d6a34ad77c961ff3629293f35137fc42a143fa54931b1fa6"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>/codesmith</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved firewall rule behavior for redirected, masqueraded, and return traffic by switching NAT/ACL handling to use connection (conntrack) marks consistently. * Strengthened DNAT guard logic to drop incorrectly marked redirected traffic. * Improved NetFlow direction detection for firewall-managed connections based on these connection marks. * **Tests** * Added/updated Linux-focused tests to verify connection-mark-based rule generation and NAT matching/cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 08:09:24 -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#29917