forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bpfman#1338 from anfredette/debug-globals
Add an eBPF program with 9 global variables
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |