Skip to content

Commit 05fc8b6

Browse files
nvmmaxdavem330
authored andcommitted
net/tls: Replace TLS_RX_SYNC_RUNNING with RCU
RCU synchronization is guaranteed to finish in finite time, unlike a busy loop that polls a flag. This patch is a preparation for the bugfix in the next patch, where the same synchronize_net() call will also be used to sync with the TX datapath. Signed-off-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f336d0b commit 05fc8b6

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

include/net/tls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ struct tls_offload_context_tx {
193193
(sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX)
194194

195195
enum tls_context_flags {
196-
TLS_RX_SYNC_RUNNING = 0,
197196
/* Unlike RX where resync is driven entirely by the core in TX only
198197
* the driver knows when things went out of sync, so we need the flag
199198
* to be atomic.

net/tls/tls_device.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,15 +680,13 @@ static void tls_device_resync_rx(struct tls_context *tls_ctx,
680680
struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);
681681
struct net_device *netdev;
682682

683-
if (WARN_ON(test_and_set_bit(TLS_RX_SYNC_RUNNING, &tls_ctx->flags)))
684-
return;
685-
686683
trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type);
684+
rcu_read_lock();
687685
netdev = READ_ONCE(tls_ctx->netdev);
688686
if (netdev)
689687
netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn,
690688
TLS_OFFLOAD_CTX_DIR_RX);
691-
clear_bit_unlock(TLS_RX_SYNC_RUNNING, &tls_ctx->flags);
689+
rcu_read_unlock();
692690
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICERESYNC);
693691
}
694692

@@ -1300,9 +1298,7 @@ static int tls_device_down(struct net_device *netdev)
13001298
netdev->tlsdev_ops->tls_dev_del(netdev, ctx,
13011299
TLS_OFFLOAD_CTX_DIR_RX);
13021300
WRITE_ONCE(ctx->netdev, NULL);
1303-
smp_mb__before_atomic(); /* pairs with test_and_set_bit() */
1304-
while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags))
1305-
usleep_range(10, 200);
1301+
synchronize_net();
13061302
dev_put(netdev);
13071303
list_del_init(&ctx->list);
13081304

0 commit comments

Comments
 (0)