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
1208#endif1208#endif
1209 1209
1210 bool (*stream_memory_free)(const struct sock *sk, int wake);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 /* Memory pressure */1212 /* Memory pressure */
1213 void (*enter_memory_pressure)(struct sock *sk);1213 void (*enter_memory_pressure)(struct sock *sk);
1214 void (*leave_memory_pressure)(struct sock *sk);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
2821int sock_bind_add(struct sock *sk, struct sockaddr *addr, int addr_len);2821int sock_bind_add(struct sock *sk, struct sockaddr *addr, int addr_len);
2822 2822
2823static 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#endif /* _SOCK_H */2829#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
375void tls_sw_free_ctx_rx(struct tls_context *tls_ctx);375void tls_sw_free_ctx_rx(struct tls_context *tls_ctx);
376int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,376int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
377 int nonblock, int flags, int *addr_len);377 int nonblock, int flags, int *addr_len);
378bool tls_sw_stream_read(const struct sock *sk);378bool tls_sw_sock_is_readable(struct sock *sk);
379ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,379ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
380 struct pipe_inode_info *pipe,380 struct pipe_inode_info *pipe,
381 size_t len, unsigned int flags);381 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
486{486{
487 if (tcp_epollin_ready(sk, target))487 if (tcp_epollin_ready(sk, target))
488 return true;488 return true;
489 489 return sk_is_readable(sk);
490 if (sk->sk_prot->stream_memory_read)
491 return sk->sk_prot->stream_memory_read(sk);
492 return false;
493}490}
494 491
495/*492/*
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
150EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir);150EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir);
151 151
152#ifdef CONFIG_BPF_SYSCALL152#ifdef CONFIG_BPF_SYSCALL
153static bool tcp_bpf_stream_read(const struct sock *sk)153static bool tcp_bpf_sock_is_readable(struct sock *sk)
154{154{
155 struct sk_psock *psock;155 struct sk_psock *psock;
156 bool empty = true;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 prot[TCP_BPF_BASE].unhash = sock_map_unhash;491 prot[TCP_BPF_BASE].unhash = sock_map_unhash;
492 prot[TCP_BPF_BASE].close = sock_map_close;492 prot[TCP_BPF_BASE].close = sock_map_close;
493 prot[TCP_BPF_BASE].recvmsg = tcp_bpf_recvmsg;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 prot[TCP_BPF_TX] = prot[TCP_BPF_BASE];496 prot[TCP_BPF_TX] = prot[TCP_BPF_BASE];
497 prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg;497 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
681 681
682 prot[TLS_BASE][TLS_SW] = prot[TLS_BASE][TLS_BASE];682 prot[TLS_BASE][TLS_SW] = prot[TLS_BASE][TLS_BASE];
683 prot[TLS_BASE][TLS_SW].recvmsg = tls_sw_recvmsg;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 prot[TLS_BASE][TLS_SW].close = tls_sk_proto_close;685 prot[TLS_BASE][TLS_SW].close = tls_sk_proto_close;
686 686
687 prot[TLS_SW][TLS_SW] = prot[TLS_SW][TLS_BASE];687 prot[TLS_SW][TLS_SW] = prot[TLS_SW][TLS_BASE];
688 prot[TLS_SW][TLS_SW].recvmsg = tls_sw_recvmsg;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 prot[TLS_SW][TLS_SW].close = tls_sk_proto_close;690 prot[TLS_SW][TLS_SW].close = tls_sk_proto_close;
691 691
692#ifdef CONFIG_TLS_DEVICE692#ifdef CONFIG_TLS_DEVICE
net/tls/tls_sw.c+1−1
@@ -2026,7 +2026,7 @@ splice_read_end: · 2025 unmodified lines
2026 return copied ? : err;2026 return copied ? : err;
2027}2027}
2028 2028
2029bool tls_sw_stream_read(const struct sock *sk)2029bool tls_sw_sock_is_readable(struct sock *sk)
2030{2030{
2031 struct tls_context *tls_ctx = tls_get_ctx(sk);2031 struct tls_context *tls_ctx = tls_get_ctx(sk);
2032 struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);2032 struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);