netbirdio/netbird · error

apply source

Error message

apply source: %w

What it means

Translating the source network of a route rule into nftables expressions failed in applyNetwork. Fires when a single source prefix or a prefix set cannot be represented, e.g. a malformed prefix or set overflow.

Solutions

  1. Validate source prefixes before building the rule
  2. Split large source lists below the ipset prefix limit
  3. Check address family matches the router (v4 vs v6)
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

	chain := r.chains[chainNameRoutingFw]
	var exprs []expr.Any

	var source firewall.Network
	switch {
	case len(sources) == 1 && sources[0].Bits() == 0:
		// If it's 0.0.0.0/0, we don't need to add any source matching
	case len(sources) == 1:
		// If there's only one source, we can use it directly
		source.Prefix = sources[0]
	default:
		// If there are multiple sources, use a set
		source.Set = firewall.NewPrefixSet(sources)
	}

	sourceExp, err := r.applyNetwork(source, sources, true)
	if err != nil {
		return nil, fmt.Errorf("apply source: %w", err)
	}
	exprs = append(exprs, sourceExp...)

	destExp, err := r.applyNetwork(destination, nil, false)
	if err != nil {
		return nil, fmt.Errorf("apply destination: %w", err)
	}
	exprs = append(exprs, destExp...)

	// Handle protocol
	if proto != firewall.ProtocolALL {
		protoNum, err := r.af.protoNum(proto)
		if err != nil {
			return nil, fmt.Errorf("convert protocol to number: %w", err)
		}
		exprs = append(exprs, &expr.Meta{Key: expr.MetaKeyL4PROTO, Register: 1})
		exprs = append(exprs, &expr.Cmp{
			Op:       expr.CmpOpEq,

View on GitHub (pinned to 93e97f4bf1)