Add dropworld

This commit is contained in:
Pim Kunis 2024-12-24 16:46:35 +01:00
commit 2af8823f2c
5 changed files with 104 additions and 0 deletions

16
dropworld/default.nix Normal file
View file

@ -0,0 +1,16 @@
{clangStdenv, libbpf, ...}: clangStdenv.mkDerivation {
name = "dropworld";
src = ./.;
hardeningDisable = [ "stackprotector" "zerocallusedregs" ];
dontFixup = true;
buildInputs = [ libbpf ];
buildPhase = ''
clang -O2 -target bpf -g -c dropworld.c -o dropworld.o
'';
installPhase = ''
mkdir $out
cp dropworld.o $out
'';
}

9
dropworld/dropworld.c Normal file
View file

@ -0,0 +1,9 @@
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
SEC("xdp")
int xdp_drop(struct xdp_md *ctx) {
return XDP_DROP; // Drop all packets
}
char LICENSE[] SEC("license") = "GPL";