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/test_log_fixup.c
int bad_relo_subprog(const void *ctx) { static struct task_struct___bad *t; return bad_subprog() + bpf_core_field_size(t->pid); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_lwt_seg6local.c
__always_inline int update_tlv_pad(struct __sk_buff *skb, uint32_t new_pad, uint32_t old_pad, uint32_t pad_off) { int err; if (new_pad != old_pad) { err = bpf_lwt_seg6_adjust_srh(skb, pad_off, (int)new_pad - (int)old_pad); if (err) return err; } if (new_pad > ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_lwt_seg6local.c
static __always_inline int delete_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off) { uint32_t srh_off = (char *)srh - (char *)(long)skb->data; uint8_t len_remaining, new_pad; uint32_t partial_srh_len; uint32_t pad_off = 0; uint32_t pad_size = 0; struc...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_lwt_seg6local.c
int __encap_srh(struct __sk_buff *skb) { unsigned long long hi = 0xfd00000000000000; struct ip6_addr_t *seg; struct ip6_srh_t *srh; char srh_buf[72]; int err; srh = (struct ip6_srh_t *)srh_buf; srh->nexthdr = 0; srh->hdrlen = 8; srh->type = 4; srh->segments_left = 3; srh->first_segment = 3; srh...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_lwt_seg6local.c
int __inspect_t(struct __sk_buff *skb) { struct ip6_srh_t *srh = get_srh(skb); int table = 117; int err; if (srh == NULL) return BPF_DROP; if (srh->flags != 0) return BPF_DROP; if (srh->tag != bpf_htons(2442)) return BPF_DROP; if (srh->hdrlen != 8) return BPF_DROP; err = bpf_lwt_seg...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_map_init.c
int sysenter_getpgid(const void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; if (cur_pid == inPid) bpf_map_update_elem(&hashmap1, &inKey, &inValue, BPF_NOEXIST); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_map_lookup_percpu_elem.c
static int read_percpu_elem_callback(__u32 index, struct read_percpu_elem_ctx *ctx) { __u64 key = 0; __u64 *value; value = bpf_map_lookup_percpu_elem(ctx->map, &key, index); if (value) ctx->sum += *value; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_map_lookup_percpu_elem.c
int sysenter_getuid(const void *ctx) { struct read_percpu_elem_ctx map_ctx; if (my_pid != (bpf_get_current_pid_tgid() >> 32)) return 0; map_ctx.map = &percpu_array_map; map_ctx.sum = 0; bpf_loop(nr_cpus, read_percpu_elem_callback, &map_ctx, 0); percpu_array_elem_sum = map_ctx.sum; map_ctx.map = &pe...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_migrate_reuseport.c
int drop_ack(struct xdp_md *xdp) { void *data_end = (void *)(long)xdp->data_end; void *data = (void *)(long)xdp->data; struct ethhdr *eth = data; struct tcphdr *tcp = NULL; if (eth + 1 > data_end) goto pass; switch (bpf_ntohs(eth->h_proto)) { case ETH_P_IP: { struct iphdr *ip = (struct iphdr *)(...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
static int check_active_hdr_in(struct bpf_sock_ops *skops) { struct tcphdr *th; if (__check_active_hdr_in(skops, false) == CG_ERR) return CG_ERR; th = skops->skb_data; if (th + 1 > skops->skb_data_end) RET_CG_ERR(0); if (tcp_hdrlen(th) < skops->skb_len) nr_data++; if (th->fin) nr_fin++;...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
static int active_opt_len(struct bpf_sock_ops *skops) { int err; err = bpf_reserve_hdr_opt(skops, 12, 0); if (err) RET_CG_ERR(err); return CG_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
int misc_estab(struct bpf_sock_ops *skops) { int true_val = 1; switch (skops->op) { case BPF_SOCK_OPS_TCP_LISTEN_CB: passive_lport_h = skops->local_port; passive_lport_n = __bpf_htons(passive_lport_h); bpf_setsockopt(skops, SOL_TCP, TCP_SAVE_SYN, &true_val, sizeof(true_val)); set_hdr_cb_flags(sko...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_module_attach.c
int BPF_PROG(handle_raw_tp, struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx) { raw_tp_read_sz = BPF_CORE_READ(read_ctx, len); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_module_attach.c
int BPF_PROG(handle_raw_tp_writable_bare, struct bpf_testmod_test_writable_ctx *writable) { raw_tp_writable_bare_in_val = writable->val; writable->early_ret = raw_tp_writable_bare_early_ret; writable->val = raw_tp_writable_bare_out_val; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_module_attach.c
int BPF_PROG(handle_fentry, struct file *file, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len) { fentry_read_sz = len; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_module_attach.c
int BPF_PROG(handle_fexit, struct file *file, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len, int ret) { fexit_read_sz = len; fexit_ret = ret; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_module_attach.c
int BPF_PROG(handle_fmod_ret, struct file *file, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len) { fmod_ret_read_sz = len; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c
int handler(const void *ctx) { struct bpf_pidns_info nsdata; if (bpf_get_ns_current_pid_tgid(dev, ino, &nsdata, sizeof(struct bpf_pidns_info))) return 0; user_pid = nsdata.pid; user_tgid = nsdata.tgid; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_overhead.c
int prog3(struct bpf_raw_tracepoint_args *ctx) { return !ctx->args[0]; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_perf_buffer.c
int handle_sys_enter(void *ctx) { int zero = 0, *my_pid, cur_pid; int cpu = bpf_get_smp_processor_id(); my_pid = bpf_map_lookup_elem(&my_pid_map, &zero); if (!my_pid) return 1; cur_pid = bpf_get_current_pid_tgid() >> 32; if (cur_pid != *my_pid) return 1; bpf_perf_event_output(ctx, &perf_buf_map...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_perf_link.c
int handler(struct pt_regs *ctx) { __sync_fetch_and_add(&run_cnt, 1); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_pe_preserve_elems.c
int BPF_PROG(read_array_2) { struct bpf_perf_event_value val; return bpf_perf_event_read_value(&array_2, 0, &val, sizeof(val)); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_pkt_access.c
int get_constant(long val) { return val - 122; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_probe_read_user_str.c
int on_write(void *ctx) { if (pid != (bpf_get_current_pid_tgid() >> 32)) return 0; ret = bpf_probe_read_user_str(buf, sizeof(buf), user_ptr); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_probe_user.c
int BPF_KSYSCALL(handle_sys_socketcall, int call, unsigned long *args) { if (call == SYS_CONNECT) { struct sockaddr_in *uservaddr; bpf_probe_read_user(&uservaddr, sizeof(uservaddr), &args[1]); return handle_sys_connect_common(uservaddr); } return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_prog_array_init.c
int tailcall_1(void *ctx) { value = 42; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
int BPF_PROG(rename, struct task_struct *task, char *comm) { count++; if ((__u64)task == 0x1234ULL && (__u64)comm == 0x5678ULL) { on_cpu = bpf_get_smp_processor_id(); return (long)task + (long)comm; } return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_rdonly_maps.c
int skip_loop(struct pt_regs *ctx) { unsigned *volatile p = (void *)&rdonly_values.a; unsigned iters = 0, sum = 0; /* we should never enter this loop */ while (*p & 1) { iters++; sum += *p; p++; } res.did_run = 1; res.iters = iters; res.sum = sum; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_ringbuf.c
int test_ringbuf(void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; struct sample *sample; int zero = 0; if (cur_pid != pid) return 0; sample = bpf_ringbuf_reserve(&ringbuf, sizeof(*sample), 0); if (!sample) { __sync_fetch_and_add(&dropped, 1); return 0; } sample->pid = pid; b...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_ringbuf_map_key.c
int test_ringbuf_mem_map_key(void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; struct sample *sample, sample_copy; int *lookup_val; if (cur_pid != pid) return 0; sample = bpf_ringbuf_reserve(&ringbuf, sizeof(*sample), 0); if (!sample) return 0; sample->pid = pid; bpf_get_current_co...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_skb_cgroup_id_kern.c
int log_cgroup_id(struct __sk_buff *skb) { log_nth_level(skb, 0); log_nth_level(skb, 1); log_nth_level(skb, 2); log_nth_level(skb, 3); return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_skmsg_load_helpers.c
int prog_msg_verdict(struct sk_msg_md *msg) { struct task_struct *task = (struct task_struct *)bpf_get_current_task(); int verdict = SK_PASS; __u32 pid, tpid; __u64 *sk_stg; pid = bpf_get_current_pid_tgid() >> 32; sk_stg = bpf_sk_storage_get(&socket_storage, msg->sk, 0, BPF_SK...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_assign.c
static inline int handle_udp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4) { struct bpf_sock *sk; const int zero = 0; size_t tuple_len; __be16 dport; int ret; tuple_len = ipv4 ? sizeof(tuple->ipv4) : sizeof(tuple->ipv6); if ((void *)tuple + tuple_len > (voi...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_assign.c
static inline int handle_tcp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4) { struct bpf_sock *sk; const int zero = 0; size_t tuple_len; __be16 dport; int ret; tuple_len = ipv4 ? sizeof(tuple->ipv4) : sizeof(tuple->ipv6); if ((void *)tuple + tuple_len > (voi...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int redir_ip4(struct bpf_sk_lookup *ctx) { struct bpf_sock *sk; int err; if (ctx->family != AF_INET) return SK_PASS; if (ctx->local_port != DST_PORT) return SK_PASS; if (ctx->local_ip4 != DST_IP4) return SK_PASS; sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A); if (!sk) return SK_PAS...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int redir_ip6(struct bpf_sk_lookup *ctx) { struct bpf_sock *sk; int err; if (ctx->family != AF_INET6) return SK_PASS; if (ctx->local_port != DST_PORT) return SK_PASS; if (ctx->local_ip6[0] != DST_IP6[0] || ctx->local_ip6[1] != DST_IP6[1] || ctx->local_ip6[2] != DST_IP6[2] || ctx->local_ip6[3] !...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int select_sock_a(struct bpf_sk_lookup *ctx) { struct bpf_sock *sk; int err; sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A); if (!sk) return SK_PASS; err = bpf_sk_assign(ctx, sk, 0); bpf_sk_release(sk); return err ? SK_DROP : SK_PASS; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int sk_assign_eexist(struct bpf_sk_lookup *ctx) { struct bpf_sock *sk; int err, ret; ret = SK_DROP; sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B); if (!sk) goto out; err = bpf_sk_assign(ctx, sk, 0); if (err) goto out; bpf_sk_release(sk); sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int multi_prog_pass2(struct bpf_sk_lookup *ctx) { bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY); return SK_PASS; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup.c
int multi_prog_redir1(struct bpf_sk_lookup *ctx) { int ret; ret = select_server_a(ctx); bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY); return SK_PASS; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
static struct bpf_sock_tuple *get_tuple(void *data, __u64 nh_off, void *data_end, __u16 eth_proto, bool *ipv4) { struct bpf_sock_tuple *result; __u8 proto = 0; __u64 ihl_len; if (eth_proto == bpf_htons(ETH_P_IP)) { struct iphdr...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
int err_modify_sk_or_null_pointer(struct __sk_buff *skb) { struct bpf_sock_tuple tuple = {}; struct bpf_sock *sk; __u32 family; sk = bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); sk += 1; if (sk) bpf_sk_release(sk); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
int err_no_release(struct __sk_buff *skb) { struct bpf_sock_tuple tuple = {}; bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
int err_release_twice(struct __sk_buff *skb) { struct bpf_sock_tuple tuple = {}; struct bpf_sock *sk; sk = bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); bpf_sk_release(sk); bpf_sk_release(sk); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c
int BPF_PROG(trace_inet_csk_listen_start, struct sock *sk) { set_task_info(sk); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c
int BPF_PROG(trace_tcp_connect, struct sock *sk) { set_task_info(sk); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_snprintf_single.c
int handler(const void *ctx) { unsigned long long arg = 42; bpf_snprintf(NULL, 0, fmt, &arg, sizeof(arg)); return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sockmap_kern.h
int bpf_prog4(struct sk_msg_md *msg) { int *bytes, zero = 0, one = 1, two = 2, three = 3, four = 4, five = 5; int *start, *end, *start_push, *end_push, *start_pop, *pop, err = 0; bytes = bpf_map_lookup_elem(&sock_apply_bytes, &zero); if (bytes) bpf_msg_apply_bytes(msg, *bytes); bytes = bpf_map_lookup_ele...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sockmap_kern.h
int bpf_prog10(struct sk_msg_md *msg) { int *bytes, *start, *end, *start_push, *end_push, *start_pop, *pop; int zero = 0, one = 1, two = 2, three = 3, four = 4, five = 5, err = 0; bytes = bpf_map_lookup_elem(&sock_apply_bytes, &zero); if (bytes) bpf_msg_apply_bytes(msg, *bytes); bytes = bpf_map_lookup_el...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sockmap_progs_query.c
int prog_skmsg_verdict(struct sk_msg_md *msg) { return SK_PASS; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sockmap_skb_verdict_attach.c
int prog_skb_verdict(struct __sk_buff *skb) { return SK_DROP; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sockmap_update.c
int copy_sock_map(void *ctx) { struct bpf_sock *sk; bool failed = false; __u32 key = 0; sk = bpf_map_lookup_elem(&src, &key); if (!sk) return SK_DROP; if (bpf_map_update_elem(&dst_sock_map, &key, sk, 0)) failed = true; if (bpf_map_update_elem(&dst_sock_hash, &key, sk, 0)) failed = true; ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_spin_lock_fail.c
int lock_id_mismatch_mapval_mapval(void *ctx) { struct foo *f1, *f2; int key = 0; f1 = bpf_map_lookup_elem(&array_map, &key); if (!f1) return 0; f2 = bpf_map_lookup_elem(&array_map, &key); if (!f2) return 0; bpf_spin_lock(&f1->lock); f1->data = 42; bpf_spin_unlock(&f2->lock); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_spin_lock_fail.c
int lock_id_mismatch_innermapval_innermapval1(void *ctx) { struct foo *f1, *f2; int key = 0; void *map; map = bpf_map_lookup_elem(&map_of_maps, &key); if (!map) return 0; f1 = bpf_map_lookup_elem(map, &key); if (!f1) return 0; f2 = bpf_map_lookup_elem(map, &key); if (!f2) return 0; bpf...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_spin_lock_fail.c
int lock_id_mismatch_innermapval_innermapval2(void *ctx) { struct foo *f1, *f2; int key = 0; void *map; map = bpf_map_lookup_elem(&map_of_maps, &key); if (!map) return 0; f1 = bpf_map_lookup_elem(map, &key); if (!f1) return 0; map = bpf_map_lookup_elem(&map_of_maps, &key); if (!map) retur...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_static_linked1.c
static __noinline int subprog(int x) { return x * 2; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_static_linked2.c
static __noinline int subprog(int x) { return x * 3; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
__noinline int sub2(int y) { return sub5(y + 2); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
static __noinline int sub3(int z) { return z + 3 + sub1(4); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
__noinline int get_task_tgid(uintptr_t t) { return BPF_CORE_READ((struct task_struct *)(void *)t, tgid); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
int prog1(void *ctx) { struct task_struct *t = (void *)bpf_get_current_task(); if (!BPF_CORE_READ(t, pid) || !get_task_tgid((uintptr_t)t)) return 1; res1 = sub1(1) + sub3(2); /* (1 + 1) + (2 + 3 + (4 + 1)) = 12 */ return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
int prog2(void *ctx) { struct task_struct *t = (void *)bpf_get_current_task(); if (!BPF_CORE_READ(t, pid) || !get_task_tgid((uintptr_t)t)) return 1; res2 = sub2(3) + sub3(4); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subprogs.c
int prog3(void *ctx) { struct task_struct *t = (void *)bpf_get_current_task(); if (!BPF_CORE_READ(t, pid) || !get_task_tgid((uintptr_t)t)) return 1; bpf_loop(1, empty_callback, NULL, 0); res3 = sub3(5) + 6; /* (5 + 3 + (4 + 1)) + 6 = 19 */ return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_subskeleton_lib.c
int lib_routine(void) { __u32 key = 1, value = 2; (void)CONFIG_BPF_SYSCALL; bpf_map_update_elem(&map2, &key, &value, BPF_ANY); libout1 = var1 + var2 + var3.var3_1 + var3.var3_2 + var5 + var6; return libout1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_sysctl_prog.c
int sysctl_tcp_mem(struct bpf_sysctl *ctx) { unsigned long tcp_mem[3] = {0, 0, 0}; char value[MAX_VALUE_STR_LEN]; unsigned char i, off = 0; volatile int ret; if (ctx->write) return 0; if (!is_tcp_mem(ctx)) return 0; ret = bpf_sysctl_get_current_value(ctx, value, MAX_VALUE_STR_LEN); if (ret < ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
static __always_inline int get_tp_window_clamp(struct bpf_sock_ops *skops) { struct bpf_sock *sk; struct tcp_sock *tp; sk = skops->sk; if (!sk) return -1; tp = bpf_skc_to_tcp_sock(sk); if (!tp) return -1; return tp->window_clamp; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c
int check_syncookie_clsact(struct __sk_buff *skb) { check_syncookie(skb, (void *)(long)skb->data, (void *)(long)skb->data_end); return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int store_option(struct bpf_sock_ops *skops, const struct bpf_test_option *test_opt) { union { struct tcp_exprm_opt exprm; struct tcp_opt regular; } write_opt; int err; if (test_kind == TCPOPT_EXP) { write_opt.exprm.kind = TCPOPT_EXP; write_opt.exprm.len = option...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int write_syn_opt(struct bpf_sock_ops *skops) { if (!active_syn_out.flags) RET_CG_ERR(0); return store_option(skops, &active_syn_out); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int nodata_opt_len(struct bpf_sock_ops *skops) { int resend; resend = resend_in_ack(skops); if (resend < 0) RET_CG_ERR(0); if (resend) return syn_opt_len(skops); return CG_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int data_opt_len(struct bpf_sock_ops *skops) { return nodata_opt_len(skops); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int write_data_opt(struct bpf_sock_ops *skops) { return write_nodata_opt(skops); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int handle_hdr_opt_len(struct bpf_sock_ops *skops) { __u8 tcp_flags = skops_tcp_flags(skops); if ((tcp_flags & TCPHDR_SYNACK) == TCPHDR_SYNACK) return synack_opt_len(skops); if (tcp_flags & TCPHDR_SYN) return syn_opt_len(skops); if (tcp_flags & TCPHDR_FIN) return fin_opt_len(skops); if ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int set_delack_max(struct bpf_sock_ops *skops, __u8 max_delack_ms) { __u32 max_delack_us = max_delack_ms * 1000; return bpf_setsockopt(skops, SOL_TCP, TCP_BPF_DELACK_MAX, &max_delack_us, sizeof(max_delack_us)); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
static int handle_parse_hdr(struct bpf_sock_ops *skops) { struct hdr_stg *hdr_stg; struct tcphdr *th; if (!skops->sk) RET_CG_ERR(0); th = skops->skb_data; if (th + 1 > skops->skb_data_end) RET_CG_ERR(0); hdr_stg = bpf_sk_storage_get(&hdr_stg_map, skops->sk, NULL, 0); if (!hdr_stg) RET_CG_ER...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tcp_hdr_options.c
int estab(struct bpf_sock_ops *skops) { int true_val = 1; switch (skops->op) { case BPF_SOCK_OPS_TCP_LISTEN_CB: bpf_setsockopt(skops, SOL_TCP, TCP_SAVE_SYN, &true_val, sizeof(true_val)); set_hdr_cb_flags(skops, BPF_SOCK_OPS_STATE_CB_FLAG); break; case BPF_SOCK_OPS_TCP_CONNECT_CB: set_hdr_cb_fla...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_bpf.c
int cls(struct __sk_buff *skb) { return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_dtime.c
static void inc_errs(__u32 idx) { if (test < __NR_TESTS) errs[test][idx]++; else errs[UKN_TEST][idx]++; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_dtime.c
static int skb_ns(int type) { return (type >> 8) & 0xff; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_dtime.c
int ingress_host(struct __sk_buff *skb) { int skb_type; skb_type = skb_get_type(skb); if (skb_type == -1) return TC_ACT_SHOT; if (!skb_type) return TC_ACT_OK; if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO && skb->tstamp == EGRESS_FWDNS_MAGIC) inc_dtimes(INGRESS_ENDHOST); else ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
static __always_inline int fill_fib_params_v4(struct __sk_buff *skb, struct bpf_fib_lookup *fib_params) { void *data_end = ctx_ptr(skb->data_end); void *data = ctx_ptr(skb->data); struct iphdr *ip4h; if (data + sizeof(struct ethhdr) > data_end) return -1; ip4h = (struct iphdr *)(data + sizeof(struct et...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
int tc_chk(struct __sk_buff *skb) { void *data_end = ctx_ptr(skb->data_end); void *data = ctx_ptr(skb->data); __u32 *raw = data; if (data + sizeof(struct ethhdr) > data_end) return TC_ACT_SHOT; return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
int tc_dst(struct __sk_buff *skb) { return tc_redir(skb); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_peer.c
int tc_chk(struct __sk_buff *skb) { return TC_ACT_SHOT; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_peer.c
int tc_src(struct __sk_buff *skb) { return bpf_redirect_peer(IFINDEX_DST, 0); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_peer.c
int tc_src_l3(struct __sk_buff *skb) { __u16 proto = skb->protocol; if (bpf_skb_change_head(skb, ETH_HLEN, 0) != 0) return TC_ACT_SHOT; if (bpf_skb_store_bytes(skb, 0, &src_mac, ETH_ALEN, 0) != 0) return TC_ACT_SHOT; if (bpf_skb_store_bytes(skb, ETH_ALEN, &dst_mac, ETH_ALEN, 0) != 0) return TC_AC...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
static __always_inline int encap_ipv6(struct __sk_buff *skb, __u8 encap_proto, __u16 l2_proto) { return __encap_ipv6(skb, encap_proto, l2_proto, 0); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
int __encap_gre_eth(struct __sk_buff *skb) { if (skb->protocol == __bpf_constant_htons(ETH_P_IP)) return encap_ipv4(skb, IPPROTO_GRE, ETH_P_TEB); else return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
int __encap_udp_mpls(struct __sk_buff *skb) { if (skb->protocol == __bpf_constant_htons(ETH_P_IP)) return encap_ipv4(skb, IPPROTO_UDP, ETH_P_MPLS_UC); else return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
int __encap_vxlan_eth(struct __sk_buff *skb) { if (skb->protocol == __bpf_constant_htons(ETH_P_IP)) return __encap_ipv4(skb, IPPROTO_UDP, ETH_P_TEB, EXTPROTO_VXLAN); else return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
int __encap_ip6tnl_none(struct __sk_buff *skb) { if (skb->protocol == __bpf_constant_htons(ETH_P_IPV6)) return encap_ipv6(skb, IPPROTO_IPV6, ETH_P_IPV6); else return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tc_tunnel.c
int __encap_ip6udp_mpls(struct __sk_buff *skb) { if (skb->protocol == __bpf_constant_htons(ETH_P_IPV6)) return encap_ipv6(skb, IPPROTO_UDP, ETH_P_MPLS_UC); else return TC_ACT_OK; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_time_tai.c
int time_tai(struct __sk_buff *skb) { __u64 ts1, ts2; ts1 = bpf_ktime_get_tai_ns(); ts2 = bpf_ktime_get_tai_ns(); /* Save TAI timestamps (Note: skb->hwtstamp is read-only) */ skb->tstamp = ts1; skb->cb[0] = ts2 & 0xffffffff; skb->cb[1] = ts2 >> 32; return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_trace_ext_tracing.c
int BPF_PROG(fexit, struct sk_buff *skb) { fexit_called = skb->len; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int gre_set_tunnel(struct __sk_buff *skb) { int ret; struct bpf_tunnel_key key; __builtin_memset(&key, 0x0, sizeof(key)); key.remote_ipv4 = 0xac100164; key.tunnel_id = 2; key.tunnel_tos = 0; key.tunnel_ttl = 64; ret = bpf_skb_set_tunnel_key(skb, &key, sizeof(key), BPF_F_...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int gre_get_tunnel(struct __sk_buff *skb) { int ret; struct bpf_tunnel_key key; ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); if (ret < 0) { log_err(ret); return TC_ACT_SHOT; } bpf_printk("key %d remote ip 0x%x\n", key.tunnel_id, key.remote_ipv4); return TC_ACT_OK; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int ip6gretap_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key; int ret; __builtin_memset(&key, 0x0, sizeof(key)); key.remote_ipv6[3] = bpf_htonl(0x11); key.tunnel_id = 2; key.tunnel_tos = 0; key.tunnel_ttl = 64; key.tunnel_label = 0xabcde; ret = bpf_skb_set_tunnel_key(skb, &key, sizeof...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int ip6gretap_get_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key; int ret; ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), BPF_F_TUNINFO_IPV6); if (ret < 0) { log_err(ret); return TC_ACT_SHOT; } bpf_printk("key %d remote ip6 ::%x label %x\n", key.tunnel_id, key.remote_...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int ip4ip6erspan_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key; struct erspan_metadata md; int ret; __builtin_memset(&key, 0x0, sizeof(key)); key.remote_ipv6[3] = bpf_htonl(0x11); key.tunnel_id = 2; key.tunnel_tos = 0; key.tunnel_ttl = 64; ret = bpf_skb_set_tunnel_key(skb, &key, size...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
int vxlan_set_tunnel_dst(struct __sk_buff *skb) { int ret; struct bpf_tunnel_key key; struct vxlan_metadata md; __u32 index = 0; __u32 *local_ip = NULL; local_ip = bpf_map_lookup_elem(&local_ip_map, &index); if (!local_ip) { log_err(ret); return TC_ACT_SHOT; } __builtin_memset(&key, 0x0, siz...
[ 1, 0 ]