• Stars
    star
    2,718
  • Rank 16,766 (Top 0.4 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated 2 months 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
19,773
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
6,227
star
3

tetragon

eBPF-based Security Observability and Runtime Enforcement
Go
3,519
star
4

hubble

Hubble - Network, Service & Security Observability for Kubernetes using eBPF
Makefile
3,452
star
5

cilium-cli

CLI to install, manage & troubleshoot Kubernetes clusters running Cilium
Makefile
413
star
6

hubble-ui

Observability & Troubleshooting for Kubernetes Services
TypeScript
386
star
7

proxy

Envoy with Cilium filters
C++
135
star
8

k8s-iptables-diagram

Diagram of Kubernetes / kube-proxy iptables rules architecture
106
star
9

cilium-service-mesh-beta

Instructions and issue tracking for Service Mesh capabilities of Cilium
104
star
10

hubble-otel

Hubble adaptor for OpenTelemetry
Go
69
star
11

little-vm-helper

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

cilium-perf-networking

Utilities for Cilium networking performance evaluation
Shell
55
star
13

team-manager

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

bpf-map

Generic tool to inspect BPF maps
Go
43
star
15

charts

Helm charts repository for the Cilium project
Shell
39
star
16

coverbee

Code coverage tooling for eBPF
Go
34
star
17

cilium.io

Cilium project website
JavaScript
34
star
18

statedb

In-memory state database for Go
Go
30
star
19

star-wars-demo

Cilium Star Wars Demo
Shell
28
star
20

chaos-testing-examples

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

design-cfps

Repo to store Cilium CFP design docs
27
star
22

cilium-etcd-operator

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

workerpool

Run tasks concurrently with limits
Go
26
star
24

k8s-1abel

Kubernetes YAML/JSON survival kit
TypeScript
22
star
25

certgen

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

fake

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

image-tools

Dockerfiles for cilium-runtime and cilium-builder dependencies
Shell
17
star
28

microscope

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

cilium-sysdump

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

ci-kernels

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

installfest

Documentation and resources for Cilium Installfest
14
star
32

echoserver

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

json-mock

Simple container image for json-server to mock REST/JSON APIs
Makefile
13
star
34

little-vm-helper-images

Dockerfile
12
star
35

community

Here you can find community content around Cilium
Shell
11
star
36

hive

Hive dependency injection
Go
11
star
37

cilium-olm

Smarty
10
star
38

packer-ci-build

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

scaffolding

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

cilium-l4lb-test

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

ipam

Go
8
star
42

gke

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

clustermesh-apiserver

API server for ClusterMesh
Go
7
star
44

client-example

Cilium API example
Go
7
star
45

chaos-monkeys

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

release

Repository used to generate release notes for Cilium releases
Go
6
star
47

alpine-curl

Container image for curl client
Makefile
6
star
48

misc-scripts

Misc netperf scripts
Shell
5
star
49

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
50

docsearch-scraper-webhook

Python
5
star
51

xdp-config

XDP config quirks / troubleshooting documents
Shell
5
star
52

arping

Go
5
star
53

kube-apate

Go
4
star
54

clustermesh-tools

Tooling to set up a cluster mesh
Shell
4
star
55

cilium-perf-test

Go
4
star
56

terraform-gke-ci-management-cluster

Terraform module for GKE CI management cluster
HCL
4
star
57

stream

Reactive streams for Go
Go
4
star
58

openshift-terraform-upi

HCL
3
star
59

customvet

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

starwars-docker

Deathstar as a Service
Go
2
star
61

ubuntu-curl

Container image for curl client
Makefile
2
star
62

linters

Go
2
star
63

star-wars-demo-automated

Shell
2
star
64

helm-toolbox

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

echoserver-udp

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

kustomize-bases

A collection of kustomize bases used for demos
2
star
67

.github

2
star
68

scruffy

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

reusable-workflows

1
star
70

bpf-ci-scripts

Make testing BPF trees easier with Jenkins
Shell
1
star
71

ebpf.io-summit

JavaScript
1
star
72

stale-rules

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

go-bindata

Go
1
star
74

log-gatherer

Dockerfile
1
star
75

api-router

Simple HTTP API router
Go
1
star
76

state-writer

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

graceful-termination-test-apps

Apps to test graceful termination
Go
1
star
78

affinity-test-apps

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

test-connection-disruption

Testing connection interruptions during Cilium upgrades
Go
1
star
80

dummylb

Dummy k8s LB used for testing
Go
1
star
81

little-vm-helper-action

1
star
82

busybox

C
1
star
83

scale-tests-action

Repository that hosts the GitHub action to run scale tests
1
star