Skip to content

Commit

Permalink
Merge pull request bpfman#1338 from anfredette/debug-globals
Browse files Browse the repository at this point in the history
Add an eBPF program with 9 global variables
  • Loading branch information
mergify[bot] authored Nov 8, 2024
2 parents b28ea2c + c33ecfc commit 5b47ba1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/integration-test/bpf/kprobe_globals.bpf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
// Copyright Authors of bpfman

// Some kprobe test code

// clang-format off
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
// clang-format on

volatile const __u32 sampling = 0;
volatile const __u8 trace_messages = 0;
volatile const __u8 enable_rtt = 0;
volatile const __u8 enable_pca = 0;
volatile const __u8 enable_dns_tracking = 0;
volatile const __u8 enable_flows_filtering = 0;
volatile const __u16 dns_port = 0;
volatile const __u8 enable_network_events_monitoring = 0;
volatile const __u8 network_events_monitoring_groupid = 0;

void print_globals() {
bpf_printk("sampling: 0x%08X, trace_messages: 0x%02X, enable_rtt: 0x%02X, "
"enable_pca: 0x%02X, enable_dns_tracking: 0x%02X, "
"enable_flows_filtering: 0x%02X, dns_port: 0x%02X, "
"enable_network_events_monitoring: 0x%02X, "
"network_events_monitoring_groupid: 0x%02X\n",
sampling, trace_messages, enable_rtt, enable_pca,
enable_dns_tracking, enable_flows_filtering, dns_port,
enable_network_events_monitoring,
network_events_monitoring_groupid);
}

SEC("kprobe/kprobe_globals")
int kprobe_globals(struct pt_regs *ctx) {
print_globals();
return 0;
}

SEC("kretprobe/kprobe_globals")
int kretprobe_globals(struct pt_regs *ctx) {
print_globals();
return 0;
}

char _license[] SEC("license") = "Dual BSD/GPL";

0 comments on commit 5b47ba1

Please sign in to comment.