Add dropworld
This commit is contained in:
commit
2af8823f2c
5 changed files with 104 additions and 0 deletions
16
dropworld/default.nix
Normal file
16
dropworld/default.nix
Normal 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
9
dropworld/dropworld.c
Normal 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";
|
Loading…
Add table
Add a link
Reference in a new issue