netbirdio/netbird · error

refresh rules map

Error message

refresh rules map: %w

What it means

Rebuilding the in-memory rule map from the kernel failed at the start of DeleteRouteRule. The refresh reads live rule handles; if it fails, deletion cannot proceed safely because the cached handle may be stale.

Solutions

  1. Retry the delete after a successful refresh
  2. Check nftables connection health
  3. Recreate the router if the table was replaced externally
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

	if r.af.tableFamily == nftables.TableFamilyIPv6 {
		return iptables.ProtocolIPv6
	}
	return iptables.ProtocolIPv4
}

func (r *router) hasRule(id string) bool {
	_, ok := r.rules[id]
	return ok
}

func (r *router) hasDNATRule(id string) bool {
	_, ok := r.rules[id+dnatSuffix]
	return ok
}

func (r *router) DeleteRouteRule(rule firewall.Rule) error {
	if err := r.refreshRulesMap(); err != nil {
		return fmt.Errorf(refreshRulesMapError, err)
	}

	ruleKey := rule.ID()
	nftRule, exists := r.rules[ruleKey]
	if !exists {
		log.Debugf("route rule %s not found", ruleKey)
		return nil
	}

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

View on GitHub (pinned to 93e97f4bf1)