[PR #5401] [client] Fall back to individual IP rules when ipset is unavailable #25776

Open
opened 2026-08-05 07:06:27 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5401
Author: @zerotohero
Created: 2/19/2026
Status: 🔄 Open

Base: mainHead: fix/ipset-fallback-and-notrack-nonfatal


📝 Commits (2)

  • 469b7c0 [client] Fall back to individual IP rules when ipset is unavailable
  • 52d2c02 ci: retrigger flaky DNS test and FreeBSD pkg infra failure

📊 Changes

1 file changed (+28 additions, -7 deletions)

View changed files

📝 client/firewall/iptables/acl_linux.go (+28 -7)

📄 Description

Describe your changes

On systems where the ip_set kernel module is not available (e.g. Nvidia Jetson with Tegra kernels), ipset creation fails which causes AddPeerFiltering to return an error. The ACL manager's applyPeerACLs then calls rollBack(), deleting all rules from NETBIRD-ACL-INPUT and leaving it empty. Since the INPUT chain has a DROP catch-all for the WireGuard interface, all tunnel traffic is blocked.

Root cause

  1. ip_set kernel module missing → createIPSet() fails via netlink
  2. AddPeerFiltering returns error → applyPeerACLs calls rollBack()
  3. rollBack() deletes all newly added rules → NETBIRD-ACL-INPUT left empty
  4. INPUT chain: ESTABLISHED/RELATED → ACCEPT, jump NETBIRD-ACL-INPUT (empty), DROP -i wt0
  5. All new WireGuard connections dropped

Changes

File Change
client/firewall/iptables/acl_linux.go Add ipsetSupported field; on first createIPSet failure, fall back to individual -s ip rules

Note: this PR originally also made initNoTrackChain/initNoTrackChains failures non-fatal. That part was superseded by #5621, which landed an equivalent fix upstream using rawSupported. After rebasing onto current main, only the ipset fallback remains — and it is still needed on Jetson Tegra kernels (confirmed 2026-04).

No existing issue — discovered on Nvidia Jetson Orin AGX devices (Tegra kernel 5.15.148) where ip_set and iptable_raw kernel modules are absent.

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)

This is an internal resilience fix — graceful fallback when the ip_set kernel module is unavailable. No user-facing configuration or behavior changes that require documentation.

Test plan

  • Verify on system with ip_set module: ipset behavior unchanged, rules use -m set --set as before
  • Verify on system without ip_set module (e.g. Nvidia Jetson Tegra kernel): NETBIRD-ACL-INPUT populated with individual -s <ip> ACCEPT rules instead of empty chain, and inbound tunnel traffic is no longer dropped
  • Verify log contains `"ipset not supported, falling back to individual IP rules"` warning on affected systems

Summary by CodeRabbit

  • Bug Fixes
    • Firewall ACL now detects whether optimized IP-set support is available and automatically falls back to per-IP matching when not, ensuring rules are applied even if optimizations fail.
    • Streamlined error handling and logging for firewall rule operations; failures during set operations are logged consistently and trigger safe fallback behavior.

Review Change Stack


🔄 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/5401 **Author:** [@zerotohero](https://github.com/zerotohero) **Created:** 2/19/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ipset-fallback-and-notrack-nonfatal` --- ### 📝 Commits (2) - [`469b7c0`](https://github.com/netbirdio/netbird/commit/469b7c03c2035ba439baa738ee93f8e7c5cf47d3) [client] Fall back to individual IP rules when ipset is unavailable - [`52d2c02`](https://github.com/netbirdio/netbird/commit/52d2c029d693d08cbb0c3a3e8fadb6aa818ea9ea) ci: retrigger flaky DNS test and FreeBSD pkg infra failure ### 📊 Changes **1 file changed** (+28 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `client/firewall/iptables/acl_linux.go` (+28 -7) </details> ### 📄 Description ## Describe your changes On systems where the `ip_set` kernel module is not available (e.g. Nvidia Jetson with Tegra kernels), ipset creation fails which causes `AddPeerFiltering` to return an error. The ACL manager's `applyPeerACLs` then calls `rollBack()`, deleting all rules from `NETBIRD-ACL-INPUT` and leaving it empty. Since the INPUT chain has a DROP catch-all for the WireGuard interface, **all tunnel traffic is blocked**. ### Root cause 1. `ip_set` kernel module missing → `createIPSet()` fails via netlink 2. `AddPeerFiltering` returns error → `applyPeerACLs` calls `rollBack()` 3. `rollBack()` deletes all newly added rules → `NETBIRD-ACL-INPUT` left empty 4. INPUT chain: `ESTABLISHED/RELATED → ACCEPT`, `jump NETBIRD-ACL-INPUT` (empty), `DROP -i wt0` 5. All new WireGuard connections dropped ### Changes | File | Change | |------|--------| | `client/firewall/iptables/acl_linux.go` | Add `ipsetSupported` field; on first `createIPSet` failure, fall back to individual `-s ip` rules | > Note: this PR originally also made `initNoTrackChain`/`initNoTrackChains` failures non-fatal. That part was superseded by #5621, which landed an equivalent fix upstream using `rawSupported`. After rebasing onto current `main`, only the ipset fallback remains — and it is still needed on Jetson Tegra kernels (confirmed 2026-04). ## Issue ticket number and link No existing issue — discovered on Nvidia Jetson Orin AGX devices (Tegra kernel 5.15.148) where `ip_set` and `iptable_raw` kernel modules are absent. ## Stack <!-- branch-stack --> ### Checklist - [x] 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](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) This is an internal resilience fix — graceful fallback when the `ip_set` kernel module is unavailable. No user-facing configuration or behavior changes that require documentation. ## Test plan - [x] Verify on system with `ip_set` module: ipset behavior unchanged, rules use `-m set --set` as before - [x] Verify on system without `ip_set` module (e.g. Nvidia Jetson Tegra kernel): `NETBIRD-ACL-INPUT` populated with individual `-s <ip>` ACCEPT rules instead of empty chain, and inbound tunnel traffic is no longer dropped - [x] Verify log contains \`"ipset not supported, falling back to individual IP rules"\` warning on affected systems <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Firewall ACL now detects whether optimized IP-set support is available and automatically falls back to per-IP matching when not, ensuring rules are applied even if optimizations fail. * Streamlined error handling and logging for firewall rule operations; failures during set operations are logged consistently and trigger safe fallback behavior. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/netbird/pull/5401?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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:06:27 -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#25776