netbirdio/netbird · error

list rules

Error message

list rules: %w

What it means

Reading the rules of a chain failed while existingNetbirdRulesInChain was collecting NetBird-owned UserData tags. Because InsertRule is purely additive and deduplication depends on this set, callers must bail out on error instead of proceeding — otherwise duplicate accept/jump rules would be appended to the chain.

Solutions

  1. Retry the rule listing
  2. Check connection health to the nftables subsystem
  3. Skip insertion this cycle and retry on the next reconciliation
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/firewall/nftables/router_linux.go:1274 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/c427fb9f95d451e8. Report an issue: GitHub.

Appendix: source

Thrown at client/firewall/nftables/router_linux.go:1274

	}
	r.conn.InsertRule(&nftables.Rule{
		Table: chain.Table,
		Chain: chain,
		Exprs: []expr.Any{
			&expr.Meta{Key: expr.MetaKeyIIFNAME, Register: 1},
			&expr.Cmp{Op: expr.CmpOpEq, Register: 1, Data: intf},
			&expr.Counter{},
			&expr.Verdict{Kind: expr.VerdictAccept},
		},
		UserData: []byte(userDataAcceptInputRule),
	})
}

// existingNetbirdRulesInChain returns the set of netbird-owned UserData tags present in a chain; callers must bail on error since InsertRule is additive.
func (r *router) existingNetbirdRulesInChain(chain *nftables.Chain) (map[string]bool, error) {
	rules, err := r.conn.GetRules(chain.Table, chain)
	if err != nil {
		return nil, fmt.Errorf("list rules: %w", err)
	}
	present := map[string]bool{}
	for _, rule := range rules {
		if !isNetbirdAcceptRuleTag(rule.UserData) {
			continue
		}
		present[string(rule.UserData)] = true
	}
	return present, nil
}

func isNetbirdAcceptRuleTag(userData []byte) bool {
	switch string(userData) {
	case userDataAcceptForwardRuleIif,
		userDataAcceptForwardRuleOif,
		userDataAcceptInputRule:
		return true
	}

View on GitHub (pinned to 93e97f4bf1)