The proto ops ->stream_memory_read() is currently only used by TCP to check whether psock queue is empty or not. We need to rename it before reusing it for non-TCP protocols, and adjust the exsiting users accordingly.
Unified · Split
| @@ -1208,7 +1208,7 @@ struct proto { · 1207 unmodified lines | ||
| 1208 | 1208 | #endif |
| 1209 | 1209 | |
| 1210 | 1210 | bool (*stream_memory_free)(const struct sock *sk, int wake); |
| 1211 | − bool (*stream_memory_read)(const struct sock *sk); | |
| 1211 | + bool (*sock_is_readable)(struct sock *sk); | |
| 1212 | 1212 | /* Memory pressure */ |
| 1213 | 1213 | void (*enter_memory_pressure)(struct sock *sk); |
| 1214 | 1214 | void (*leave_memory_pressure)(struct sock *sk); |
| @@ -2820,4 +2820,10 @@ void sock_set_sndtimeo(struct sock *sk, s64 secs); · 1605 unmodified lines | ||
| 2820 | 2820 | |
| 2821 | 2821 | int sock_bind_add(struct sock *sk, struct sockaddr *addr, int addr_len); |
| 2822 | 2822 | |
| 2823 | +static inline bool sk_is_readable(struct sock *sk) | |
| 2824 | +{ | |
| 2825 | + if (sk->sk_prot->sock_is_readable) | |
| 2826 | + return sk->sk_prot->sock_is_readable(sk); | |
| 2827 | + return false; | |
| 2828 | +} | |
| 2823 | 2829 | #endif /* _SOCK_H */ |
| @@ -375,7 +375,7 @@ void tls_sw_release_resources_rx(struct sock *sk); · 374 unmodified lines | ||
| 375 | 375 | void tls_sw_free_ctx_rx(struct tls_context *tls_ctx); |
| 376 | 376 | int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, |
| 377 | 377 | int nonblock, int flags, int *addr_len); |
| 378 | −bool tls_sw_stream_read(const struct sock *sk); | |
| 378 | +bool tls_sw_sock_is_readable(struct sock *sk); | |
| 379 | 379 | ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, |
| 380 | 380 | struct pipe_inode_info *pipe, |
| 381 | 381 | size_t len, unsigned int flags); |
| @@ -486,10 +486,7 @@ static bool tcp_stream_is_readable(struct sock *sk, int target) · 485 unmodified lines | ||
| 486 | 486 | { |
| 487 | 487 | if (tcp_epollin_ready(sk, target)) |
| 488 | 488 | return true; |
| 489 | − | |
| 490 | − if (sk->sk_prot->stream_memory_read) | |
| 491 | − return sk->sk_prot->stream_memory_read(sk); | |
| 492 | − return false; | |
| 489 | + return sk_is_readable(sk); | |
| 493 | 490 | } |
| 494 | 491 | |
| 495 | 492 | /* |
| @@ -150,7 +150,7 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg, · 149 unmodified lines | ||
| 150 | 150 | EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir); |
| 151 | 151 | |
| 152 | 152 | #ifdef CONFIG_BPF_SYSCALL |
| 153 | −static bool tcp_bpf_stream_read(const struct sock *sk) | |
| 153 | +static bool tcp_bpf_sock_is_readable(struct sock *sk) | |
| 154 | 154 | { |
| 155 | 155 | struct sk_psock *psock; |
| 156 | 156 | bool empty = true; |
| @@ -491,7 +491,7 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], · 334 unmodified lines | ||
| 491 | 491 | prot[TCP_BPF_BASE].unhash = sock_map_unhash; |
| 492 | 492 | prot[TCP_BPF_BASE].close = sock_map_close; |
| 493 | 493 | prot[TCP_BPF_BASE].recvmsg = tcp_bpf_recvmsg; |
| 494 | − prot[TCP_BPF_BASE].stream_memory_read = tcp_bpf_stream_read; | |
| 494 | + prot[TCP_BPF_BASE].sock_is_readable = tcp_bpf_sock_is_readable; | |
| 495 | 495 | |
| 496 | 496 | prot[TCP_BPF_TX] = prot[TCP_BPF_BASE]; |
| 497 | 497 | prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg; |
| @@ -681,12 +681,12 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG], · 680 unmodified lines | ||
| 681 | 681 | |
| 682 | 682 | prot[TLS_BASE][TLS_SW] = prot[TLS_BASE][TLS_BASE]; |
| 683 | 683 | prot[TLS_BASE][TLS_SW].recvmsg = tls_sw_recvmsg; |
| 684 | − prot[TLS_BASE][TLS_SW].stream_memory_read = tls_sw_stream_read; | |
| 684 | + prot[TLS_BASE][TLS_SW].sock_is_readable = tls_sw_sock_is_readable; | |
| 685 | 685 | prot[TLS_BASE][TLS_SW].close = tls_sk_proto_close; |
| 686 | 686 | |
| 687 | 687 | prot[TLS_SW][TLS_SW] = prot[TLS_SW][TLS_BASE]; |
| 688 | 688 | prot[TLS_SW][TLS_SW].recvmsg = tls_sw_recvmsg; |
| 689 | − prot[TLS_SW][TLS_SW].stream_memory_read = tls_sw_stream_read; | |
| 689 | + prot[TLS_SW][TLS_SW].sock_is_readable = tls_sw_sock_is_readable; | |
| 690 | 690 | prot[TLS_SW][TLS_SW].close = tls_sk_proto_close; |
| 691 | 691 | |
| 692 | 692 | #ifdef CONFIG_TLS_DEVICE |
| @@ -2026,7 +2026,7 @@ splice_read_end: · 2025 unmodified lines | ||
| 2026 | 2026 | return copied ? : err; |
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | −bool tls_sw_stream_read(const struct sock *sk) | |
| 2029 | +bool tls_sw_sock_is_readable(struct sock *sk) | |
| 2030 | 2030 | { |
| 2031 | 2031 | struct tls_context *tls_ctx = tls_get_ctx(sk); |
| 2032 | 2032 | struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); |