mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
move around examples
This commit is contained in:
13
tests/c-form/struct_field_tests.bpf.c
Normal file
13
tests/c-form/struct_field_tests.bpf.c
Normal file
@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include "vmlinux.h"
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#include <bpf/bpf_tracing.h>
|
||||
|
||||
SEC("tp/syscalls/sys_enter_execve")
|
||||
int handle_setuid_entry(struct trace_event_raw_sys_enter *ctx) {
|
||||
bpf_printk("args: %u", (unsigned int)ctx->args[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char LICENSE[] SEC("license") = "GPL";
|
||||
267313
tests/c-form/vmlinux.h
vendored
267313
tests/c-form/vmlinux.h
vendored
File diff suppressed because it is too large
Load Diff
21
tests/c-form/xdp_modify.bpf.c
Normal file
21
tests/c-form/xdp_modify.bpf.c
Normal file
@ -0,0 +1,21 @@
|
||||
// xdp_rewrite.c
|
||||
#include <linux/bpf.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
SEC("xdp")
|
||||
int xdp_rewrite_mac(struct xdp_md *ctx)
|
||||
{
|
||||
void *data_end = (void *)(long)ctx->data_end;
|
||||
void *data = (void *)(long)ctx->data;
|
||||
|
||||
struct ethhdr *eth = data;
|
||||
if ((void*)(eth + 1) > data_end)
|
||||
return XDP_PASS;
|
||||
__u8 new_src[ETH_ALEN] = {0x02,0x00,0x00,0x00,0x00,0x02};
|
||||
for (int i = 0; i < ETH_ALEN; i++) eth->h_source[i] = new_src[i];
|
||||
|
||||
return XDP_PASS;
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
Reference in New Issue
Block a user