Skip to content

[meshnet] Replace veth + libpcap with TAP devices for gRPC wires - #731

Open
kraney wants to merge 3 commits into
openconfig:mainfrom
kraney:meshnet-tap
Open

[meshnet] Replace veth + libpcap with TAP devices for gRPC wires#731
kraney wants to merge 3 commits into
openconfig:mainfrom
kraney:meshnet-tap

Conversation

@kraney

@kraney kraney commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
Replace the veth pair and libpcap packet capture implementation in meshnetd
with persistent Linux TAP devices created directly inside container network
namespaces.

Reason for Change:
- Eliminates packet loss under high traffic loads caused by libpcap's kernel-
  to-userspace drop policy.
- Provides native Linux socket buffer flow control and backpressure (`txqueuelen`)
  up to the container application when gRPC processing falls behind.
- Guarantees protocol transparent packet handling (including LACP and LLDP frames).
- Ensures process crash resilience: setting `TUNSETPERSIST=1` keeps TAP interfaces
  alive in the container netns across daemon restarts without link flaps.
- Synchronizes CNI plugin pod readiness with complete end-to-end gRPC wire setup,
  preventing test/ping race conditions upon pod startup.
- Eliminates CGO and `libpcap-dev` build dependencies, producing a pure Go static
  binary (`CGO_ENABLED=0`).

Key Changes:
- Added `CreateOrAttachTAP` in `wireutil` using `TUNSETIFF` & `TUNSETPERSIST`.
- Replaced `pcap.Handle` with `*os.File` in `gwire_map.go`, `grpcwire.go`, and `handler.go`.
- Updated `ReconcilePodLinks` in `controller.go` to use TAP interfaces directly without
  host-side veth creation.
- Updated `GRPCWireExists` and CNI `cmdAdd` readiness check to block until gRPC wire
  handshakes are fully established.
- Removed `libpcap-dev` and updated Dockerfile to build `meshnetd` with `CGO_ENABLED=0`.

kraney added 3 commits July 31, 2026 20:31
Replace the veth pair and libpcap packet capture implementation in meshnetd
with persistent Linux TAP devices created directly inside container network
namespaces.

Reason for Change:
- Eliminates packet loss under high traffic loads caused by libpcap's kernel-
  to-userspace drop policy.
- Provides native Linux socket buffer flow control and backpressure (`txqueuelen`)
  up to the container application when gRPC processing falls behind.
- Guarantees protocol transparent packet handling (including LACP and LLDP frames).
- Ensures process crash resilience: setting `TUNSETPERSIST=1` keeps TAP interfaces
  alive in the container netns across daemon restarts without link flaps.
- Synchronizes CNI plugin pod readiness with complete end-to-end gRPC wire setup,
  preventing test/ping race conditions upon pod startup.
- Eliminates CGO and `libpcap-dev` build dependencies, producing a pure Go static
  binary (`CGO_ENABLED=0`).

Key Changes:
- Added `CreateOrAttachTAP` in `wireutil` using `TUNSETIFF` & `TUNSETPERSIST`.
- Replaced `pcap.Handle` with `*os.File` in `gwire_map.go`, `grpcwire.go`, and `handler.go`.
- Updated `ReconcilePodLinks` in `controller.go` to use TAP interfaces directly without
  host-side veth creation.
- Updated `GRPCWireExists` and CNI `cmdAdd` readiness check to block until gRPC wire
  handshakes are fully established.
- Removed `libpcap-dev` and updated Dockerfile to build `meshnetd` with `CGO_ENABLED=0`.
Add package & public method comments, and format Go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant