netbirdio/netbird · error

convert protocol to number

Error message

convert protocol to number: %w

What it means

Converting the firewall protocol enum to an L4 protocol number failed for this rule. Only reached for non-ALL protocols; means the protoNum mapping rejected the value, an unsupported or invalid protocol for the address family.

Solutions

  1. Check the protocol value sent by management
  2. Ensure ICMPv6 vs ICMP mapping matches the family
  3. Reject unknown protocols before calling the router
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

	}

	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,
			Register: 1,
			Data:     []byte{protoNum},
		})

		exprs = append(exprs, applyPort(sPort, true)...)
		exprs = append(exprs, applyPort(dPort, false)...)
	}

	exprs = append(exprs, &expr.Counter{})

	var verdict expr.VerdictKind
	if action == firewall.ActionAccept {
		verdict = expr.VerdictAccept
	} else {

View on GitHub (pinned to 93e97f4bf1)