Skip to content

Instantly share code, notes, and snippets.

@mattnite
Last active October 16, 2020 07:15
Show Gist options
  • Save mattnite/a3637625730c90480c522aba2d325cbe to your computer and use it in GitHub Desktop.
Save mattnite/a3637625730c90480c522aba2d325cbe to your computer and use it in GitHub Desktop.
simple BPF program
const std = @import("std");
const mem = std.mem
usingnamespace @import("bpf");
export var events linksection("maps") = PerfEventArray.init(256, 0);
export fn bpf_prog(ctx: *SkBuff) linksection("socket1") c_int {
var time = ktime_get_ns();
events.event_output(ctx, F_CURRENT_CPU, mem.asBytes(&time)) catch {};
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment