History

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.

Cong Wang committed 5 years ago

Commit 7b50ecf1 parent cd9733f6 files · +14 −11Browse files

Unified · Split

6 files
  1. include/net/sock.h +7 −1
  2. include/net/tls.h +1 −1
  3. net/ipv4/tcp.c +1 −4
  4. net/ipv4/tcp_bpf.c +2 −2
  5. net/tls/tls_main.c +2 −2
  6. net/tls/tls_sw.c +1 −1
include/net/sock.h+7−1
@@ -1208,7 +1208,7 @@ struct proto { · 1207 unmodified lines
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); · 1605 unmodified lines
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+1−1
@@ -375,7 +375,7 @@ void tls_sw_release_resources_rx(struct sock *sk); · 374 unmodified lines
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+1−4
@@ -486,10 +486,7 @@ static bool tcp_stream_is_readable(struct sock *sk, int target) · 485 unmodified lines
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+2−2
@@ -150,7 +150,7 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg, · 149 unmodified lines
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], · 334 unmodified lines
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+2−2
@@ -681,12 +681,12 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG], · 680 unmodified lines
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+1−1
@@ -2026,7 +2026,7 @@ splice_read_end: · 2025 unmodified lines
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);