Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tls: suppress wakeups unless we have a full record

TLS does not override .poll() so TLS-enabled socket will generate
an event whenever data arrives at the TCP socket. This leads to
unnecessary wakeups on slow connections.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jakub Kicinski and committed by
David S. Miller
121dca78 a395b8d1

+35
+35
net/tls/tls_main.c
··· 358 358 tls_ctx_free(sk, ctx); 359 359 } 360 360 361 + static __poll_t tls_sk_poll(struct file *file, struct socket *sock, 362 + struct poll_table_struct *wait) 363 + { 364 + struct tls_sw_context_rx *ctx; 365 + struct tls_context *tls_ctx; 366 + struct sock *sk = sock->sk; 367 + struct sk_psock *psock; 368 + __poll_t mask = 0; 369 + u8 shutdown; 370 + int state; 371 + 372 + mask = tcp_poll(file, sock, wait); 373 + 374 + state = inet_sk_state_load(sk); 375 + shutdown = READ_ONCE(sk->sk_shutdown); 376 + if (unlikely(state != TCP_ESTABLISHED || shutdown & RCV_SHUTDOWN)) 377 + return mask; 378 + 379 + tls_ctx = tls_get_ctx(sk); 380 + ctx = tls_sw_ctx_rx(tls_ctx); 381 + psock = sk_psock_get(sk); 382 + 383 + if (skb_queue_empty_lockless(&ctx->rx_list) && 384 + !tls_strp_msg_ready(ctx) && 385 + sk_psock_queue_empty(psock)) 386 + mask &= ~(EPOLLIN | EPOLLRDNORM); 387 + 388 + if (psock) 389 + sk_psock_put(sk, psock); 390 + 391 + return mask; 392 + } 393 + 361 394 static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval, 362 395 int __user *optlen, int tx) 363 396 { ··· 961 928 962 929 ops[TLS_BASE][TLS_SW ] = ops[TLS_BASE][TLS_BASE]; 963 930 ops[TLS_BASE][TLS_SW ].splice_read = tls_sw_splice_read; 931 + ops[TLS_BASE][TLS_SW ].poll = tls_sk_poll; 964 932 965 933 ops[TLS_SW ][TLS_SW ] = ops[TLS_SW ][TLS_BASE]; 966 934 ops[TLS_SW ][TLS_SW ].splice_read = tls_sw_splice_read; 935 + ops[TLS_SW ][TLS_SW ].poll = tls_sk_poll; 967 936 968 937 #ifdef CONFIG_TLS_DEVICE 969 938 ops[TLS_HW ][TLS_BASE] = ops[TLS_BASE][TLS_BASE];