netbirdio/netbird · error

remove legacy forwarding rule

Error message

remove legacy forwarding rule %s -> %s: %w

What it means

Deleting the legacy-format forwarding nftables rule for a router pair failed in removeLegacyRouteRule. Zero-handle entries are treated as stale and dropped without kernel interaction; a real DelRule failure leaves the legacy rule live in the kernel and is returned so callers know forwarding for that pair persists.

Solutions

  1. Refresh handles and retry the removal
  2. Delete the rule manually via nft using its key
  3. Continue migration; the next reset removes leftover rules
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/firewall/nftables/router_linux.go:1017 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/2aca98918c68eaa4. Report an issue: GitHub.

Appendix: source

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

func (r *router) removeLegacyRouteRule(pair firewall.RouterPair) error {
	ruleKey := firewall.GenKey(firewall.ForwardingFormat, pair)

	rule, exists := r.rules[ruleKey]
	if !exists {
		return nil
	}

	if rule.Handle == 0 {
		log.Warnf("legacy forwarding rule %s has no handle, removing stale entry", ruleKey)
		if err := r.decrementSetCounter(rule); err != nil {
			log.Warnf("decrement set counter for stale rule %s: %v", ruleKey, err)
		}
		delete(r.rules, ruleKey)
		return nil
	}

	if err := r.conn.DelRule(rule); err != nil {
		return fmt.Errorf("remove legacy forwarding rule %s -> %s: %w", pair.Source, pair.Destination, err)
	}

	log.Debugf("removed legacy forwarding rule %s -> %s", pair.Source, pair.Destination)

	delete(r.rules, ruleKey)

	if err := r.decrementSetCounter(rule); err != nil {
		return fmt.Errorf("decrement set counter: %w", err)
	}

	return nil
}

// GetLegacyManagement returns the route manager's legacy management mode
func (r *router) GetLegacyManagement() bool {
	return r.legacyManagement
}

View on GitHub (pinned to 93e97f4bf1)