/tools/testing/selftests/bpf/progs/ |
D | kfunc_call_test.c | 7 extern int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym; 8 extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b, 14 struct bpf_sock *sk = skb->sk; in kfunc_call_test2() local 16 if (!sk) in kfunc_call_test2() 19 sk = bpf_sk_fullsock(sk); in kfunc_call_test2() 20 if (!sk) in kfunc_call_test2() 23 return bpf_kfunc_call_test2((struct sock *)sk, 1, 2); in kfunc_call_test2() 29 struct bpf_sock *sk = skb->sk; in kfunc_call_test1() local 33 if (!sk) in kfunc_call_test1() 36 sk = bpf_sk_fullsock(sk); in kfunc_call_test1() [all …]
|
D | test_sk_lookup_kern.c | 63 struct bpf_sock *sk; in bpf_sk_lookup_test0() local 75 sk = bpf_sk_lookup_tcp(skb, tuple, tuple_len, BPF_F_CURRENT_NETNS, 0); in bpf_sk_lookup_test0() 76 bpf_printk("sk=%d\n", sk ? 1 : 0); in bpf_sk_lookup_test0() 77 if (sk) in bpf_sk_lookup_test0() 78 bpf_sk_release(sk); in bpf_sk_lookup_test0() 79 return sk ? TC_ACT_OK : TC_ACT_UNSPEC; in bpf_sk_lookup_test0() 86 struct bpf_sock *sk; in bpf_sk_lookup_test1() local 88 sk = bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); in bpf_sk_lookup_test1() 89 if (sk) in bpf_sk_lookup_test1() 90 bpf_sk_release(sk); in bpf_sk_lookup_test1() [all …]
|
D | bpf_dctcp.c | 59 void BPF_PROG(dctcp_init, struct sock *sk) in BPF_PROG() argument 61 const struct tcp_sock *tp = tcp_sk(sk); in BPF_PROG() 62 struct dctcp *ca = inet_csk_ca(sk); in BPF_PROG() 67 bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION, in BPF_PROG() 72 bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION, in BPF_PROG() 75 bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION, in BPF_PROG() 78 tcp_cdg_res = bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION, in BPF_PROG() 80 bpf_getsockopt(sk, SOL_TCP, TCP_CONGESTION, in BPF_PROG() 99 __u32 BPF_PROG(dctcp_ssthresh, struct sock *sk) in BPF_PROG() argument 101 struct dctcp *ca = inet_csk_ca(sk); in BPF_PROG() [all …]
|
D | test_sock_fields.c | 127 struct bpf_sock *sk, *sk_ret; in egress_read_sock_fields() local 133 sk = skb->sk; in egress_read_sock_fields() 134 if (!sk) in egress_read_sock_fields() 140 if (sk->family != AF_INET6 || !is_loopback6(sk->src_ip6) || in egress_read_sock_fields() 141 sk->state == 10) in egress_read_sock_fields() 144 if (sk->src_port == bpf_ntohs(srv_sa6.sin6_port)) { in egress_read_sock_fields() 148 } else if (sk->dst_port == srv_sa6.sin6_port) { in egress_read_sock_fields() 158 sk = bpf_sk_fullsock(sk); in egress_read_sock_fields() 159 if (!sk) in egress_read_sock_fields() 163 if (sk->protocol != IPPROTO_TCP) in egress_read_sock_fields() [all …]
|
D | test_sk_lookup.c | 103 struct bpf_sock *sk; in redir_port() local 109 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A); in redir_port() 110 if (!sk) in redir_port() 113 err = bpf_sk_assign(ctx, sk, 0); in redir_port() 114 bpf_sk_release(sk); in redir_port() 122 struct bpf_sock *sk; in redir_ip4() local 132 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A); in redir_ip4() 133 if (!sk) in redir_ip4() 136 err = bpf_sk_assign(ctx, sk, 0); in redir_ip4() 137 bpf_sk_release(sk); in redir_ip4() [all …]
|
D | kfunc_call_test_subprog.c | 8 extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b, 10 extern struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym; 16 struct bpf_sock *sk = skb->sk; in f1() local 19 if (!sk) in f1() 22 sk = bpf_sk_fullsock(sk); in f1() 23 if (!sk) in f1() 31 sk_state_res = bpf_kfunc_call_test3((struct sock *)sk)->sk_state; in f1() 33 return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4); in f1()
|
D | bpf_cubic.c | 156 static __always_inline __u32 bictcp_clock_us(const struct sock *sk) in bictcp_clock_us() argument 158 return tcp_sk(sk)->tcp_mstamp; in bictcp_clock_us() 161 static __always_inline void bictcp_hystart_reset(struct sock *sk) in bictcp_hystart_reset() argument 163 struct tcp_sock *tp = tcp_sk(sk); in bictcp_hystart_reset() 164 struct bictcp *ca = inet_csk_ca(sk); in bictcp_hystart_reset() 166 ca->round_start = ca->last_ack = bictcp_clock_us(sk); in bictcp_hystart_reset() 178 void BPF_PROG(bpf_cubic_init, struct sock *sk) in BPF_PROG() argument 180 struct bictcp *ca = inet_csk_ca(sk); in BPF_PROG() 185 bictcp_hystart_reset(sk); in BPF_PROG() 188 tcp_sk(sk)->snd_ssthresh = initial_ssthresh; in BPF_PROG() [all …]
|
D | test_sk_assign.c | 105 struct bpf_sock *sk; in handle_udp() local 115 sk = bpf_sk_lookup_udp(skb, tuple, tuple_len, BPF_F_CURRENT_NETNS, 0); in handle_udp() 116 if (sk) in handle_udp() 123 sk = bpf_map_lookup_elem(&server_map, &zero); in handle_udp() 124 if (!sk) in handle_udp() 128 ret = bpf_sk_assign(skb, sk, 0); in handle_udp() 129 bpf_sk_release(sk); in handle_udp() 137 struct bpf_sock *sk; in handle_tcp() local 147 sk = bpf_skc_lookup_tcp(skb, tuple, tuple_len, BPF_F_CURRENT_NETNS, 0); in handle_tcp() 148 if (sk) { in handle_tcp() [all …]
|
D | bpf_iter_setsockopt.c | 10 sk = NULL; \ 14 sk = (struct sock *)tp; \ 44 struct sock *sk; in change_tcp_cc() local 50 if (sk->sk_family != AF_INET6 || in change_tcp_cc() 51 (sk->sk_state != TCP_LISTEN && in change_tcp_cc() 52 sk->sk_state != TCP_ESTABLISHED) || in change_tcp_cc() 53 (sk->sk_num != reuse_listen_hport && in change_tcp_cc() 54 sk->sk_num != listen_hport && in change_tcp_cc() 55 bpf_ntohs(sk->sk_dport) != listen_hport)) in change_tcp_cc()
|
D | test_sk_storage_tracing.c | 33 int BPF_PROG(trace_inet_sock_set_state, struct sock *sk, int oldstate, in BPF_PROG() argument 41 stg = bpf_sk_storage_get(&sk_stg_map, sk, 0, in BPF_PROG() 48 bpf_sk_storage_delete(&del_sk_stg_map, sk); in BPF_PROG() 53 static void set_task_info(struct sock *sk) in set_task_info() argument 58 stg = bpf_sk_storage_get(&sk_stg_map, sk, 0, in set_task_info() 71 int BPF_PROG(trace_inet_csk_listen_start, struct sock *sk, int backlog) in BPF_PROG() argument 73 set_task_info(sk); in BPF_PROG() 79 int BPF_PROG(trace_tcp_connect, struct sock *sk) in BPF_PROG() argument 81 set_task_info(sk); in BPF_PROG() 87 int BPF_PROG(inet_csk_accept, struct sock *sk, int flags, int *err, bool kern, in BPF_PROG() argument
|
D | bpf_iter_unix.c | 10 static long sock_i_ino(const struct sock *sk) in sock_i_ino() argument 12 const struct socket *sk_socket = sk->sk_socket; in sock_i_ino() 28 struct sock *sk = (struct sock *)unix_sk; in dump_unix() local 42 sk->sk_refcnt.refs.counter, in dump_unix() 44 sk->sk_state == TCP_LISTEN ? __SO_ACCEPTCON : 0, in dump_unix() 45 sk->sk_type, in dump_unix() 46 sk->sk_socket ? in dump_unix() 47 (sk->sk_state == TCP_ESTABLISHED ? SS_CONNECTED : SS_UNCONNECTED) : in dump_unix() 48 (sk->sk_state == TCP_ESTABLISHED ? SS_CONNECTING : SS_DISCONNECTING), in dump_unix() 49 sock_i_ino(sk)); in dump_unix()
|
D | connect6_prog.c | 34 struct bpf_sock *sk; in connect_v6_prog() local 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() 56 if (!sk) in connect_v6_prog() 59 if (sk->src_ip6[0] != tuple.ipv6.daddr[0] || in connect_v6_prog() 60 sk->src_ip6[1] != tuple.ipv6.daddr[1] || in connect_v6_prog() 61 sk->src_ip6[2] != tuple.ipv6.daddr[2] || in connect_v6_prog() 62 sk->src_ip6[3] != tuple.ipv6.daddr[3] || in connect_v6_prog() 63 sk->src_port != DST_REWRITE_PORT6) { in connect_v6_prog() 64 bpf_sk_release(sk); in connect_v6_prog() [all …]
|
D | bpf_iter_udp6.c | 17 static long sock_i_ino(const struct sock *sk) in sock_i_ino() argument 19 const struct socket *sk_socket = sk->sk_socket; in sock_i_ino() 57 rqueue = inet->sk.sk_rmem_alloc.counter - udp_sk->forward_deficit; in dump_udp6() 58 dest = &inet->sk.sk_v6_daddr; in dump_udp6() 59 src = &inet->sk.sk_v6_rcv_saddr; in dump_udp6() 69 inet->sk.sk_state, in dump_udp6() 70 inet->sk.sk_wmem_alloc.refs.counter - 1, in dump_udp6() 73 sock_i_ino(&inet->sk), in dump_udp6() 74 inet->sk.sk_refcnt.refs.counter, udp_sk, in dump_udp6() 75 inet->sk.sk_drops.counter); in dump_udp6()
|
D | netns_cookie_prog.c | 33 struct bpf_sock *sk = ctx->sk; in get_netns_cookie_sockops() local 40 if (!sk) in get_netns_cookie_sockops() 45 cookie = bpf_sk_storage_get(&sockops_netns_cookies, sk, 0, in get_netns_cookie_sockops() 65 struct bpf_sock *sk = msg->sk; in get_netns_cookie_sk_msg() local 71 if (!sk) in get_netns_cookie_sk_msg() 74 cookie = bpf_sk_storage_get(&sk_msg_netns_cookies, sk, 0, in get_netns_cookie_sk_msg()
|
D | test_tcp_estats.c | 82 struct sock sk; member 83 #define inet_daddr sk.__sk_common.skc_daddr 84 #define inet_dport sk.__sk_common.skc_dport 93 static inline struct inet_sock *inet_sk(const struct sock *sk) in inet_sk() argument 95 return (struct inet_sock *)sk; in inet_sk() 212 struct sock *sk) in tcp_estats_conn_id_init() argument 214 conn_id->localport = _(inet_sk(sk)->inet_sport); in tcp_estats_conn_id_init() 215 conn_id->remport = _(inet_sk(sk)->inet_dport); in tcp_estats_conn_id_init() 217 if (_(sk->sk_family) == AF_INET6) in tcp_estats_conn_id_init() 219 sk->sk_v6_rcv_saddr.s6_addr32, in tcp_estats_conn_id_init() [all …]
|
D | bpf_iter_udp4.c | 10 static long sock_i_ino(const struct sock *sk) in sock_i_ino() argument 12 const struct socket *sk_socket = sk->sk_socket; in sock_i_ino() 47 if (inet->sk.sk_family == AF_INET6) in dump_udp4() 55 rqueue = inet->sk.sk_rmem_alloc.counter - udp_sk->forward_deficit; in dump_udp4() 61 inet->sk.sk_state, in dump_udp4() 62 inet->sk.sk_wmem_alloc.refs.counter - 1, in dump_udp4() 65 sock_i_ino(&inet->sk), in dump_udp4() 66 inet->sk.sk_refcnt.refs.counter, udp_sk, in dump_udp4() 67 inet->sk.sk_drops.counter); in dump_udp4()
|
D | test_tcp_check_syncookie_kern.c | 26 static __always_inline __s64 gen_syncookie(void *data_end, struct bpf_sock *sk, in gen_syncookie() argument 40 return bpf_tcp_gen_syncookie(sk, iph, ip_size, tcph, thlen); in gen_syncookie() 49 struct bpf_sock *sk; in check_syncookie() local 82 sk = bpf_skc_lookup_tcp(ctx, &tup, sizeof(tup.ipv4), in check_syncookie() 84 if (!sk) in check_syncookie() 87 if (sk->state != BPF_TCP_LISTEN) in check_syncookie() 90 seq_mss = gen_syncookie(data_end, sk, ipv4h, sizeof(*ipv4h), in check_syncookie() 93 ret = bpf_tcp_check_syncookie(sk, ipv4h, sizeof(*ipv4h), in check_syncookie() 114 sk = bpf_skc_lookup_tcp(ctx, &tup, sizeof(tup.ipv6), in check_syncookie() 116 if (!sk) in check_syncookie() [all …]
|
D | sockopt_sk.c | 35 struct bpf_sock *sk; in _getsockopt() local 38 sk = ctx->sk; in _getsockopt() 39 if (sk && sk->family == AF_NETLINK) in _getsockopt() 116 storage = bpf_sk_storage_get(&socket_storage_map, ctx->sk, 0, in _getsockopt() 139 struct bpf_sock *sk; in _setsockopt() local 142 sk = ctx->sk; in _setsockopt() 143 if (sk && sk->family == AF_NETLINK) in _setsockopt() 215 storage = bpf_sk_storage_get(&socket_storage_map, ctx->sk, 0, in _setsockopt()
|
D | freplace_cls_redirect.c | 22 struct bpf_sock *sk; in freplace_cls_redirect_test() local 24 sk = bpf_map_lookup_elem(&sock_map, &zero); in freplace_cls_redirect_test() 25 if (!sk) in freplace_cls_redirect_test() 28 ret = bpf_map_update_elem(&sock_map, &zero, sk, 0); in freplace_cls_redirect_test() 29 bpf_sk_release(sk); in freplace_cls_redirect_test()
|
D | bind_perm.c | 12 struct bpf_sock *sk; in bind_prog() local 14 sk = ctx->sk; in bind_prog() 15 if (!sk) in bind_prog() 18 if (sk->family != family) in bind_prog()
|
D | recvmsg4_prog.c | 19 struct bpf_sock *sk; in recvmsg4_prog() local 23 sk = ctx->sk; in recvmsg4_prog() 24 if (!sk) in recvmsg4_prog() 27 if (sk->family != AF_INET) in recvmsg4_prog()
|
D | socket_cookie_prog.c | 40 p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, in set_cookie() 54 struct bpf_sock *sk = ctx->sk; in update_cookie_sockops() local 63 if (!sk) in update_cookie_sockops() 66 p = bpf_sk_storage_get(&socket_cookies, sk, 0, 0); in update_cookie_sockops() 87 p = bpf_sk_storage_get(&socket_cookies, sock->sk, 0, 0); in BPF_PROG() 91 if (p->cookie_key != bpf_get_socket_cookie(sock->sk)) in BPF_PROG()
|
D | test_sockmap_update.c | 30 struct bpf_sock *sk; in copy_sock_map() local 34 sk = bpf_map_lookup_elem(&src, &key); in copy_sock_map() 35 if (!sk) in copy_sock_map() 38 if (bpf_map_update_elem(&dst_sock_map, &key, sk, 0)) in copy_sock_map() 41 if (bpf_map_update_elem(&dst_sock_hash, &key, sk, 0)) in copy_sock_map() 44 bpf_sk_release(sk); in copy_sock_map()
|
/tools/testing/selftests/bpf/ |
D | bpf_tcp_helpers.h | 40 struct sock sk; member 86 static __always_inline struct inet_connection_sock *inet_csk(const struct sock *sk) in inet_csk() argument 88 return (struct inet_connection_sock *)sk; in inet_csk() 91 static __always_inline void *inet_csk_ca(const struct sock *sk) in inet_csk_ca() argument 93 return (void *)inet_csk(sk)->icsk_ca_priv; in inet_csk_ca() 96 static __always_inline struct tcp_sock *tcp_sk(const struct sock *sk) in tcp_sk() argument 98 return (struct tcp_sock *)sk; in tcp_sk() 159 void (*init)(struct sock *sk); 161 void (*release)(struct sock *sk); 164 __u32 (*ssthresh)(struct sock *sk); [all …]
|
/tools/testing/selftests/pidfd/ |
D | pidfd_getfd_test.c | 36 static int __child(int sk, int memfd) in __child() argument 52 ret = send(sk, &memfd, sizeof(memfd), 0); in __child() 68 while ((ret = recv(sk, &buf, sizeof(buf), 0)) > 0) { in __child() 82 ret = send(sk, &buf, sizeof(buf), 0); in __child() 98 static int child(int sk) in child() argument 108 ret = __child(sk, memfd); in child() 112 close(sk); in child() 131 int sk; in FIXTURE() local 141 self->sk = sk_pair[0]; in FIXTURE_SETUP() 169 EXPECT_EQ(0, close(self->sk)); in FIXTURE_TEARDOWN() [all …]
|