• Stars
    star
    2,354
  • Rank 18,687 (Top 0.4 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 29 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Packet, where are you? -- eBPF-based Linux kernel networking debugger

pwru (packet, where are you?)

logo

pwru is an eBPF-based tool for tracing network packets in the Linux kernel with advanced filtering capabilities. It allows fine-grained introspection of kernel state to facilitate debugging network connectivity issues.

The following example shows where the packets of a curl request are dropped after installing an IP tables rule:

demo

Running

Requirements

pwru requires >= 5.3 kernel to run. For --output-skb >= 5.9 kernel is required. For --backend=kprobe-multi >= 5.18 kernel is required.

debugfs has to be mounted in /sys/kernel/debug. In case the folder is empty, it can be mounted with:

mount -t debugfs none /sys/kernel/debug

The following kernel configuration is required.

Option Note
CONFIG_DEBUG_INFO_BTF=y available since >= 5.3
CONFIG_KPROBES=y
CONFIG_PERF_EVENTS=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_FUNCTION_TRACER=y /sys/kernel/debug/tracing/available_filter_functions
CONFIG_FPROBE=y --backend=kprobe-multi, available since >= 5.18

You can use zgrep $OPTION /proc/config.gz to validate whether option is enabled.

Downloading

You can download the statically linked executable for x86_64 and arm64 from the release page.

Usage

$ ./pwru --help
Usage: pwru [options] [pcap-filter]
    Availble pcap-filter: see "man 7 pcap-filter"
    Availble options:
      --all-kmods                 attach to all available kernel modules
      --backend string            Tracing backend('kprobe', 'kprobe-multi'). Will auto-detect if not specified.
      --filter-func string        filter kernel functions to be probed by name (exact match, supports RE2 regular expression)
      --filter-mark uint32        filter skb mark
      --filter-netns uint32       filter netns inode
      --filter-track-skb          trace a packet even if it does not match given filters (e.g., after NAT or tunnel decapsulation)
      --kernel-btf string         specify kernel BTF file
      --kmods strings             list of kernel modules names to attach to
      --output-file string        write traces to file
      --output-limit-lines uint   exit the program after the number of events has been received/printed
      --output-meta               print skb metadata
      --output-skb                print skb
      --output-stack              print stack
      --output-tuple              print L4 tuple
      --timestamp string          print timestamp per skb ("current", "relative", "absolute", "none") (default "none")
      --version                   show pwru version and exit

The --filter-func switch does an exact match on function names i.e. --filter-func=foo only matches foo(); for a wildcarded match, try --filter-func=".*foo.*" instead.

Running with Docker

Docker images for pwru are published at https://hub.docker.com/r/cilium/pwru.

An example how to run pwru with Docker:

docker run --privileged --rm -t --pid=host -v /sys/kernel/debug/:/sys/kernel/debug/ cilium/pwru pwru --output-tuple 'host 1.1.1.1'

Running on Kubernetes

The following example shows how to run pwru on a given node:

#!/usr/bin/env bash
NODE=kind-control-plane
PWRU_ARGS="--output-tuple 'host 1.1.1.1'"

trap " kubectl delete --wait=false pod pwru " EXIT

kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: pwru
spec:
  nodeSelector:
    kubernetes.io/hostname: ${NODE}
  containers:
  - image: docker.io/cilium/pwru:latest
    name: pwru
    volumeMounts:
    - mountPath: /sys/kernel/debug
      name: sys-kernel-debug
    securityContext:
      privileged: true
    command: ["/bin/sh"]
    args: ["-c", "pwru ${PWRU_ARGS}"]
  volumes:
  - name: sys-kernel-debug
    hostPath:
      path: /sys/kernel/debug
      type: DirectoryOrCreate
  hostNetwork: true
  hostPID: true
EOF

kubectl wait pod pwru --for condition=Ready --timeout=90s
kubectl logs -f pwru

Running on Vagrant

See docs/vagrant.md

Developing

Dependencies

  • Go >= 1.16
  • LLVM/clang >= 1.12

Building

make

Alternatively, you can build in the Docker container:

make release

Contributing

pwru is an open source project. The userspace code is licensed under Apache-2.0, while the BPF under BSD 2-Clause and GPL-2.0. Everybody is welcome to contribute. Contributors are required to follow the Contributor Covenant Code of Conduct and must adhere to the Developer Certificate of Origin by adding a Signed-off-by line to their commit messages.

Community

Join the #pwru Slack channel to chat with developers, maintainers, and other users. This is a good first stop to ask questions and share your experiences.

Logo Credits

The detective gopher is based on the Go gopher designed by Renee French.

More Repositories

1

cilium

eBPF-based Networking, Security, and Observability
Go
18,311
star
2

ebpf

ebpf-go is a pure-Go library to read, modify and load eBPF programs and attach them to various hooks in the Linux kernel.
Go
5,712
star
3

hubble

Hubble - Network, Service & Security Observability for Kubernetes using eBPF
Go
3,218
star
4

tetragon

eBPF-based Security Observability and Runtime Enforcement
Go
3,195
star
5

cilium-cli

CLI to install, manage & troubleshoot Kubernetes clusters running Cilium
Go
354
star
6

hubble-ui

Observability & Troubleshooting for Kubernetes Services
TypeScript
343
star
7

proxy

Envoy with Cilium filters
C++
118
star
8

cilium-service-mesh-beta

Instructions and issue tracking for Service Mesh capabilities of Cilium
106
star
9

k8s-iptables-diagram

Diagram of Kubernetes / kube-proxy iptables rules architecture
104
star
10

hubble-otel

Hubble adaptor for OpenTelemetry
Go
67
star
11

little-vm-helper

tool for building and running VMs for development and testing
Go
52
star
12

cilium-perf-networking

Utilities for Cilium networking performance evaluation
Shell
51
star
13

team-manager

Bot to manage team members in GitHub organizations
Go
49
star
14

bpf-map

Generic tool to inspect BPF maps
Go
43
star
15

coverbee

Code coverage tooling for eBPF
Go
31
star
16

charts

Helm charts repository for the Cilium project
Shell
30
star
17

chaos-testing-examples

Examples of using Cilium for chaos testing and fault injection
Shell
27
star
18

cilium.io

Cilium project website
JavaScript
27
star
19

cilium-etcd-operator

Operator to manage Cilium's etcd cluster
Go
26
star
20

star-wars-demo

Cilium Star Wars Demo
Shell
25
star
21

workerpool

Run tasks concurrently with limits
Go
23
star
22

k8s-1abel

Kubernetes YAML/JSON survival kit
TypeScript
22
star
23

fake

A Go library to generate random data for testing and/or performance evaluation
Go
19
star
24

design-cfps

Repo to store Cilium CFP design docs
19
star
25

certgen

A convenience tool to generate and store certificates for Hubble Relay mTLS
Go
17
star
26

microscope

[DEPRECATED: See https://github.com/cilium/hubble/] Gather monitor data data from all cilium nodes in your cluster
Python
17
star
27

cilium-sysdump

Tool to collect system information to troubleshoot Cilium & Hubble related issues
Python
16
star
28

ci-kernels

A collection of kernels used for CI builds
Shell
14
star
29

installfest

Documentation and resources for Cilium Installfest
14
star
30

image-tools

Dockerfiles for cilium-runtime and cilium-builder dependencies
Shell
13
star
31

echoserver

k8s.gcr.io/echoserver fork
Dockerfile
13
star
32

json-mock

Simple container image for json-server to mock REST/JSON APIs
Makefile
11
star
33

cilium-olm

Smarty
10
star
34

packer-ci-build

Contains the scripts and data for building the Cilium CI testing VM.
Shell
10
star
35

little-vm-helper-images

Dockerfile
10
star
36

cilium-l4lb-test

Repo for containing scripts to test Cilium's L4LB
C
9
star
37

ipam

Go
8
star
38

gke

Guide & scripts for deploying Cilium on GKE
Shell
7
star
39

scaffolding

Set of tools and resources for automating performance tests.
Go
7
star
40

community

Here you can find community content around Cilium
Shell
7
star
41

clustermesh-apiserver

API server for ClusterMesh
Go
7
star
42

client-example

Cilium API example
Go
7
star
43

alpine-curl

Container image for curl client
Makefile
6
star
44

chaos-monkeys

Base infrastructure plus collection of tests to assist in the Cilium chaos testing efforts
Shell
6
star
45

release

Repository used to generate release notes for Cilium releases
Go
5
star
46

misc-scripts

Misc netperf scripts
Shell
5
star
47

github-actions

Repository dedicated for the GitHub actions logic executed in cilium/cilium. Also known as the maintainer's little helper (MLH).
Go
5
star
48

arping

Go
5
star
49

kube-apate

Go
4
star
50

clustermesh-tools

Tooling to set up a cluster mesh
Shell
4
star
51

cilium-perf-test

Go
4
star
52

docsearch-scraper-webhook

Python
4
star
53

xdp-config

XDP config quirks / troubleshooting documents
Shell
4
star
54

terraform-gke-ci-management-cluster

Terraform module for GKE CI management cluster
HCL
4
star
55

statedb

Go
4
star
56

openshift-terraform-upi

HCL
3
star
57

customvet

Custom Go Vet tool for the Cilium Repository
Go
3
star
58

starwars-docker

Deathstar as a Service
Go
2
star
59

ubuntu-curl

Container image for curl client
Makefile
2
star
60

kustomize-bases

A collection of kustomize bases used for demos
2
star
61

helm-toolbox

Set of tools that are useful for linting helm charts and generating documentation
Dockerfile
2
star
62

echoserver-udp

Container image serving a dynamic TFTP page similar to cilium/echoserver
Go
2
star
63

.github

2
star
64

hive

Hive dependency injection
Go
2
star
65

scruffy

Utility to garbage collect docker image tags from quay.io
Go
1
star
66

reusable-workflows

1
star
67

bpf-ci-scripts

Make testing BPF trees easier with Jenkins
Shell
1
star
68

ebpf.io-summit

JavaScript
1
star
69

linters

Go
1
star
70

stale-rules

A tool to detect and remove stale routing rules
Go
1
star
71

star-wars-demo-automated

Shell
1
star
72

go-bindata

Go
1
star
73

log-gatherer

Dockerfile
1
star
74

api-router

Simple HTTP API router
Go
1
star
75

state-writer

Restore endpoint state from API and write to disk
Go
1
star
76

graceful-termination-test-apps

Apps to test graceful termination
Go
1
star
77

affinity-test-apps

Apps to test connection affinity with load-balancing endpoint updates
Go
1
star
78

test-connection-disruption

Testing connection interruptions during Cilium upgrades
Go
1
star
79

dummylb

Dummy k8s LB used for testing
Go
1
star
80

little-vm-helper-action

1
star
81

busybox

C
1
star