/tools/testing/selftests/bpf/progs/ |
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 | 54 void BPF_PROG(dctcp_init, struct sock *sk) in BPF_PROG() argument 56 const struct tcp_sock *tp = tcp_sk(sk); in BPF_PROG() 57 struct dctcp *ca = inet_csk_ca(sk); in BPF_PROG() 74 __u32 BPF_PROG(dctcp_ssthresh, struct sock *sk) in BPF_PROG() argument 76 struct dctcp *ca = inet_csk_ca(sk); in BPF_PROG() 77 struct tcp_sock *tp = tcp_sk(sk); in BPF_PROG() 84 void BPF_PROG(dctcp_update_alpha, struct sock *sk, __u32 flags) in BPF_PROG() argument 86 const struct tcp_sock *tp = tcp_sk(sk); in BPF_PROG() 87 struct dctcp *ca = inet_csk_ca(sk); in BPF_PROG() 113 static __always_inline void dctcp_react_to_loss(struct sock *sk) in dctcp_react_to_loss() argument [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 | 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_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(bictcp_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 | 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 | 18 static long sock_i_ino(const struct sock *sk) in sock_i_ino() argument 20 const struct socket *sk_socket = sk->sk_socket; in sock_i_ino() 58 rqueue = inet->sk.sk_rmem_alloc.counter - udp_sk->forward_deficit; in dump_udp6() 59 dest = &inet->sk.sk_v6_daddr; in dump_udp6() 60 src = &inet->sk.sk_v6_rcv_saddr; in dump_udp6() 70 inet->sk.sk_state, in dump_udp6() 71 inet->sk.sk_wmem_alloc.refs.counter - 1, in dump_udp6() 74 sock_i_ino(&inet->sk), in dump_udp6() 75 inet->sk.sk_refcnt.refs.counter, udp_sk, in dump_udp6() 76 inet->sk.sk_drops.counter); in dump_udp6()
|
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 | 11 static long sock_i_ino(const struct sock *sk) in sock_i_ino() argument 13 const struct socket *sk_socket = sk->sk_socket; in sock_i_ino() 48 if (inet->sk.sk_family == AF_INET6) in dump_udp4() 56 rqueue = inet->sk.sk_rmem_alloc.counter - udp_sk->forward_deficit; in dump_udp4() 62 inet->sk.sk_state, in dump_udp4() 63 inet->sk.sk_wmem_alloc.refs.counter - 1, in dump_udp4() 66 sock_i_ino(&inet->sk), in dump_udp4() 67 inet->sk.sk_refcnt.refs.counter, udp_sk, in dump_udp4() 68 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 | 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 | 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()
|
D | tcp_rtt.c | 29 struct bpf_sock *sk; in _sockops() local 31 sk = ctx->sk; in _sockops() 32 if (!sk) in _sockops() 35 storage = bpf_sk_storage_get(&socket_storage_map, sk, 0, in _sockops() 48 tcp_sk = bpf_tcp_sock(sk); in _sockops()
|
D | bpf_iter_netlink.c | 19 struct netlink_sock *nlk = ctx->sk; in dump_netlink() 22 struct socket *sk; in dump_netlink() local 33 s = &nlk->sk; in dump_netlink() 50 sk = s->sk_socket; in dump_netlink() 51 if (!sk) { in dump_netlink() 58 inode = SOCK_INODE(sk); in dump_netlink()
|
D | bpf_iter_bpf_sk_storage_map.c | 23 struct sock *sk = ctx->sk; in dump_bpf_sk_storage_map() local 26 if (sk == (void *)0 || val == (void *)0) in dump_bpf_sk_storage_map() 29 if (sk->sk_family == AF_INET6) in dump_bpf_sk_storage_map()
|
D | socket_cookie_prog.c | 30 p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, in set_cookie() 44 struct bpf_sock *sk; in update_cookie() local 53 if (!ctx->sk) in update_cookie() 56 p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, 0); in update_cookie()
|
D | bpf_iter_sockmap.c | 38 struct sock *sk = ctx->sk; in copy() local 52 if (sk) { in copy() 54 return bpf_map_update_elem(&dst, &tmp, sk, 0) != 0; in copy()
|
D | connect4_prog.c | 151 struct bpf_sock *sk; in connect_v4_prog() local 173 sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv4), in connect_v4_prog() 176 sk = bpf_sk_lookup_udp(ctx, &tuple, sizeof(tuple.ipv4), in connect_v4_prog() 179 if (!sk) in connect_v4_prog() 182 if (sk->src_ip4 != tuple.ipv4.daddr || in connect_v4_prog() 183 sk->src_port != DST_REWRITE_PORT4) { in connect_v4_prog() 184 bpf_sk_release(sk); in connect_v4_prog() 188 bpf_sk_release(sk); in connect_v4_prog()
|
D | sockmap_verdict_prog.c | 43 __u8 sk, map; in bpf_prog2() local 49 sk = d[1]; in bpf_prog2() 61 return bpf_sk_redirect_map(skb, &sock_map_rx, sk, 0); in bpf_prog2() 62 return bpf_sk_redirect_map(skb, &sock_map_tx, sk, 0); in bpf_prog2()
|
D | test_sockmap_invalid_update.c | 18 if (skops->sk) in bpf_sockmap() 19 bpf_map_update_elem(&map, &key, skops->sk, 0); in bpf_sockmap()
|
/tools/testing/selftests/bpf/ |
D | bpf_tcp_helpers.h | 35 struct sock sk; member 80 static __always_inline struct inet_connection_sock *inet_csk(const struct sock *sk) in inet_csk() argument 82 return (struct inet_connection_sock *)sk; in inet_csk() 85 static __always_inline void *inet_csk_ca(const struct sock *sk) in inet_csk_ca() argument 87 return (void *)inet_csk(sk)->icsk_ca_priv; in inet_csk_ca() 90 static __always_inline struct tcp_sock *tcp_sk(const struct sock *sk) in tcp_sk() argument 92 return (struct tcp_sock *)sk; in tcp_sk() 153 void (*init)(struct sock *sk); 155 void (*release)(struct sock *sk); 158 __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 …]
|
/tools/testing/selftests/bpf/prog_tests/ |
D | sock_fields.c | 60 static void print_sk(const struct bpf_sock *sk, const char *prefix) in print_sk() argument 65 inet_ntop(AF_INET, &sk->src_ip4, src_ip4, sizeof(src_ip4)); in print_sk() 66 inet_ntop(AF_INET6, &sk->src_ip6, src_ip6, sizeof(src_ip6)); in print_sk() 67 inet_ntop(AF_INET, &sk->dst_ip4, dst_ip4, sizeof(dst_ip4)); in print_sk() 68 inet_ntop(AF_INET6, &sk->dst_ip6, dst_ip6, sizeof(dst_ip6)); in print_sk() 74 sk->state, sk->bound_dev_if, sk->family, sk->type, sk->protocol, in print_sk() 75 sk->mark, sk->priority, in print_sk() 76 sk->src_ip4, src_ip4, in print_sk() 77 sk->src_ip6[0], sk->src_ip6[1], sk->src_ip6[2], sk->src_ip6[3], in print_sk() 78 src_ip6, sk->src_port, in print_sk() [all …]
|
/tools/testing/selftests/bpf/verifier/ |
D | sock.c | 4 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 16 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 30 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 45 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 57 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 73 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 91 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 108 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 126 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), 144 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct __sk_buff, sk)), [all …]
|