githubEdit

Parser Configuration

The parser configuration controls how Mermin's eBPF programs parse network packets, including tunnel detection, protocol parsing depth, and IPv6 extension header handling.

Overview

Mermin's parser configuration allows you to:

  • Specify ports for tunnel protocol detection (VXLAN, Geneve, WireGuard)

  • Control the maximum depth of nested protocol headers to parse

  • Enable/disable parsing of advanced IPv6 extension headers

These settings directly affect eBPF verifier complexity and can be tuned to balance visibility needs against deployment constraints.

Configuration

parser {
  # Tunnel port detection
  geneve_port = 6081
  vxlan_port = 4789
  wireguard_port = 51820
}

Configuration Options

Tunnel Port Detection

geneve_port

Type: Integer (port number) Default: 6081

UDP port number for Geneve tunnel detection.

Description:

  • Genevearrow-up-right (Generic Network Virtualization Encapsulation) is a tunneling protocol

  • IANA assigned port: 6081

  • Used by various cloud networking solutions and SDN controllers

When to customize:

  • Your environment uses non-standard Geneve port

  • Network policy requires specific port assignment

  • Conflict with other services on standard port

Example:

Custom port example:

vxlan_port

Type: Integer (port number) Default: 4789

UDP port number for VXLAN tunnel detection.

Description:

  • VXLANarrow-up-right (Virtual Extensible LAN) is a network virtualization technology

  • IANA assigned port: 4789

  • Commonly used in Kubernetes networking (Flannel, Calico, NSX-T)

When to customize:

  • Your CNI or network plugin uses non-standard VXLAN port

  • Legacy VXLAN deployments using older port assignments

  • Custom overlay network configuration

Example:

Custom port example:

wireguard_port

Type: Integer (port number) Default: 51820

UDP port number for WireGuard tunnel detection.

Description:

  • WireGuardarrow-up-right is a modern VPN protocol

  • Default port: 51820 (not IANA assigned, but widely adopted)

  • Used for secure site-to-site or pod-to-pod encrypted connections

When to customize:

  • WireGuard configured with custom listen port

  • Multiple WireGuard tunnels with different ports

  • Security requirements for non-default ports

Example:

Custom port example:

How Tunnel Parsing Works

Packet Processing Flow

  1. Outer Header Parsing:

    • Mermin's eBPF program examines the outer IP header

    • Checks UDP destination port against configured tunnel ports

  2. Tunnel Type Detection:

    • If port matches vxlan_port → Parse as VXLAN

    • If port matches geneve_port → Parse as Geneve

    • If port matches wireguard_port → Parse as WireGuard

  3. Inner Header Parsing:

    • Extract encapsulated packet

    • Parse inner IP, TCP/UDP headers

    • Generate flow records using inner headers

  4. Flow Attributes:

    • Flow records contain both outer and inner header information

    • Tunnel type is recorded in flow metadata

    • Enables tracking of overlay network traffic

Tunnel Detection Benefits

Without tunnel parsing:

  • Flows show only tunnel endpoints (node IPs)

  • Cannot see actual source/destination of encapsulated traffic

  • Limited visibility into overlay network communication

With tunnel parsing:

  • Flows show inner source/destination (pod IPs)

  • Complete visibility into overlay traffic

  • Accurate flow accounting for containerized workloads

CNI-Specific Configurations

Flannel with VXLAN

Flannel typically uses VXLAN on port 8472 (older) or 4789 (newer):

Calico with VXLAN

Calico uses standard VXLAN port when VXLAN mode is enabled:

Cilium with Geneve

Cilium can use Geneve for overlay networking:

WireGuard Encryption

If using WireGuard for pod-to-pod encryption:

NSX-T

VMware NSX-T uses Geneve:

Determining Your Configuration

Identifying VXLAN Port

Flannel:

Calico:

Identifying Geneve Port

Cilium:

NSX-T:

Identifying WireGuard Port

Multiple Tunnel Types

Some environments use multiple tunnel types simultaneously. Configure all relevant ports:

Performance Considerations

Impact of Tunnel Parsing

  • CPU Usage: Minimal overhead for tunnel header parsing

  • Memory: No additional memory required

  • Accuracy: Significantly improves flow accuracy in overlay networks

When to Disable

Tunnel parsing cannot be disabled, but misconfigured ports may cause:

  • Incorrect tunnel detection

  • Flows attributed to wrong source/destination

  • Missing inner packet information

Validation

Verify tunnel parsing is working:

Check Flow Records

Compare With/Without Tunnel Parsing

Without proper configuration:

  • Flows show: Node IP A → Node IP B (outer headers only)

  • Protocol: UDP (tunnel protocol)

  • Ports: tunnel ports (4789, 6081, etc.)

With proper configuration:

  • Flows show: Pod IP X → Pod IP Y (inner headers)

  • Protocol: TCP/UDP/ICMP (actual application protocol)

  • Ports: application ports (80, 443, etc.)

eBPF Verifier Considerations

Understanding Verifier Complexity

The Linux eBPF verifier analyzes all possible execution paths in the program to ensure safety. Parser configuration directly impacts verifier complexity:

Symptoms of verifier failure:

Resolution steps:

  1. Update kernel (if possible): Newer kernels (5.14+) have improved verifier efficiency

Standard Kubernetes (Kind, K3s, Cloud providers):

Constrained environments (older kernels, K3s on edge):

Advanced networks (SRv6, multicast, specialized):

Complete Configuration Example

Troubleshooting

Seeing Only Tunnel Endpoints in Flows

Symptoms: Flows show node IPs instead of pod IPs

Solutions:

  1. Verify tunnel port configuration matches your CNI

  2. Check CNI documentation for port settings

  3. Inspect actual tunnel traffic: tcpdump -i any -n udp port 4789

Incorrect Tunnel Detection

Symptoms: Flows misattributed or missing

Solutions:

  1. Confirm tunnel ports with CNI configuration

  2. Check for port conflicts with other services

  3. Review eBPF program logs for parsing errors

Multiple Ports for Same Protocol

If your environment uses multiple ports for the same tunnel protocol (e.g., multiple VXLAN configurations), Mermin currently supports only one port per protocol type. Choose the most commonly used port or consult support for multi-port scenarios.

Best Practices

  1. Use IANA defaults: Unless you have a specific reason, use the default ports

  2. Document customizations: If using custom ports, document why in comments

  3. Validate after changes: Test flow accuracy after modifying parser configuration

  4. Match CNI configuration: Ensure parser ports match your CNI's tunnel ports

  5. Monitor metrics: Watch for anomalies after configuration changes

Next Steps

Last updated