Skip to content

Commit 7b50ecf

Browse files
Cong WangAlexei Starovoitov
authored andcommitted
net: Rename ->stream_memory_read to ->sock_is_readable
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. Signed-off-by: Cong Wang <cong.wang@bytedance.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211008203306.37525-2-xiyou.wangcong@gmail.com
1 parent cd9733f commit 7b50ecf

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎include/net/sock.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ struct proto {
12081208
#endif
12091209

12101210
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);
12121212
/* Memory pressure */
12131213
void (*enter_memory_pressure)(struct sock *sk);
12141214
void (*leave_memory_pressure)(struct sock *sk);
@@ -2820,4 +2820,10 @@ void sock_set_sndtimeo(struct sock *sk, s64 secs);
28202820

28212821
int sock_bind_add(struct sock *sk, struct sockaddr *addr, int addr_len);
28222822

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+
}
28232829
#endif /* _SOCK_H */

‎include/net/tls.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void tls_sw_release_resources_rx(struct sock *sk);
375375
void tls_sw_free_ctx_rx(struct tls_context *tls_ctx);
376376
int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
377377
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);
379379
ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
380380
struct pipe_inode_info *pipe,
381381
size_t len, unsigned int flags);

‎net/ipv4/tcp.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,7 @@ static bool tcp_stream_is_readable(struct sock *sk, int target)
486486
{
487487
if (tcp_epollin_ready(sk, target))
488488
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);
493490
}
494491

495492
/*

‎net/ipv4/tcp_bpf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg,
150150
EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir);
151151

152152
#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)
154154
{
155155
struct sk_psock *psock;
156156
bool empty = true;
@@ -491,7 +491,7 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],
491491
prot[TCP_BPF_BASE].unhash = sock_map_unhash;
492492
prot[TCP_BPF_BASE].close = sock_map_close;
493493
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;
495495

496496
prot[TCP_BPF_TX] = prot[TCP_BPF_BASE];
497497
prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg;

‎net/tls/tls_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,12 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG],
681681

682682
prot[TLS_BASE][TLS_SW] = prot[TLS_BASE][TLS_BASE];
683683
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;
685685
prot[TLS_BASE][TLS_SW].close = tls_sk_proto_close;
686686

687687
prot[TLS_SW][TLS_SW] = prot[TLS_SW][TLS_BASE];
688688
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;
690690
prot[TLS_SW][TLS_SW].close = tls_sk_proto_close;
691691

692692
#ifdef CONFIG_TLS_DEVICE

‎net/tls/tls_sw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
20262026
return copied ? : err;
20272027
}
20282028

2029-
bool tls_sw_stream_read(const struct sock *sk)
2029+
bool tls_sw_sock_is_readable(struct sock *sk)
20302030
{
20312031
struct tls_context *tls_ctx = tls_get_ctx(sk);
20322032
struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);

0 commit comments

Comments
 (0)