Skip to content

zakisk/drop-packets

Repository files navigation

Problem statement 1: Drop packets using eBPF

Write an eBPF code to drop the TCP packets on a port (def: 4040). Additionally, if you can make the port number configurable from the userspace, that will be a big plus.

Solution

A simple program written in Golang along with eBPF/XDP program written in C to drop incoming network packets on a port P.

how to run

for linux

Step 1:

# install the necessary dependencies to run the program

sudo apt update
sudo apt install clang llvm gcc golang-go
sudo apt install linux-headers-$(uname -r)

sudo apt-get update
sudo apt-get install bpfcc-tools libbpfcc-dev

Step 2:

# clone the repository
git clone github.com/zakisk/drop-packets

Step 3:

# build and run program
cd drop-packets
go build && sudo ./drop-packets

To change the network interface on your machine change ifname variable value in main.go. Execute ip a command to list network interfaces available on machine.

here in code:

ifname := "lo"
iface, err := net.InterfaceByName(ifname)
if err != nil {
    log.Fatalf("Getting interface %s: %s", ifname, err)
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published