提交 05fc8b6c 编写于 作者: M Maxim Mikityanskiy 提交者: David S. Miller

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: NMaxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: NTariq Toukan <tariqt@nvidia.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 f336d0b9
...@@ -193,7 +193,6 @@ struct tls_offload_context_tx { ...@@ -193,7 +193,6 @@ struct tls_offload_context_tx {
(sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX) (sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX)
enum tls_context_flags { enum tls_context_flags {
TLS_RX_SYNC_RUNNING = 0,
/* Unlike RX where resync is driven entirely by the core in TX only /* Unlike RX where resync is driven entirely by the core in TX only
* the driver knows when things went out of sync, so we need the flag * the driver knows when things went out of sync, so we need the flag
* to be atomic. * to be atomic.
......
...@@ -680,15 +680,13 @@ static void tls_device_resync_rx(struct tls_context *tls_ctx, ...@@ -680,15 +680,13 @@ static void tls_device_resync_rx(struct tls_context *tls_ctx,
struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx); struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);
struct net_device *netdev; struct net_device *netdev;
if (WARN_ON(test_and_set_bit(TLS_RX_SYNC_RUNNING, &tls_ctx->flags)))
return;
trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type); trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type);
rcu_read_lock();
netdev = READ_ONCE(tls_ctx->netdev); netdev = READ_ONCE(tls_ctx->netdev);
if (netdev) if (netdev)
netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn, netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn,
TLS_OFFLOAD_CTX_DIR_RX); TLS_OFFLOAD_CTX_DIR_RX);
clear_bit_unlock(TLS_RX_SYNC_RUNNING, &tls_ctx->flags); rcu_read_unlock();
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICERESYNC); TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICERESYNC);
} }
...@@ -1300,9 +1298,7 @@ static int tls_device_down(struct net_device *netdev) ...@@ -1300,9 +1298,7 @@ static int tls_device_down(struct net_device *netdev)
netdev->tlsdev_ops->tls_dev_del(netdev, ctx, netdev->tlsdev_ops->tls_dev_del(netdev, ctx,
TLS_OFFLOAD_CTX_DIR_RX); TLS_OFFLOAD_CTX_DIR_RX);
WRITE_ONCE(ctx->netdev, NULL); WRITE_ONCE(ctx->netdev, NULL);
smp_mb__before_atomic(); /* pairs with test_and_set_bit() */ synchronize_net();
while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags))
usleep_range(10, 200);
dev_put(netdev); dev_put(netdev);
list_del_init(&ctx->list); list_del_init(&ctx->list);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册