/tools/testing/selftests/bpf/progs/ |
D | sockopt_sk.c | 26 int _getsockopt(struct bpf_sockopt *ctx) in _getsockopt() argument 28 __u8 *optval_end = ctx->optval_end; in _getsockopt() 29 __u8 *optval = ctx->optval; in _getsockopt() 32 if (ctx->level == SOL_IP && ctx->optname == IP_TOS) in _getsockopt() 39 if (ctx->level == SOL_SOCKET && ctx->optname == SO_SNDBUF) { in _getsockopt() 47 if (ctx->level == SOL_TCP && ctx->optname == TCP_CONGESTION) { in _getsockopt() 55 if (ctx->level != SOL_CUSTOM) in _getsockopt() 61 storage = bpf_sk_storage_get(&socket_storage_map, ctx->sk, 0, in _getsockopt() 66 if (!ctx->retval) in _getsockopt() 70 ctx->retval = 0; /* Reset system call return value to zero */ in _getsockopt() [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 | 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 | 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 | 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 | 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 | test_xdp_vlan.c | 106 int xdp_prognum0(struct xdp_md *ctx) in xdp_prognum0() argument 108 void *data_end = (void *)(long)ctx->data_end; in xdp_prognum0() 109 void *data = (void *)(long)ctx->data; in xdp_prognum0() 148 int xdp_prognum1(struct xdp_md *ctx) in xdp_prognum1() argument 150 void *data_end = (void *)(long)ctx->data_end; in xdp_prognum1() 151 void *data = (void *)(long)ctx->data; in xdp_prognum1() 182 int xdp_prognum2(struct xdp_md *ctx) in xdp_prognum2() argument 184 void *data_end = (void *)(long)ctx->data_end; in xdp_prognum2() 185 void *data = (void *)(long)ctx->data; in xdp_prognum2() 207 bpf_xdp_adjust_head(ctx, VLAN_HDR_SZ); in xdp_prognum2() [all …]
|
D | connect4_prog.c | 22 int connect_v4_prog(struct bpf_sock_addr *ctx) in connect_v4_prog() argument 35 if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM) in connect_v4_prog() 37 else if (ctx->type == SOCK_STREAM) in connect_v4_prog() 38 sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv4), in connect_v4_prog() 41 sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv4), in connect_v4_prog() 56 ctx->user_ip4 = bpf_htonl(DST_REWRITE_IP4); in connect_v4_prog() 57 ctx->user_port = bpf_htons(DST_REWRITE_PORT4); in connect_v4_prog() 66 if (bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa)) != 0) in connect_v4_prog()
|
D | test_get_stack_rawtp.c | 58 int bpf_prog1(void *ctx) in bpf_prog1() argument 72 data->kern_stack_size = bpf_get_stack(ctx, data->kern_stack, in bpf_prog1() 74 data->user_stack_size = bpf_get_stack(ctx, data->user_stack, max_len, in bpf_prog1() 77 ctx, data->user_stack_buildid, max_buildid_len, in bpf_prog1() 79 bpf_perf_event_output(ctx, &perfmap, 0, data, sizeof(*data)); in bpf_prog1() 86 usize = bpf_get_stack(ctx, raw_data, max_len, BPF_F_USER_STACK); in bpf_prog1() 90 ksize = bpf_get_stack(ctx, raw_data + usize, max_len - usize, 0); in bpf_prog1() 96 bpf_perf_event_output(ctx, &perfmap, 0, raw_data, total_size); in bpf_prog1()
|
D | test_sysctl_loop2.c | 22 static __attribute__((noinline)) int is_tcp_mem(struct bpf_sysctl *ctx) in is_tcp_mem() argument 29 ret = bpf_sysctl_get_name(ctx, name, sizeof(name), 0); in is_tcp_mem() 43 int sysctl_tcp_mem(struct bpf_sysctl *ctx) in sysctl_tcp_mem() argument 50 if (ctx->write) in sysctl_tcp_mem() 53 if (!is_tcp_mem(ctx)) in sysctl_tcp_mem() 56 ret = bpf_sysctl_get_current_value(ctx, value, MAX_VALUE_STR_LEN); in sysctl_tcp_mem()
|
/tools/perf/tests/ |
D | expr.c | 9 static int test(struct parse_ctx *ctx, const char *e, double val2) in test() argument 13 if (expr__parse(&val, ctx, &e)) in test() 25 struct parse_ctx ctx; in test__expr() local 28 expr__ctx_init(&ctx); in test__expr() 29 expr__add_id(&ctx, "FOO", 1); in test__expr() 30 expr__add_id(&ctx, "BAR", 2); in test__expr() 32 ret = test(&ctx, "1+1", 2); in test__expr() 33 ret |= test(&ctx, "FOO+BAR", 3); in test__expr() 34 ret |= test(&ctx, "(BAR/2)%2", 1); in test__expr() 35 ret |= test(&ctx, "1 - -4", 5); in test__expr() [all …]
|
/tools/testing/selftests/bpf/ |
D | bpf_helpers.h | 45 static void (*bpf_tail_call)(void *ctx, void *map, int index) = 58 static int (*bpf_clone_redirect)(void *ctx, int ifindex, int flags) = 64 static int (*bpf_perf_event_output)(void *ctx, void *map, 68 static int (*bpf_get_stackid)(void *ctx, void *map, int flags) = 74 static int (*bpf_skb_get_tunnel_key)(void *ctx, void *key, int size, int flags) = 76 static int (*bpf_skb_set_tunnel_key)(void *ctx, void *key, int size, int flags) = 78 static int (*bpf_skb_get_tunnel_opt)(void *ctx, void *md, int size) = 80 static int (*bpf_skb_set_tunnel_opt)(void *ctx, void *md, int size) = 84 static int (*bpf_xdp_adjust_head)(void *ctx, int offset) = 86 static int (*bpf_xdp_adjust_meta)(void *ctx, int offset) = [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.y | 18 %parse-param { struct parse_ctx *ctx } 43 struct parse_ctx *ctx __maybe_unused, 50 static int lookup_id(struct parse_ctx *ctx, char *id, double *val) 54 for (i = 0; i < ctx->num_ids; i++) { 55 if (!strcasecmp(ctx->ids[i].name, id)) { 56 *val = ctx->ids[i].val; 75 | ID { if (lookup_id(ctx, $1, &$$) < 0) { 173 void expr__add_id(struct parse_ctx *ctx, const char *name, double val) 176 assert(ctx->num_ids < MAX_PARSE_ID); 177 idx = ctx->num_ids++; [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/subcmd/ |
D | parse-options.c | 493 static void parse_options_start(struct parse_opt_ctx_t *ctx, in parse_options_start() argument 496 memset(ctx, 0, sizeof(*ctx)); in parse_options_start() 497 ctx->argc = argc - 1; in parse_options_start() 498 ctx->argv = argv + 1; in parse_options_start() 499 ctx->out = argv; in parse_options_start() 500 ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0); in parse_options_start() 501 ctx->flags = flags; in parse_options_start() 511 static int parse_options_step(struct parse_opt_ctx_t *ctx, in parse_options_step() argument 515 int internal_help = !(ctx->flags & PARSE_OPT_NO_INTERNAL_HELP); in parse_options_step() 520 ctx->opt = NULL; in parse_options_step() [all …]
|
/tools/testing/selftests/x86/ |
D | sigreturn.c | 307 static unsigned short *ssptr(ucontext_t *ctx) in ssptr() argument 309 struct selectors *sels = (void *)&ctx->uc_mcontext.gregs[REG_CSGSFS]; in ssptr() 313 static unsigned short *csptr(ucontext_t *ctx) in csptr() argument 315 struct selectors *sels = (void *)&ctx->uc_mcontext.gregs[REG_CSGSFS]; in csptr() 323 static greg_t *ssptr(ucontext_t *ctx) in ssptr() argument 325 return &ctx->uc_mcontext.gregs[REG_SS]; in ssptr() 328 static greg_t *csptr(ucontext_t *ctx) in csptr() argument 330 return &ctx->uc_mcontext.gregs[REG_CS]; in csptr() 394 static void validate_signal_ss(int sig, ucontext_t *ctx) in validate_signal_ss() argument 397 bool was_64bit = (cs_bitness(*csptr(ctx)) == 64); in validate_signal_ss() [all …]
|
D | sysret_rip.c | 71 ucontext_t *ctx = (ucontext_t*)ctx_void; in sigsegv_for_sigreturn_test() local 73 if (rip != ctx->uc_mcontext.gregs[REG_RIP]) { in sigsegv_for_sigreturn_test() 75 rip, (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]); in sigsegv_for_sigreturn_test() 80 memcpy(&ctx->uc_mcontext.gregs, &initial_regs, sizeof(gregset_t)); in sigsegv_for_sigreturn_test() 87 ucontext_t *ctx = (ucontext_t*)ctx_void; in sigusr1() local 89 memcpy(&initial_regs, &ctx->uc_mcontext.gregs, sizeof(gregset_t)); in sigusr1() 92 ctx->uc_mcontext.gregs[REG_RIP] = rip; in sigusr1() 93 ctx->uc_mcontext.gregs[REG_RCX] = rip; in sigusr1() 96 assert(ctx->uc_mcontext.gregs[REG_EFL] == in sigusr1() 97 ctx->uc_mcontext.gregs[REG_R11]); in sigusr1() [all …]
|
D | unwind_vdso.c | 87 _Unwind_Reason_Code trace_fn(struct _Unwind_Context * ctx, void *opaque) in trace_fn() argument 90 unsigned long ip = _Unwind_GetIP(ctx); in trace_fn() 102 unsigned long eax = _Unwind_GetGR(ctx, 0); in trace_fn() 103 unsigned long ecx = _Unwind_GetGR(ctx, 1); in trace_fn() 104 unsigned long edx = _Unwind_GetGR(ctx, 2); in trace_fn() 105 unsigned long ebx = _Unwind_GetGR(ctx, 3); in trace_fn() 106 unsigned long ebp = _Unwind_GetGR(ctx, 5); in trace_fn() 107 unsigned long esi = _Unwind_GetGR(ctx, 6); in trace_fn() 108 unsigned long edi = _Unwind_GetGR(ctx, 7); in trace_fn() 128 ucontext_t *ctx = (ucontext_t *)ctx_void; in sigtrap() local [all …]
|
/tools/bpf/bpftool/ |
D | map_perf_ring.c | 74 struct event_pipe_ctx *ctx = private_data; in print_bpf_output() local 75 int idx = ctx->all_cpus ? cpu : ctx->idx; in print_bpf_output() 129 struct event_pipe_ctx ctx = { in do_event_pipe() local 158 ctx.cpu = strtoul(*argv, &endptr, 0); in do_event_pipe() 169 ctx.idx = strtoul(*argv, &endptr, 0); in do_event_pipe() 181 ctx.all_cpus = false; in do_event_pipe() 184 if (!ctx.all_cpus) { in do_event_pipe() 185 if (ctx.idx == -1 || ctx.cpu == -1) { in do_event_pipe() 190 ctx.cpu = 0; in do_event_pipe() 191 ctx.idx = 0; in do_event_pipe() [all …]
|
/tools/lib/bpf/ |
D | hashmap.h | 26 typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx); 27 typedef bool (*hashmap_equal_fn)(const void *key1, const void *key2, void *ctx); 38 void *ctx; member 46 #define HASHMAP_INIT(hash_fn, equal_fn, ctx) { \ argument 49 .ctx = (ctx), \ 57 hashmap_equal_fn equal_fn, void *ctx); 60 void *ctx); 163 for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\ 168 if (map->equal_fn(cur->key, (_key), map->ctx)) 171 for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\ [all …]
|
/tools/perf/ui/gtk/ |
D | util.c | 13 struct perf_gtk_context *ctx; in perf_gtk__activate_context() local 15 ctx = malloc(sizeof(*pgctx)); in perf_gtk__activate_context() 16 if (ctx) in perf_gtk__activate_context() 17 ctx->main_window = window; in perf_gtk__activate_context() 19 return ctx; in perf_gtk__activate_context() 22 int perf_gtk__deactivate_context(struct perf_gtk_context **ctx) in perf_gtk__deactivate_context() argument 24 if (!perf_gtk__is_active_context(*ctx)) in perf_gtk__deactivate_context() 27 zfree(ctx); in perf_gtk__deactivate_context()
|