Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/testing/selftests/bpf/progs/cgrp_ls_sleepable.c
int cgroup_iter(struct bpf_iter__cgroup *ctx) { struct seq_file *seq = ctx->meta->seq; struct cgroup *cgrp = ctx->cgroup; long *ptr; if (cgrp == NULL) return 0; ptr = bpf_cgrp_storage_get(&map_a, cgrp, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); if (ptr) cgroup_id = cgrp->kn->id; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect4_prog.c
static __inline int set_cc(struct bpf_sock_addr *ctx) { char reno[TCP_CA_NAME_MAX] = "reno"; char cubic[TCP_CA_NAME_MAX] = "cubic"; if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &reno, sizeof(reno))) return 1; if (verify_cc(ctx, reno)) return 1; if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect4_prog.c
static __inline int bind_to_device(struct bpf_sock_addr *ctx) { char veth1[IFNAMSIZ] = "test_sock_addr1"; char veth2[IFNAMSIZ] = "test_sock_addr2"; char missing[IFNAMSIZ] = "nonexistent_dev"; char del_bind[IFNAMSIZ] = ""; if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, &veth1, sizeof(veth1))) retur...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect4_prog.c
static __inline int set_notsent_lowat(struct bpf_sock_addr *ctx) { int lowat = 65535; if (ctx->type == SOCK_STREAM) { if (bpf_setsockopt(ctx, SOL_TCP, TCP_NOTSENT_LOWAT, &lowat, sizeof(lowat))) return 1; } return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect4_prog.c
int connect_v4_prog(struct bpf_sock_addr *ctx) { struct bpf_sock_tuple tuple = {}; struct bpf_sock *sk; memset(&tuple.ipv4.saddr, 0, sizeof(tuple.ipv4.saddr)); memset(&tuple.ipv4.sport, 0, sizeof(tuple.ipv4.sport)); tuple.ipv4.daddr = bpf_htonl(DST_REWRITE_IP4); tuple.ipv4.dport = bpf_htons(DST_REWRITE_PO...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect_force_port4.c
int getsockname4(struct bpf_sock_addr *ctx) { if (!get_set_sk_priority(ctx)) return 1; if (ctx->user_port == bpf_htons(60123)) { ctx->user_ip4 = bpf_htonl(0x01020304); ctx->user_port = bpf_htons(60000); } return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect_ping.c
int connect_v4_prog(struct bpf_sock_addr *ctx) { struct sockaddr_in sa = { .sin_family = AF_INET, .sin_addr.s_addr = bpf_htonl(0x01010101), }; __sync_fetch_and_add(&invocations_v4, 1); if (do_bind && bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa))) has_error = 1; return 1; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/connect_ping.c
int connect_v6_prog(struct bpf_sock_addr *ctx) { struct sockaddr_in6 sa = { .sin6_family = AF_INET6, .sin6_addr = BINDADDR_V6, }; __sync_fetch_and_add(&invocations_v6, 1); if (do_bind && bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa))) has_error = 1; return 1; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/core_kern.c
int BPF_PROG(tp_xdp_devmap_xmit_multi, const struct net_device *from_dev, const struct net_device *to_dev, int sent, int drops, int err) { return randmap(from_dev->ifindex, from_dev); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/dev_cgroup.c
int bpf_prog1(struct bpf_cgroup_dev_ctx *ctx) { short type = ctx->access_type & 0xFFFF; #ifdef DEBUG short access = ctx->access_type >> 16; char fmt[] = " %d:%d \n"; switch (type) { case BPF_DEVCG_DEV_BLOCK: fmt[0] = 'b'; break; case BPF_DEVCG_DEV_CHAR: fmt[0] = 'c'; break; default: ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/dynptr_fail.c
static int release_twice_callback_fn(__u32 index, void *data) { bpf_ringbuf_discard_dynptr(data, 0); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/empty_skb.c
int redirect_egress(struct __sk_buff *skb) { ret = bpf_clone_redirect(skb, ifindex, 0); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/exhandler_kern.c
int BPF_PROG(trace_task_newtask, struct task_struct *task, u64 clone_flags) { int pid = bpf_get_current_pid_tgid() >> 32; struct callback_head *work; void *func; if (test_pid != pid) return 0; work = task->task_works; func = work->func; /* Currently verifier will fail for `btf_ptr |= btf_ptr` * inst...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fentry_test.c
int BPF_PROG(test1, int a) { test1_result = a == 1; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fentry_test.c
int BPF_PROG(test2, int a, __u64 b) { test2_result = a == 2 && b == 3; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fentry_test.c
int BPF_PROG(test5, __u64 a, void *b, short c, int d, __u64 e) { test5_result = a == 11 && b == (void *)12 && c == 13 && d == 14 && e == 15; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
int new_get_skb_len(struct __sk_buff *skb) { int len = skb->len; if (len != 74) return 0; test_get_skb_len = 1; return 74; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fexit_sleep.c
int nanosleep_fentry(void *ctx) { if (bpf_get_current_pid_tgid() >> 32 != pid) return 0; fentry_cnt++; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/fexit_sleep.c
int nanosleep_fexit(void *ctx) { if (bpf_get_current_pid_tgid() >> 32 != pid) return 0; fexit_cnt++; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/find_vma.c
static long check_vma(struct task_struct *task, struct vm_area_struct *vma, struct callback_ctx *data) { if (vma->vm_file) bpf_probe_read_kernel_str(d_iname, DNAME_INLINE_LEN - 1, vma->vm_file->f_path.dentry->d_iname); if (vma->vm_flags & VM_EXEC) found_v...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/find_vma_fail1.c
static long write_vma(struct task_struct *task, struct vm_area_struct *vma, struct callback_ctx *data) { vma->vm_flags |= 0x55; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/for_each_array_map_elem.c
static __u64 unused_subprog(struct bpf_map *map, __u32 *key, __u64 *val, struct callback_ctx *data) { data->output = 0; return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/for_each_array_map_elem.c
static __u64 check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val, struct callback_ctx *data) { data->output += *val; if (*key == 1) return 1; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/for_each_hash_map_elem.c
static __u64 check_hash_elem(struct bpf_map *map, __u32 *key, __u64 *val, struct callback_ctx *data) { struct __sk_buff *skb = data->ctx; __u32 k; __u64 v; if (skb) { k = *key; v = *val; if (skb->len == 10000 && k == 10 && v == 10) data->output = 3; else ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/for_each_map_elem_write_key.c
static __u64 check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val, void *data) { bpf_get_current_comm(key, sizeof(*key)); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/freplace_connect_v4_prog.c
int new_connect_v4_prog(struct bpf_sock_addr *ctx) { return 255; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/get_func_args_test.c
int BPF_PROG(fmod_ret_test, int _a, int *_b, int _ret) { __u64 cnt = bpf_get_func_arg_cnt(ctx); __u64 a = 0, b = 0, z = 0, ret = 0; __s64 err; test3_result = cnt == 2; err = bpf_get_func_arg(ctx, 0, &a); test3_result &= err == 0 && ((int)a == 1); err = bpf_get_func_arg(ctx, 1, &b); test3_result &= er...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/get_func_ip_test.c
int unused(void) { return CONFIG_X86_KERNEL_IBT ? 0 : 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/get_func_ip_test.c
int BPF_PROG(test2, int a) { __u64 addr = bpf_get_func_ip(ctx); test2_result = (const void *)addr == &bpf_fentry_test2; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/get_func_ip_test.c
int BPF_PROG(test5, int a, int *b, int ret) { __u64 addr = bpf_get_func_ip(ctx); test5_result = (const void *)addr == &bpf_modify_return_test; return ret; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/get_func_ip_test.c
int test6(struct pt_regs *ctx) { __u64 addr = bpf_get_func_ip(ctx); test6_result = (const void *)addr == 0; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/ima.c
int BPF_PROG(kernel_read_file, struct file *file, enum kernel_read_file_id id, bool contents) { int ret; if (!enable_kernel_read_file) return 0; if (!contents) return 0; if (id != READING_POLICY) return 0; ret = ima_test_deny(); if (ret < 0) return ret; ima_test_common(fi...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kfree_skb.c
int BPF_PROG(fentry_eth_type_trans, struct sk_buff *skb, struct net_device *dev, unsigned short protocol) { int len, ifindex; __builtin_preserve_access_index(({ len = skb->len; ifindex = dev->ifindex; })); if (len != 74 || ifindex != 1) return 0; result.fentry_test_ok = true; retu...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kfunc_call_fail.c
int kfunc_call_test_mem_acquire_fail(struct __sk_buff *skb) { struct prog_test_ref_kfunc *pt; unsigned long s = 0; int *p = NULL; int ret = 0; pt = bpf_kfunc_call_test_acquire(&s); if (pt) { p = bpf_kfunc_call_test_acq_rdonly_mem(pt, 2 * sizeof(int)); if (p) ret = p[0]; else ret = ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kfunc_call_test.c
int kfunc_call_test_pass(struct __sk_buff *skb) { struct prog_test_pass1 p1 = {}; struct prog_test_pass2 p2 = {}; short a = 0; __u64 b = 0; long c = 0; char d = 0; int e = 0; bpf_kfunc_call_test_pass_ctx(skb); bpf_kfunc_call_test_pass1(&p1); bpf_kfunc_call_test_pass2(&p2); bpf_kfunc_call_test_me...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kprobe_multi.c
static void kprobe_multi_check(void *ctx, bool is_return) { if (bpf_get_current_pid_tgid() >> 32 != pid) return; __u64 cookie = test_cookie ? bpf_get_attach_cookie(ctx) : 0; __u64 addr = bpf_get_func_ip(ctx); #define SET(__var, __addr, __cookie) \ ({ ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kprobe_multi.c
int test_kprobe(struct pt_regs *ctx) { kprobe_multi_check(ctx, false); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kprobe_multi.c
int test_kprobe_manual(struct pt_regs *ctx) { kprobe_multi_check(ctx, false); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kprobe_multi.c
int test_kretprobe_testmod(struct pt_regs *ctx) { kprobe_multi_testmod_check(ctx, true); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/kprobe_multi_empty.c
int test_kprobe_empty(struct pt_regs *ctx) { return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/ksym_race.c
int ksym_fail(struct __sk_buff *ctx) { return *(int *)bpf_this_cpu_ptr(&bpf_testmod_ksym_percpu); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_funcs1.c
void set_output_ctx1(__u64 *ctx) { output_ctx1 = ctx[1]; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_funcs2.c
void set_output_ctx2(__u64 *ctx) { output_ctx2 = ctx[1]; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_funcs2.c
__weak int set_output_weak(int x) { static volatile int whatever; whatever = 2 * bpf_core_type_size(struct task_struct); output_weak2 = x; return 2 * x; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_funcs2.c
int BPF_PROG(handler2, struct pt_regs *regs, long id) { static volatile int whatever; if (my_tid != (u32)bpf_get_current_pid_tgid() || id != syscall_id) return 0; whatever = bpf_core_type_size(struct task_struct); set_output_val1(2000); set_output_ctx1(ctx); /* ctx definition is hidden in BPF_PROG macr...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list.c
int map_list_push_pop(void *ctx) { struct map_value *v; v = bpf_map_lookup_elem(&array_map, &(int){0}); if (!v) return 1; return test_list_push_pop(&v->lock, &v->head); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list.c
int global_list_push_pop_multiple(void *ctx) { int ret; ret = list_push_pop_multiple(&glock, &ghead, false); if (ret) return ret; return list_push_pop_multiple(&glock, &ghead, true); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int map_compat_perf(void *ctx) { bpf_list_push_front(&ghead, NULL); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int obj_type_id_oor(void *ctx) { bpf_obj_new_impl(~0UL, NULL); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int obj_new_no_composite(void *ctx) { bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int obj_drop_non_zero_off(void *ctx) { void *f; f = bpf_obj_new(struct foo); if (!f) return 0; bpf_obj_drop(f + 1); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int new_null_ret(void *ctx) { return bpf_obj_new(struct foo)->data; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int write_after_push_back(void *ctx) { return write_after_op((void *)bpf_list_push_back); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int use_after_unlock_push_back(void *ctx) { return use_after_unlock((void *)bpf_list_push_back); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int double_push_back(void *ctx) { return list_double_add((void *)bpf_list_push_back); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int incorrect_node_off2(void *ctx) { struct foo *f; f = bpf_obj_new(typeof(*f)); if (!f) return 0; bpf_spin_lock(&glock); bpf_list_push_front(&ghead, &f->node2); bpf_spin_unlock(&glock); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int incorrect_head_var_off1(struct __sk_buff *ctx) { struct foo *f; f = bpf_obj_new(typeof(*f)); if (!f) return 0; bpf_spin_lock(&glock); bpf_list_push_front((void *)&ghead + ctx->protocol, &f->node); bpf_spin_unlock(&glock); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int incorrect_head_var_off2(struct __sk_buff *ctx) { struct foo *f; f = bpf_obj_new(typeof(*f)); if (!f) return 0; bpf_spin_lock(&glock); bpf_list_push_front((void *)&f->head + ctx->protocol, &f->node); bpf_spin_unlock(&glock); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int incorrect_head_off1(void *ctx) { struct foo *f; struct bar *b; f = bpf_obj_new(typeof(*f)); if (!f) return 0; b = bpf_obj_new(typeof(*b)); if (!b) { bpf_obj_drop(f); return 0; } bpf_spin_lock(&f->lock); bpf_list_push_front((void *)&f->head + 1, &b->node); bpf_spin_unlock(&f->lock);...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_list_fail.c
int incorrect_head_off2(void *ctx) { struct foo *f; struct bar *b; f = bpf_obj_new(typeof(*f)); if (!f) return 0; bpf_spin_lock(&glock); bpf_list_push_front((void *)&ghead + 1, &f->node); bpf_spin_unlock(&glock); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_maps1.c
int BPF_PROG(handler_enter1) { int key = 1, val = 1; struct my_key key_struct = {.x = 1}; struct my_value val_struct = {.x = 1000}; bpf_map_update_elem(&map1, &key_struct, &val_struct, 0); bpf_map_update_elem(&map2, &key, &val, 0); bpf_map_update_elem(&map_weak, &key, &val, 0); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/linked_maps2.c
int BPF_PROG(handler_exit2) { int key = 1, *val; key_type key_struct = {.x = 1}; value_type *value_struct; value_struct = bpf_map_lookup_elem(&map1, &key_struct); if (value_struct) output_first2 = value_struct->x; val = bpf_map_lookup_elem(&map2, &key); if (val) output_second2 = *val; val = ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/local_storage.c
int BPF_PROG(inode_rename, struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { __u32 pid = bpf_get_current_pid_tgid() >> 32; struct local_storage *storage; int err; bpf_inode_storage_get(&inode_storage_map, new_dent...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/local_storage.c
int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address, int addrlen) { __u32 pid = bpf_get_current_pid_tgid() >> 32; struct local_storage *storage; int err; if (pid != monitored_pid) return 0; storage = bpf_sk_storage_get(&sk_storage_map, sock->sk, 0, ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/local_storage_bench.c
int get_local(void *ctx) { struct loop_ctx lctx; lctx.task = bpf_get_current_task_btf(); lctx.loop_hits = 0; lctx.loop_important_hits = 0; bpf_loop(10000, &loop, &lctx, 0); __sync_add_and_fetch(&hits, lctx.loop_hits); __sync_add_and_fetch(&important_hits, lctx.loop_important_hits); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/local_storage_rcu_tasks_trace_bench.c
int postgp(struct pt_regs *ctx) { if (!current_gp_start && postgp_seen) { __sync_add_and_fetch(&unexpected, 1); return 0; } __sync_add_and_fetch(&gp_times, bpf_ktime_get_ns() - current_gp_start); __sync_add_and_fetch(&gp_hits, 1); current_gp_start = 0; postgp_seen = true; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/loop1.c
int nested_loops(volatile struct pt_regs *ctx) { int i, j, sum = 0, m; for (j = 0; j < 300; j++) for (i = 0; i < j; i++) { if (j & 1) m = PT_REGS_RC(ctx); else m = j; sum += i * m; } return sum; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/loop2.c
int while_true(volatile struct pt_regs *ctx) { int i = 0; while (true) { if (PT_REGS_RC(ctx) & 1) i += 3; else i += 7; if (i > 40) break; } return i; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/loop6.c
static inline struct scatterlist *get_sgp(struct scatterlist **sgs, int i) { struct scatterlist *sgp; bpf_probe_read_kernel(&sgp, sizeof(sgp), sgs + i); return sgp; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/lru_bug.c
int printk(void *ctx) { struct map_value v = {}; if (pid == bpf_get_current_task_btf()->pid) bpf_map_update_elem(&lru_map, &(int){0}, &v, 0); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/lru_bug.c
int nanosleep(void *ctx) { struct map_value val = {}, *v; struct task_struct *current; bpf_map_update_elem(&lru_map, &(int){0}, &val, 0); v = bpf_map_lookup_elem(&lru_map, &(int){0}); if (!v) return 0; bpf_map_delete_elem(&lru_map, &(int){0}); current = bpf_get_current_task_btf(); v->ptr = current;...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/lsm.c
int BPF_PROG(test_task_free, struct task_struct *task) { return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/lsm_cgroup.c
int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address, int addrlen) { called_socket_bind++; return real_bind(sock, address, addrlen); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_kptr.c
static void test_kptr_ref(struct map_value *v) { struct prog_test_ref_kfunc *p; p = v->ref_ptr; v->unref_ptr = p; if (!p) return; if (p->a + p->b > 100) return; /* store NULL */ p = bpf_kptr_xchg(&v->ref_ptr, NULL); if (!p) return; if (p->a + p->b > 100) { bpf_kfunc_call_test_release...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_kptr.c
int test_map_kptr_ref2(struct __sk_buff *ctx) { struct prog_test_ref_kfunc *p, *p_st; struct map_value *v; int key = 0; v = bpf_map_lookup_elem(&array_map, &key); if (!v) return 1; p_st = v->ref_ptr; if (!p_st || p_st->cnt.refs.counter != 2) return 2; p = bpf_kptr_xchg(&v->ref_ptr, NULL); i...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static __noinline int check_default_noinline(struct bpf_map *indirect, struct bpf_map *direct) { VERIFY(check(indirect, direct, sizeof(__u32), sizeof(__u32), MAX_ENTRIES)); return 1; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_hash(void) { struct bpf_htab *hash = (struct bpf_htab *)&m_hash; struct bpf_map *map = (struct bpf_map *)&m_hash; int i; VERIFY(check_default_noinline(&hash->map, map)); VERIFY(hash->n_buckets == MAX_ENTRIES); VERIFY(hash->elem_size == 64); VERIFY(hash->count.counter == 0); f...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_lru_hash(void) { struct bpf_htab *lru_hash = (struct bpf_htab *)&m_lru_hash; struct bpf_map *map = (struct bpf_map *)&m_lru_hash; VERIFY(check_default(&lru_hash->map, map)); return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_devmap(void) { struct bpf_dtab *devmap = (struct bpf_dtab *)&m_devmap; struct bpf_map *map = (struct bpf_map *)&m_devmap; VERIFY(check_default(&devmap->map, map)); return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_sockmap(void) { struct bpf_stab *sockmap = (struct bpf_stab *)&m_sockmap; struct bpf_map *map = (struct bpf_map *)&m_sockmap; VERIFY(check_default(&sockmap->map, map)); return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_sockhash(void) { struct bpf_shtab *sockhash = (struct bpf_shtab *)&m_sockhash; struct bpf_map *map = (struct bpf_map *)&m_sockhash; VERIFY(check_default(&sockhash->map, map)); return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
static inline int check_stack(void) { struct bpf_queue_stack *stack = (struct bpf_queue_stack *)&m_stack; struct bpf_map *map = (struct bpf_map *)&m_stack; VERIFY(check(&stack->map, map, 0, sizeof(__u32), MAX_ENTRIES)); return 1; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/map_ptr_kern.c
int cg_skb(void *ctx) { VERIFY_TYPE(BPF_MAP_TYPE_HASH, check_hash); VERIFY_TYPE(BPF_MAP_TYPE_ARRAY, check_array); VERIFY_TYPE(BPF_MAP_TYPE_PROG_ARRAY, check_prog_array); VERIFY_TYPE(BPF_MAP_TYPE_PERF_EVENT_ARRAY, check_perf_event_array); VERIFY_TYPE(BPF_MAP_TYPE_PERCPU_HASH, check_percpu_hash); VERIFY_TYPE(...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/metadata_unused.c
int prog(struct xdp_md *ctx) { return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/metadata_used.c
int prog(struct xdp_md *ctx) { return bpf_metadata_b ? 1 : 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/netns_cookie_prog.c
int get_netns_cookie_sockops(struct bpf_sock_ops *ctx) { struct bpf_sock *sk = ctx->sk; int *cookie; __u32 key = 0; if (ctx->family != AF_INET6) return 1; if (!sk) return 1; switch (ctx->op) { case BPF_SOCK_OPS_TCP_CONNECT_CB: cookie = bpf_sk_storage_get(&sockops_netns_cookies, sk, 0, ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/profiler.inc.h
static ino_t get_inode_from_kernfs(struct kernfs_node *node) { struct kernfs_node___52 *node52 = (void *)node; if (bpf_core_field_exists(node52->id.ino)) { barrier_var(node52); return BPF_CORE_READ(node52, id.ino); } else { barrier_var(node); return (u64)BPF_CORE_READ(node, id); } }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/pyperf.h
static __always_inline bool get_frame_data(void *frame_ptr, PidData *pidData, FrameData *frame, Symbol *symbol) { bpf_probe_read_user(&frame->f_back, sizeof(frame->f_back), frame_ptr + pidData->offsets.PyFrameObject_back); bpf_probe_read_user(&frame-...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/rcu_read_lock.c
int non_sleepable_2(void *ctx) { struct task_struct *task, *real_parent; bpf_rcu_read_lock(); task = bpf_get_current_task_btf(); bpf_rcu_read_unlock(); bpf_rcu_read_lock(); real_parent = task->real_parent; if (!real_parent) goto out; (void)bpf_task_storage_get(&map_a, real_parent, 0, 0); out: bp...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/recursion.c
int BPF_PROG(on_delete, struct bpf_map *map) { int key = 0; if (map == (void *)&hash1) { pass1++; return 0; } if (map == (void *)&hash2) { pass2++; bpf_map_delete_elem(&hash2, &key); return 0; } return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/ringbuf_bench.c
static __always_inline long get_flags() { long sz; if (!wakeup_data_size) return 0; sz = bpf_ringbuf_query(&ringbuf, BPF_RB_AVAIL_DATA); return sz >= wakeup_data_size ? BPF_RB_FORCE_WAKEUP : BPF_RB_NO_WAKEUP; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/ringbuf_bench.c
int bench_ringbuf(void *ctx) { long *sample, flags; int i; if (!use_output) { for (i = 0; i < batch_cnt; i++) { sample = bpf_ringbuf_reserve(&ringbuf, sizeof(sample_val), 0); if (!sample) { __sync_add_and_fetch(&dropped, 1); } else { *sample = sample_val; flags = get...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/sendmsg4_prog.c
int sendmsg_v4_prog(struct bpf_sock_addr *ctx) { int prio; if (ctx->type != SOCK_DGRAM) return 0; if (!get_set_sk_priority(ctx)) return 0; if (ctx->msg_src_ip4 == bpf_htonl(SRC1_IP4) || ctx->msg_src_ip4 == bpf_htonl(SRC2_IP4)) { ctx->msg_src_ip4 = bpf_htonl(SRC_REWRITE_IP4); } else { ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/setget_sockopt.c
static int bpf_test_sockopt_int(void *ctx, struct sock *sk, const struct sockopt_test *t, int level) { int old, tmp, new, expected, opt; opt = t->opt; new = t->new; if (sk->sk_type == SOCK_STREAM && t->tcp_expected) expected = t->tcp_expected; else expected = t->expec...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/setget_sockopt.c
int BPF_PROG(socket_post_create, struct socket *sock, int family, int type, int protocol, int kern) { struct sock *sk = sock->sk; if (!sk) return 1; nr_socket_post_create += !bpf_test_sockopt(sk, sk); nr_binddev += !binddev_test(sk); return 1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/skb_load_bytes.c
int skb_process(struct __sk_buff *skb) { char buf[16]; test_result = bpf_skb_load_bytes(skb, load_offset, buf, 10); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/socket_cookie_prog.c
int BPF_PROG(update_cookie_tracing, struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags) { struct socket_cookie *p; if (uaddr->sa_family != AF_INET6) return 0; p = bpf_sk_storage_get(&socket_cookies, sock->sk, 0, 0); if (!p) return 0; if (p->cookie_key != bpf_get_socke...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
int bpf_prog1(struct __sk_buff *skb) { void *data_end = (void *)(long)skb->data_end; void *data = (void *)(long)skb->data; __u8 *d = data; int err; if (data + 10 > data_end) { err = bpf_skb_pull_data(skb, 10); if (err) return SK_DROP; data_end = (void *)(long)skb->data_end; data = (voi...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c
int bpf_prog2(struct __sk_buff *skb) { void *data_end = (void *)(long)skb->data_end; void *data = (void *)(long)skb->data; __u32 lport = skb->local_port; __u32 rport = skb->remote_port; __u8 *d = data; __u8 sk, map; if (data + 8 > data_end) return SK_DROP; map = d[0]; sk = d[1]; d[0] = 0xd; ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/sockopt_inherit.c
int _getsockopt(struct bpf_sockopt *ctx) { __u8 *optval_end = ctx->optval_end; struct sockopt_inherit *storage; __u8 *optval = ctx->optval; if (ctx->level != SOL_CUSTOM) return 1; if (optval + 1 > optval_end) return 0; /* EPERM, bounds check */ storage = get_storage(ctx); if (!storage) retu...
[ 0, 0 ]