All Projects → sematext → oxdpus

sematext / oxdpus

Licence: Apache-2.0 License
A toy tool that leverages the super powers of XDP to bring in-kernel IP filtering

Programming Languages

go
31211 projects - #10 most used programming language
c
50402 projects - #5 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to oxdpus

Cilium
eBPF-based Networking, Security, and Observability
Stars: ✭ 10,256 (+17283.05%)
Mutual labels:  kernel, ebpf, xdp, bpf
KubeArmor
Cloud-native Runtime Security Enforcement System
Stars: ✭ 434 (+635.59%)
Mutual labels:  kernel, ebpf, bpf
Bpfd
Framework for running BPF programs with rules on Linux as a daemon. Container aware.
Stars: ✭ 396 (+571.19%)
Mutual labels:  kernel, ebpf, bpf
bpflock
bpflock - eBPF driven security for locking and auditing Linux machines
Stars: ✭ 54 (-8.47%)
Mutual labels:  kernel, ebpf, bpf
libbpf-sys
Rust bindings to libbpf from the Linux kernel
Stars: ✭ 103 (+74.58%)
Mutual labels:  ebpf, xdp, bpf
XDP-Firewall
An XDP firewall that is capable of filtering specific packets based off of filtering rules specified in a config file. IPv6 is supported!
Stars: ✭ 129 (+118.64%)
Mutual labels:  ebpf, xdp, bpf
packiffer
lightweight cross-platform networking toolkit
Stars: ✭ 52 (-11.86%)
Mutual labels:  ebpf, xdp, bpf
pwru
Packet, where are you? -- Linux kernel networking debugger
Stars: ✭ 694 (+1076.27%)
Mutual labels:  kernel, ebpf, bpf
ovs-ebpf
No description or website provided.
Stars: ✭ 34 (-42.37%)
Mutual labels:  ebpf, xdp
ebpfault
A BPF-based syscall fault injector
Stars: ✭ 65 (+10.17%)
Mutual labels:  ebpf, bpf
Polycube
eBPF/XDP-based software framework for fast network services running in the Linux kernel.
Stars: ✭ 217 (+267.8%)
Mutual labels:  ebpf, bpf
ebpf
eBPF package for Go
Stars: ✭ 25 (-57.63%)
Mutual labels:  ebpf, bpf
sqredirect
Redirection and filtering Source Engine game traffic in bundle with sqproxy
Stars: ✭ 21 (-64.41%)
Mutual labels:  kernel, ebpf
portablebpf
You came here so you could have a base code to serve you as an example on how to develop a BPF application, compatible to BCC and/or LIBBPF, specially LIBBPF, having the userland part made in C or PYTHON.
Stars: ✭ 32 (-45.76%)
Mutual labels:  ebpf, bpf
btfhub
BTFHub, together with BTFHub Archive repository, provides BTF files for existing published kernels that don't support embedded BTF.
Stars: ✭ 100 (+69.49%)
Mutual labels:  kernel, ebpf
p2pflow
Ethereum p2p traffic analysis with eBPF
Stars: ✭ 24 (-59.32%)
Mutual labels:  ebpf, bpf
go-tc
traffic control in pure go - it allows to read and alter queues, filters and classes
Stars: ✭ 245 (+315.25%)
Mutual labels:  ebpf, bpf
Tcpdog
eBPF based TCP observability.
Stars: ✭ 119 (+101.69%)
Mutual labels:  ebpf, bpf
Xdp Project
XDP project collaboration through a git-repo
Stars: ✭ 127 (+115.25%)
Mutual labels:  ebpf, bpf
ebpfpub
ebpfpub is a generic function tracing library for Linux that supports tracepoints, kprobes and uprobes.
Stars: ✭ 86 (+45.76%)
Mutual labels:  ebpf, bpf

oxdpus

oxdpus is a toy tool that demonstrates some of the super powers of XDP - a high performance packet processing path built into the kernel.

Requirements

To build oxdpus you have to satisify the following requirements:

  • have a modern Linux kernel (>4.12) that supports XDP
  • linux headers
  • clang
  • LLVM
  • Go >1.12
  • gobindata (to embed XDP bytecode inside Go binary)

This repository ships with a Makefile to facilitate the build process. The make xdp command compiles the XDP program and generates Go source code to reference the resulting bytecode. Once the XDP ELF object is produced, you can build the Go binary with make go. After compilation is done, the binary will be availalbe in cmd/oxdpus/oxdpus.

If your mere intention is to just build the Go binary without requiring modifications in the XDP program, then you'll only need the Go compiler since the XDP bytecode is already baked into the binary.

Usage

To see available CLI options, run oxdpus --help:

oxdpus --help
A toy tool that leverages the super powers of XDP to bring in-kernel IP filtering

Usage:
  oxdpus [command]

Available Commands:
  add         Appends a new IP address to the blacklist
  attach      Attaches the XDP program on the specified device
  detach      Removes the XDP program from the specified device
  help        Help about any command
  list        Shows all IP addresses registered in the blacklist
  remove      Removes an IP address from the blacklist

Flags:
  -h, --help   help for oxdpus

Use "oxdpus [command] --help" for more information about a command.

To attach the XDP program to the network interface:

$ oxdpus attach --dev=vethbd33820
INFO XDP program successfully attached to vethbd33820 device

The magic happens after you add a couple of IP addresses to the blacklist:

$ oxdpus add --ip=172.17.0.2
INFO 172.17.0.2 address added to the blacklist
$ oxdpus list
* 172.17.0.2
$ curl -v 172.17.0.2:80
*   Trying 172.17.0.2...
* TCP_NODELAY set
curl: (7) Failed to connect to 172.17.0.2 port 80: No route to host

You can remove the IP from the blacklist or even completely unload the program:

$ oxdpus remove --ip=172.17.0.2
INFO 172.17.0.2 address removed from the blacklist
$ oxdpus detach --dev=vethbd33820
INFO XDP program successfully unloaded from vethbd33820 device

Bump max file descriptor limit

If you get an error such as FATA error while loading map "maps/blacklist": too many open files, you're likely running on low file descriptor limits. Run the following commands to bump the limt:

echo "fs.file-max = 4194304" >> /etc/sysctl.d/local.conf
echo "fs.nr_open = 4194304" >> /etc/sysctl.d/local.conf
sysctl -p /etc/sysctl.d/local.conf
ulimit -n 4194304
ulimit -l unlimited
sed -i "s/# End of file//" /etc/security/limits.conf
printf "\n* - nofile 4194304\nroot - nofile 4194304\n" >> /etc/security/limits.conf
printf "\n* - memlock unlimited\nroot - memlock unlimited\n" >> /etc/security/limits.conf
printf "\nulimit -n 4194304\nulimit -l unlimited\n" >> ~/.bashrc

Tutorial

To read more, check out the tutorial I wrote about Processing Packets at Bare-metal Speed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].