/tools/testing/selftests/bpf/progs/ |
D | test_sk_lookup.c | 76 int lookup_pass(struct bpf_sk_lookup *ctx) in lookup_pass() argument 82 int lookup_drop(struct bpf_sk_lookup *ctx) in lookup_drop() argument 88 int reuseport_pass(struct sk_reuseport_md *ctx) in reuseport_pass() argument 94 int reuseport_drop(struct sk_reuseport_md *ctx) in reuseport_drop() argument 101 int redir_port(struct bpf_sk_lookup *ctx) in redir_port() argument 106 if (ctx->local_port != DST_PORT) in redir_port() 113 err = bpf_sk_assign(ctx, sk, 0); in redir_port() 120 int redir_ip4(struct bpf_sk_lookup *ctx) in redir_ip4() argument 125 if (ctx->family != AF_INET) in redir_ip4() 127 if (ctx->local_port != DST_PORT) in redir_ip4() [all …]
|
D | sockopt_sk.c | 29 int _getsockopt(struct bpf_sockopt *ctx) in _getsockopt() argument 31 __u8 *optval_end = ctx->optval_end; in _getsockopt() 32 __u8 *optval = ctx->optval; in _getsockopt() 35 if (ctx->level == SOL_IP && ctx->optname == IP_TOS) { in _getsockopt() 40 ctx->optlen = 0; /* bypass optval>PAGE_SIZE */ in _getsockopt() 44 if (ctx->level == SOL_SOCKET && ctx->optname == SO_SNDBUF) { in _getsockopt() 52 if (ctx->level == SOL_TCP && ctx->optname == TCP_CONGESTION) { in _getsockopt() 60 if (ctx->level == SOL_IP && ctx->optname == IP_FREEBIND) { in _getsockopt() 64 ctx->retval = 0; /* Reset system call return value to zero */ in _getsockopt() 68 ctx->optlen = 1; in _getsockopt() [all …]
|
D | connect_force_port6.c | 28 int connect6(struct bpf_sock_addr *ctx) in connect6() argument 38 if (bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa)) != 0) in connect6() 42 if (ctx->user_port == bpf_htons(60000)) { in connect6() 43 orig = bpf_sk_storage_get(&service_mapping, ctx->sk, 0, in connect6() 48 orig->addr[0] = ctx->user_ip6[0]; in connect6() 49 orig->addr[1] = ctx->user_ip6[1]; in connect6() 50 orig->addr[2] = ctx->user_ip6[2]; in connect6() 51 orig->addr[3] = ctx->user_ip6[3]; in connect6() 52 orig->port = ctx->user_port; in connect6() 54 ctx->user_ip6[0] = 0; in connect6() [all …]
|
D | sockopt_multi.c | 10 int _getsockopt_child(struct bpf_sockopt *ctx) in _getsockopt_child() argument 12 __u8 *optval_end = ctx->optval_end; in _getsockopt_child() 13 __u8 *optval = ctx->optval; in _getsockopt_child() 15 if (ctx->level != SOL_IP || ctx->optname != IP_TOS) in _getsockopt_child() 24 ctx->retval = 0; /* Reset system call return value to zero */ in _getsockopt_child() 27 ctx->optlen = 1; in _getsockopt_child() 33 int _getsockopt_parent(struct bpf_sockopt *ctx) in _getsockopt_parent() argument 35 __u8 *optval_end = ctx->optval_end; in _getsockopt_parent() 36 __u8 *optval = ctx->optval; in _getsockopt_parent() 38 if (ctx->level != SOL_IP || ctx->optname != IP_TOS) in _getsockopt_parent() [all …]
|
D | connect4_prog.c | 37 int do_bind(struct bpf_sock_addr *ctx) in do_bind() argument 45 if (bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa)) != 0) in do_bind() 51 static __inline int verify_cc(struct bpf_sock_addr *ctx, in verify_cc() argument 57 if (bpf_getsockopt(ctx, SOL_TCP, TCP_CONGESTION, &buf, sizeof(buf))) in verify_cc() 70 static __inline int set_cc(struct bpf_sock_addr *ctx) in set_cc() argument 75 if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &reno, sizeof(reno))) in set_cc() 77 if (verify_cc(ctx, reno)) in set_cc() 80 if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &cubic, sizeof(cubic))) in set_cc() 82 if (verify_cc(ctx, cubic)) in set_cc() 88 static __inline int bind_to_device(struct bpf_sock_addr *ctx) in bind_to_device() argument [all …]
|
D | sendmsg6_prog.c | 26 int sendmsg_v6_prog(struct bpf_sock_addr *ctx) in sendmsg_v6_prog() argument 28 if (ctx->type != SOCK_DGRAM) in sendmsg_v6_prog() 32 if (ctx->msg_src_ip6[3] == bpf_htonl(1) || in sendmsg_v6_prog() 33 ctx->msg_src_ip6[3] == bpf_htonl(0)) { in sendmsg_v6_prog() 34 ctx->msg_src_ip6[0] = bpf_htonl(SRC_REWRITE_IP6_0); in sendmsg_v6_prog() 35 ctx->msg_src_ip6[1] = bpf_htonl(SRC_REWRITE_IP6_1); in sendmsg_v6_prog() 36 ctx->msg_src_ip6[2] = bpf_htonl(SRC_REWRITE_IP6_2); in sendmsg_v6_prog() 37 ctx->msg_src_ip6[3] = bpf_htonl(SRC_REWRITE_IP6_3); in sendmsg_v6_prog() 44 if (ctx->user_ip6[0] == bpf_htonl(0xFACEB00C)) { in sendmsg_v6_prog() 45 ctx->user_ip6[0] = bpf_htonl(DST_REWRITE_IP6_0); in sendmsg_v6_prog() [all …]
|
D | connect_force_port4.c | 29 int connect4(struct bpf_sock_addr *ctx) in connect4() argument 39 if (bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa)) != 0) in connect4() 43 if (ctx->user_port == bpf_htons(60000)) { in connect4() 44 orig = bpf_sk_storage_get(&service_mapping, ctx->sk, 0, in connect4() 49 orig->addr = ctx->user_ip4; in connect4() 50 orig->port = ctx->user_port; in connect4() 52 ctx->user_ip4 = bpf_htonl(0x7f000001); in connect4() 53 ctx->user_port = bpf_htons(60123); in connect4() 59 int getsockname4(struct bpf_sock_addr *ctx) in getsockname4() argument 62 if (ctx->user_port == bpf_htons(60123)) { in getsockname4() [all …]
|
D | sockopt_inherit.c | 38 static __inline struct sockopt_inherit *get_storage(struct bpf_sockopt *ctx) in get_storage() argument 40 if (ctx->optname == CUSTOM_INHERIT1) in get_storage() 41 return bpf_sk_storage_get(&cloned1_map, ctx->sk, 0, in get_storage() 43 else if (ctx->optname == CUSTOM_INHERIT2) in get_storage() 44 return bpf_sk_storage_get(&cloned2_map, ctx->sk, 0, in get_storage() 47 return bpf_sk_storage_get(&listener_only_map, ctx->sk, 0, in get_storage() 52 int _getsockopt(struct bpf_sockopt *ctx) in _getsockopt() argument 54 __u8 *optval_end = ctx->optval_end; in _getsockopt() 56 __u8 *optval = ctx->optval; in _getsockopt() 58 if (ctx->level != SOL_CUSTOM) in _getsockopt() [all …]
|
D | socket_cookie_prog.c | 23 int set_cookie(struct bpf_sock_addr *ctx) in set_cookie() argument 27 if (ctx->family != AF_INET6 || ctx->user_family != AF_INET6) in set_cookie() 30 p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, in set_cookie() 36 p->cookie_key = bpf_get_socket_cookie(ctx); in set_cookie() 42 int update_cookie(struct bpf_sock_ops *ctx) in update_cookie() argument 47 if (ctx->family != AF_INET6) in update_cookie() 50 if (ctx->op != BPF_SOCK_OPS_TCP_CONNECT_CB) in update_cookie() 53 if (!ctx->sk) in update_cookie() 56 p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, 0); in update_cookie() 60 if (p->cookie_key != bpf_get_socket_cookie(ctx)) in update_cookie() [all …]
|
D | sendmsg4_prog.c | 22 int sendmsg_v4_prog(struct bpf_sock_addr *ctx) in sendmsg_v4_prog() argument 24 if (ctx->type != SOCK_DGRAM) in sendmsg_v4_prog() 28 if (ctx->msg_src_ip4 == bpf_htonl(SRC1_IP4) || in sendmsg_v4_prog() 29 ctx->msg_src_ip4 == bpf_htonl(SRC2_IP4)) { in sendmsg_v4_prog() 30 ctx->msg_src_ip4 = bpf_htonl(SRC_REWRITE_IP4); in sendmsg_v4_prog() 37 if ((ctx->user_ip4 >> 24) == (bpf_htonl(DST_IP4) >> 24) && in sendmsg_v4_prog() 38 ctx->user_port == bpf_htons(DST_PORT)) { in sendmsg_v4_prog() 39 ctx->user_ip4 = bpf_htonl(DST_REWRITE_IP4); in sendmsg_v4_prog() 40 ctx->user_port = bpf_htons(DST_REWRITE_PORT4); in sendmsg_v4_prog()
|
D | test_xdp_meta.c | 9 #define ctx_ptr(ctx, mem) (void *)(unsigned long)ctx->mem argument 12 int ing_cls(struct __sk_buff *ctx) in ing_cls() argument 17 data_meta = ctx_ptr(ctx, data_meta); in ing_cls() 18 data_end = ctx_ptr(ctx, data_end); in ing_cls() 19 data = ctx_ptr(ctx, data); in ing_cls() 32 int ing_xdp(struct xdp_md *ctx) in ing_xdp() argument 37 ret = bpf_xdp_adjust_meta(ctx, -round_up(ETH_ALEN, 4)); in ing_xdp() 41 data_meta = ctx_ptr(ctx, data_meta); in ing_xdp() 42 data_end = ctx_ptr(ctx, data_end); in ing_xdp() 43 data = ctx_ptr(ctx, data); in ing_xdp()
|
D | test_send_signal_kern.c | 9 static __always_inline int bpf_send_signal_test(void *ctx) in bpf_send_signal_test() argument 29 int send_signal_tp(void *ctx) in send_signal_tp() argument 31 return bpf_send_signal_test(ctx); in send_signal_tp() 35 int send_signal_tp_sched(void *ctx) in send_signal_tp_sched() argument 37 return bpf_send_signal_test(ctx); in send_signal_tp_sched() 41 int send_signal_perf(void *ctx) in send_signal_perf() argument 43 return bpf_send_signal_test(ctx); in send_signal_perf()
|
D | connect6_prog.c | 30 int connect_v6_prog(struct bpf_sock_addr *ctx) in connect_v6_prog() argument 47 if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM) in connect_v6_prog() 49 else if (ctx->type == SOCK_STREAM) in connect_v6_prog() 50 sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv6), in connect_v6_prog() 53 sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv6), in connect_v6_prog() 71 ctx->user_ip6[0] = bpf_htonl(DST_REWRITE_IP6_0); in connect_v6_prog() 72 ctx->user_ip6[1] = bpf_htonl(DST_REWRITE_IP6_1); in connect_v6_prog() 73 ctx->user_ip6[2] = bpf_htonl(DST_REWRITE_IP6_2); in connect_v6_prog() 74 ctx->user_ip6[3] = bpf_htonl(DST_REWRITE_IP6_3); in connect_v6_prog() 76 ctx->user_port = bpf_htons(DST_REWRITE_PORT6); in connect_v6_prog() [all …]
|
D | dev_cgroup.c | 13 int bpf_prog1(struct bpf_cgroup_dev_ctx *ctx) in bpf_prog1() argument 15 short type = ctx->access_type & 0xFFFF; in bpf_prog1() 17 short access = ctx->access_type >> 16; in bpf_prog1() 41 bpf_trace_printk(fmt, sizeof(fmt), ctx->major, ctx->minor); in bpf_prog1() 47 if (ctx->major != 1 || type != BPF_DEVCG_DEV_CHAR) in bpf_prog1() 50 switch (ctx->minor) { in bpf_prog1()
|
D | test_xdp_with_devmap_helpers.c | 13 int xdp_redir_prog(struct xdp_md *ctx) in xdp_redir_prog() argument 22 int xdp_dummy_prog(struct xdp_md *ctx) in xdp_dummy_prog() argument 31 int xdp_dummy_dm(struct xdp_md *ctx) in xdp_dummy_dm() argument 34 void *data_end = (void *)(long)ctx->data_end; in xdp_dummy_dm() 35 void *data = (void *)(long)ctx->data; in xdp_dummy_dm() 39 ctx->ingress_ifindex, ctx->egress_ifindex, len); in xdp_dummy_dm()
|
/tools/testing/selftests/filesystems/epoll/ |
D | epoll_wakeup_test.c | 28 static void kill_timeout(struct epoll_mtcontext *ctx) in kill_timeout() argument 31 pthread_kill(ctx->main, SIGUSR1); in kill_timeout() 32 pthread_kill(ctx->waiter, SIGUSR1); in kill_timeout() 38 struct epoll_mtcontext *ctx = data; in waiter_entry1a() local 40 if (epoll_wait(ctx->efd[0], &e, 1, -1) > 0) in waiter_entry1a() 41 __sync_fetch_and_add(&ctx->count, 1); in waiter_entry1a() 50 struct epoll_mtcontext *ctx = data; in waiter_entry1ap() local 52 pfd.fd = ctx->efd[0]; in waiter_entry1ap() 55 if (epoll_wait(ctx->efd[0], &e, 1, 0) > 0) in waiter_entry1ap() 56 __sync_fetch_and_add(&ctx->count, 1); in waiter_entry1ap() [all …]
|
/tools/perf/tests/ |
D | expr.c | 9 static int test(struct expr_parse_ctx *ctx, const char *e, double val2) in test() argument 13 if (expr__parse(&val, ctx, e, 1)) in test() 25 struct expr_parse_ctx ctx; in test__expr() local 27 expr__ctx_init(&ctx); in test__expr() 28 expr__add_id_val(&ctx, strdup("FOO"), 1); in test__expr() 29 expr__add_id_val(&ctx, strdup("BAR"), 2); in test__expr() 31 ret = test(&ctx, "1+1", 2); in test__expr() 32 ret |= test(&ctx, "FOO+BAR", 3); in test__expr() 33 ret |= test(&ctx, "(BAR/2)%2", 1); in test__expr() 34 ret |= test(&ctx, "1 - -4", 5); in test__expr() [all …]
|
/tools/perf/util/ |
D | stat-shadow.c | 29 int ctx; member 57 if (a->ctx != b->ctx) in saved_value_cmp() 58 return a->ctx - b->ctx; in saved_value_cmp() 102 int ctx, in saved_value_lookup() argument 111 .ctx = ctx, in saved_value_lookup() 151 int ctx = 0; in evsel_context() local 154 ctx |= CTX_BIT_KERNEL; in evsel_context() 156 ctx |= CTX_BIT_USER; in evsel_context() 158 ctx |= CTX_BIT_HV; in evsel_context() 160 ctx |= CTX_BIT_HOST; in evsel_context() [all …]
|
D | expr.c | 20 static size_t key_hash(const void *key, void *ctx __maybe_unused) in key_hash() 34 void *ctx __maybe_unused) in key_equal() 40 int expr__add_id(struct expr_parse_ctx *ctx, const char *id) in expr__add_id() argument 50 data_ptr->parent = ctx->parent; in expr__add_id() 52 ret = hashmap__set(&ctx->ids, id, data_ptr, in expr__add_id() 62 int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val) in expr__add_id_val() argument 74 ret = hashmap__set(&ctx->ids, id, data_ptr, in expr__add_id_val() 83 int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref) in expr__add_ref() argument 120 ret = hashmap__set(&ctx->ids, name, data_ptr, in expr__add_ref() 133 int expr__get_id(struct expr_parse_ctx *ctx, const char *id, in expr__get_id() argument [all …]
|
D | expr.h | 45 void expr__ctx_init(struct expr_parse_ctx *ctx); 46 void expr__ctx_clear(struct expr_parse_ctx *ctx); 47 void expr__del_id(struct expr_parse_ctx *ctx, const char *id); 48 int expr__add_id(struct expr_parse_ctx *ctx, const char *id); 49 int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val); 50 int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref); 51 int expr__get_id(struct expr_parse_ctx *ctx, const char *id, 53 int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id, 55 int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
|
/tools/testing/selftests/bpf/benchs/ |
D | bench_count.c | 13 struct count_global_ctx *ctx = &count_global_ctx; in count_global_producer() local 16 atomic_inc(&ctx->hits.value); in count_global_producer() 28 struct count_global_ctx *ctx = &count_global_ctx; in count_global_measure() local 30 res->hits = atomic_swap(&ctx->hits.value, 0); in count_global_measure() 41 struct count_local_ctx *ctx = &count_local_ctx; in count_local_setup() local 43 ctx->hits = calloc(env.consumer_cnt, sizeof(*ctx->hits)); in count_local_setup() 44 if (!ctx->hits) in count_local_setup() 50 struct count_local_ctx *ctx = &count_local_ctx; in count_local_producer() local 54 atomic_inc(&ctx->hits[idx].value); in count_local_producer() 66 struct count_local_ctx *ctx = &count_local_ctx; in count_local_measure() local [all …]
|
D | bench_ringbufs.c | 129 struct ringbuf_libbpf_ctx *ctx = &ringbuf_libbpf_ctx; in ringbuf_libbpf_measure() local 132 res->drops = atomic_swap(&ctx->skel->bss->dropped, 0); in ringbuf_libbpf_measure() 164 static int buf_process_sample(void *ctx, void *data, size_t len) in buf_process_sample() argument 172 struct ringbuf_libbpf_ctx *ctx = &ringbuf_libbpf_ctx; in ringbuf_libbpf_setup() local 175 ctx->skel = ringbuf_setup_skeleton(); in ringbuf_libbpf_setup() 176 ctx->ringbuf = ring_buffer__new(bpf_map__fd(ctx->skel->maps.ringbuf), in ringbuf_libbpf_setup() 178 if (!ctx->ringbuf) { in ringbuf_libbpf_setup() 183 link = bpf_program__attach(ctx->skel->progs.bench_ringbuf); in ringbuf_libbpf_setup() 192 struct ringbuf_libbpf_ctx *ctx = &ringbuf_libbpf_ctx; in ringbuf_libbpf_consumer() local 194 while (ring_buffer__poll(ctx->ringbuf, -1) >= 0) { in ringbuf_libbpf_consumer() [all …]
|
/tools/perf/bench/ |
D | sched-messaging.c | 81 static void *sender(struct sender_context *ctx) in sender() argument 86 ready(ctx->ready_out, ctx->wakefd); in sender() 91 for (j = 0; j < ctx->num_fds; j++) { in sender() 95 ret = write(ctx->out_fds[j], data + done, in sender() 110 static void *receiver(struct receiver_context* ctx) in receiver() argument 115 close(ctx->in_fds[1]); in receiver() 118 ready(ctx->ready_out, ctx->wakefd); in receiver() 121 for (i = 0; i < ctx->num_packets; i++) { in receiver() 126 ret = read(ctx->in_fds[0], data + done, DATASIZE - done); in receiver() 137 static pthread_t create_worker(void *ctx, void *(*func)(void *)) in create_worker() argument [all …]
|
/tools/lib/bpf/ |
D | xsk.c | 78 struct xsk_ctx *ctx; member 359 struct xsk_ctx *ctx = xsk->ctx; in xsk_load_xdp_prog() local 387 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), in xsk_load_xdp_prog() 399 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), in xsk_load_xdp_prog() 411 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd), in xsk_load_xdp_prog() 429 err = bpf_set_link_xdp_fd(xsk->ctx->ifindex, prog_fd, in xsk_load_xdp_prog() 436 ctx->prog_fd = prog_fd; in xsk_load_xdp_prog() 443 struct xsk_ctx *ctx = xsk->ctx; in xsk_get_max_queues() local 452 memcpy(ifr.ifr_name, ctx->ifname, IFNAMSIZ - 1); in xsk_get_max_queues() 480 struct xsk_ctx *ctx = xsk->ctx; in xsk_create_bpf_maps() local [all …]
|
/tools/testing/selftests/x86/ |
D | unwind_vdso.c | 68 _Unwind_Reason_Code trace_fn(struct _Unwind_Context * ctx, void *opaque) in trace_fn() argument 71 unsigned long ip = _Unwind_GetIP(ctx); in trace_fn() 83 unsigned long eax = _Unwind_GetGR(ctx, 0); in trace_fn() 84 unsigned long ecx = _Unwind_GetGR(ctx, 1); in trace_fn() 85 unsigned long edx = _Unwind_GetGR(ctx, 2); in trace_fn() 86 unsigned long ebx = _Unwind_GetGR(ctx, 3); in trace_fn() 87 unsigned long ebp = _Unwind_GetGR(ctx, 5); in trace_fn() 88 unsigned long esi = _Unwind_GetGR(ctx, 6); in trace_fn() 89 unsigned long edi = _Unwind_GetGR(ctx, 7); in trace_fn() 109 ucontext_t *ctx = (ucontext_t *)ctx_void; in sigtrap() local [all …]
|