commit 2af8823f2cc778efa0cd8d9b2f7ec761a72e5feb Author: Pim Kunis Date: Tue Dec 24 16:46:35 2024 +0100 Add dropworld diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/dropworld/default.nix b/dropworld/default.nix new file mode 100644 index 0000000..f102fcc --- /dev/null +++ b/dropworld/default.nix @@ -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 + ''; +} diff --git a/dropworld/dropworld.c b/dropworld/dropworld.c new file mode 100644 index 0000000..1b98ec7 --- /dev/null +++ b/dropworld/dropworld.c @@ -0,0 +1,9 @@ +#include +#include + +SEC("xdp") +int xdp_drop(struct xdp_md *ctx) { + return XDP_DROP; // Drop all packets +} + +char LICENSE[] SEC("license") = "GPL"; diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..396ec32 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1734649271, + "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..80680df --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: + let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + in + { + packages.dropworld = pkgs.callPackage ./dropworld {}; + } + ); +}